Skip to content

Commit 13e6b2b

Browse files
committed
---
yaml --- r: 6819 b: refs/heads/tswast-patch-1 c: 896de75 h: refs/heads/master i: 6817: 4ae7336 6815: a203d4f
1 parent c82f301 commit 13e6b2b

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
@@ -57,5 +57,5 @@ refs/tags/v0.18.0: 9d193c4c4b9d1c6f21515dd8e50836b9194ec9bb
5757
refs/tags/v0.19.0: e67b56e4d8dad5f9a7b38c9b2107c23c828f2ed5
5858
refs/tags/v0.20.0: 839f7fb7156535146aa1cb2c5aadd8d375d854e8
5959
refs/tags/v0.20.1: 370471f437f1f4f68a11e068df5cd6bf39edb1fa
60-
refs/heads/tswast-patch-1: bc4b8204093d92782d04319c8efda9aae424b9cc
60+
refs/heads/tswast-patch-1: 896de75d1cad86e1b2cc2e82bb20700c240fd4ec
6161
refs/heads/pubsub-streaming-pull: 19262b752ee874eb2ca3b950eb2aef44d5a5267b

branches/tswast-patch-1/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/tswast-patch-1/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)