|
3 | 3 | import com.fasterxml.jackson.core.JsonParseException; |
4 | 4 | import com.fasterxml.jackson.databind.JsonMappingException; |
5 | 5 | import com.google.common.base.Preconditions; |
| 6 | +import com.socrata.api.DatasetDestination; |
6 | 7 | import com.socrata.exceptions.LongRunningQueryException; |
7 | 8 | import com.socrata.exceptions.SodaError; |
8 | 9 | import com.socrata.model.SearchResults; |
@@ -135,19 +136,38 @@ public DatasetInfo createDataset(final DatasetInfo dataset) throws SodaError, In |
135 | 136 | * |
136 | 137 | * The new dataset will be unpublished. |
137 | 138 | * |
| 139 | + * Prefer to use the createDataset(DatasetInfo, DatasetDestination) method, as this |
| 140 | + * one has surprising behavior when useNewBackend is false. |
| 141 | + * |
138 | 142 | * @param dataset dataset to create the new dataset on. The ID should NOT be set. |
139 | | - * @param useNewBackend iff true create dataset on the New Backend |
| 143 | + * @param useNewBackend if true create dataset on the New Backend, otherwise use the default. |
140 | 144 | * @return the created dataset, the ID will be set on this. |
141 | 145 | * @throws SodaError |
142 | 146 | * @throws InterruptedException |
143 | 147 | */ |
144 | 148 | public DatasetInfo createDataset(final DatasetInfo dataset, final boolean useNewBackend) throws SodaError, InterruptedException |
| 149 | + { |
| 150 | + return createDataset(dataset, useNewBackend ? DatasetDestination.NBE : null); |
| 151 | + } |
| 152 | + |
| 153 | + /** |
| 154 | + * Creates an empty dataset, based on the dataset passed in. |
| 155 | + * |
| 156 | + * The new dataset will be unpublished. |
| 157 | + * |
| 158 | + * @param dataset dataset to create the new dataset on. The ID should NOT be set. |
| 159 | + * @param destination Specify the backend for the new dataset, or null for the default. |
| 160 | + * @return the created dataset, the ID will be set on this. |
| 161 | + * @throws SodaError |
| 162 | + * @throws InterruptedException |
| 163 | + */ |
| 164 | + public DatasetInfo createDataset(final DatasetInfo dataset, final DatasetDestination destination) throws SodaError, InterruptedException |
145 | 165 | { |
146 | 166 | SodaRequest requester = new SodaRequest<DatasetInfo>(null, dataset) |
147 | 167 | { |
148 | 168 | public Response issueRequest() throws LongRunningQueryException, SodaError |
149 | 169 | { |
150 | | - httpLowLevel.setUseNewBackend(useNewBackend); |
| 170 | + httpLowLevel.setDatasetDestination(destination); |
151 | 171 | return httpLowLevel.postRaw(viewUri, HttpLowLevel.JSON_TYPE, ContentEncoding.IDENTITY, payload); |
152 | 172 | } |
153 | 173 | }; |
|
0 commit comments