Skip to content

Commit 29af0f8

Browse files
committed
---
yaml --- r: 3551 b: refs/heads/pubsub-alpha c: 896de75 h: refs/heads/master i: 3549: c613368 3547: 20c288d 3543: 25d6633 3535: 3949e1a 3519: a60db54
1 parent 998c68e commit 29af0f8

3 files changed

Lines changed: 32 additions & 18 deletions

File tree

[refs]

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
refs/heads/master: 36a62ef856d199f8efd09501b5ba65c422c01f23
33
refs/heads/travis: e21ee7b88a5edc3f3d8c71f90c3fc32abf7e8dd6
44
refs/heads/gh-pages: 7406918e071dd2c5677a638ae2a06e7592b6542c
5-
refs/heads/pubsub-alpha: bc4b8204093d92782d04319c8efda9aae424b9cc
5+
refs/heads/pubsub-alpha: 896de75d1cad86e1b2cc2e82bb20700c240fd4ec
66
refs/heads/update-datastore: 47aae517c2cb33f1dccd909adaced73ec9d0f4df
77
refs/tags/0.0.9: 22f1839238f66c39e67ed4dfdcd273b1ae2e8444
88
refs/tags/v0.0.10: 207ebd2a3472fddee69fe1298eb90429e3306efd

branches/pubsub-alpha/gcloud-java-dns/src/main/java/com/google/gcloud/spi/DefaultDnsRpc.java

Lines changed: 20 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,7 @@
3030
*/
3131
public class DefaultDnsRpc implements DnsRpc {
3232

33+
private static final String SORTING_KEY = "changeSequence";
3334
private final Dns dns;
3435
private final DnsOptions options;
3536

@@ -64,9 +65,14 @@ public ManagedZone getZone(String zoneName, Map<Option, ?> options) throws DnsEx
6465
// just fields option
6566
try {
6667
return dns.managedZones().get(this.options.projectId(), zoneName)
67-
.setFields(FIELDS.getString(options)).execute();
68+
.setFields(FIELDS.getString(options))
69+
.execute();
6870
} catch (IOException ex) {
69-
throw translate(ex);
71+
DnsException serviceException = translate(ex);
72+
if (serviceException.code() == HTTP_NOT_FOUND) {
73+
return null;
74+
}
75+
throw serviceException;
7076
}
7177
}
7278

@@ -151,7 +157,16 @@ public Change getChangeRequest(String zoneName, String changeRequestId, Map<Opti
151157
.setFields(FIELDS.getString(options))
152158
.execute();
153159
} catch (IOException ex) {
154-
throw translate(ex);
160+
DnsException serviceException = translate(ex);
161+
if (serviceException.code() == HTTP_NOT_FOUND) {
162+
// message format "The 'parameters.changeId' resource named '4' does not exist."
163+
if (serviceException.getMessage().contains("changeId")) {
164+
// the change id was not found, but the zone exists
165+
return null;
166+
}
167+
// the zone does not exist, so throw an exception
168+
}
169+
throw serviceException;
155170
}
156171
}
157172

@@ -165,9 +180,8 @@ public Tuple<String, Iterable<Change>> listChangeRequests(String zoneName, Map<O
165180
.setMaxResults(PAGE_SIZE.getInt(options))
166181
.setPageToken(PAGE_TOKEN.getString(options));
167182
if (SORTING_ORDER.getString(options) != null) {
168-
// this needs to be checked and changed if more sorting options are implemented, issue #604
169-
String key = "changeSequence";
170-
request = request.setSortBy(key).setSortOrder(SORTING_ORDER.getString(options));
183+
// todo check and change if more sorting options are implemented, issue #604
184+
request = request.setSortBy(SORTING_KEY).setSortOrder(SORTING_ORDER.getString(options));
171185
}
172186
ChangesListResponse response = request.execute();
173187
return Tuple.<String, Iterable<Change>>of(response.getNextPageToken(), response.getChanges());

branches/pubsub-alpha/gcloud-java-dns/src/main/java/com/google/gcloud/spi/DnsRpc.java

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -85,7 +85,7 @@ public Y y() {
8585
* Creates a new zone.
8686
*
8787
* @param zone a zone to be created
88-
* @return Updated {@link ManagedZone} object
88+
* @return Updated {@code ManagedZone} object
8989
* @throws DnsException upon failure
9090
*/
9191
ManagedZone create(ManagedZone zone) throws DnsException;
@@ -121,7 +121,7 @@ public Y y() {
121121
*
122122
* @param zoneName name of the zone to be listed
123123
* @param options a map of options for the service call
124-
* @throws DnsException upon failure or if zone not found
124+
* @throws DnsException upon failure or if zone was not found
125125
*/
126126
Tuple<String, Iterable<ResourceRecordSet>> listDnsRecords(String zoneName,
127127
Map<Option, ?> options) throws DnsException;
@@ -131,40 +131,40 @@ Tuple<String, Iterable<ResourceRecordSet>> listDnsRecords(String zoneName,
131131
*
132132
* @param options a map of options for the service call
133133
* @return up-to-date project information
134-
* @throws DnsException upon failure
134+
* @throws DnsException upon failure or if the project is not found
135135
*/
136136
Project getProject(Map<Option, ?> options) throws DnsException;
137137

138138
/**
139139
* Applies change request to a zone.
140140
*
141-
* @param zoneName the name of a zone to which the {@link Change} should be applied
141+
* @param zoneName the name of a zone to which the {@code Change} should be applied
142142
* @param changeRequest change to be applied
143143
* @param options a map of options for the service call
144144
* @return updated change object with server-assigned ID
145-
* @throws DnsException upon failure or if zone not found
145+
* @throws DnsException upon failure or if zone was not found
146146
*/
147147
Change applyChangeRequest(String zoneName, Change changeRequest, Map<Option, ?> options)
148148
throws DnsException;
149149

150150
/**
151151
* Returns an existing change request.
152152
*
153-
* @param zoneName the name of a zone to which the {@link Change} was be applied
153+
* @param zoneName the name of a zone to which the {@code Change} was be applied
154154
* @param changeRequestId the unique id assigned to the change by the server
155155
* @param options a map of options for the service call
156-
* @return up-to-date change object
157-
* @throws DnsException upon failure or if zone not found
156+
* @return up-to-date change object or {@code null} if change was not found
157+
* @throws DnsException upon failure or if zone was not found
158158
*/
159159
Change getChangeRequest(String zoneName, String changeRequestId, Map<Option, ?> options)
160160
throws DnsException;
161161

162162
/**
163-
* List an existing change requests for a zone.
163+
* List existing change requests for a zone.
164164
*
165-
* @param zoneName the name of a zone to which the {@link Change}s were be applied
165+
* @param zoneName the name of a zone to which the {@code Change}s were be applied
166166
* @param options a map of options for the service call
167-
* @throws DnsException upon failure or if zone not found
167+
* @throws DnsException upon failure or if zone was not found
168168
*/
169169
Tuple<String, Iterable<Change>> listChangeRequests(String zoneName, Map<Option, ?> options)
170170
throws DnsException;

0 commit comments

Comments
 (0)