16
16
package com .basho .riak .client .api .commands .buckets ;
17
17
18
18
import com .basho .riak .client .api .commands .ChunkedResponseIterator ;
19
+ import com .basho .riak .client .api .ListException ;
19
20
import com .basho .riak .client .api .StreamableRiakCommand ;
20
21
import com .basho .riak .client .core .FutureOperation ;
21
22
import com .basho .riak .client .core .StreamingRiakFuture ;
@@ -68,10 +69,15 @@ public final class ListBuckets extends StreamableRiakCommand.StreamableRiakComma
68
69
private final int timeout ;
69
70
private final BinaryValue type ;
70
71
71
- ListBuckets (Builder builder )
72
+ ListBuckets (Builder builder ) throws ListException
72
73
{
73
74
this .timeout = builder .timeout ;
74
75
this .type = builder .type ;
76
+
77
+ if (builder .allowListing == false )
78
+ {
79
+ throw new ListException ();
80
+ }
75
81
}
76
82
77
83
@ Override
@@ -170,6 +176,7 @@ public static class Builder
170
176
{
171
177
private int timeout ;
172
178
private final BinaryValue type ;
179
+ private boolean allowListing ;
173
180
174
181
/**
175
182
* Construct a Builder for a ListBuckets command.
@@ -180,6 +187,21 @@ public Builder(String type)
180
187
this .type = BinaryValue .create (type );
181
188
}
182
189
190
+ /**
191
+ * Allow this listing command
192
+ * <p>
193
+ * Bucket and key list operations are expensive and should not
194
+ * be used in production, however using this method will allow
195
+ * the command to be built.
196
+ * </p>
197
+ * @return a reference to this object.
198
+ */
199
+ public Builder withAllowListing ()
200
+ {
201
+ this .allowListing = true ;
202
+ return this ;
203
+ }
204
+
183
205
/**
184
206
* Construct a Builder for a ListBuckets command.
185
207
* @param type the bucket type.
@@ -208,7 +230,7 @@ public Builder withTimeout(int timeout)
208
230
* Construct a new ListBuckets command.
209
231
* @return a new ListBuckets command.
210
232
*/
211
- public ListBuckets build ()
233
+ public ListBuckets build () throws ListException
212
234
{
213
235
return new ListBuckets (this );
214
236
}
0 commit comments