|
33 | 33 | import com.fasterxml.jackson.databind.JsonNode; |
34 | 34 | import com.fasterxml.jackson.databind.ObjectMapper; |
35 | 35 | import com.fasterxml.jackson.databind.node.JsonNodeType; |
| 36 | +import com.marklogic.client.*; |
36 | 37 | import com.marklogic.client.DatabaseClientFactory.HandleFactoryRegistry; |
37 | | -import com.marklogic.client.MarkLogicBindingException; |
38 | | -import com.marklogic.client.MarkLogicIOException; |
39 | | -import com.marklogic.client.MarkLogicInternalException; |
40 | | -import com.marklogic.client.Transaction; |
41 | 38 | import com.marklogic.client.document.DocumentWriteSet; |
42 | 39 | import com.marklogic.client.expression.PlanBuilder; |
43 | 40 | import com.marklogic.client.expression.PlanBuilder.Plan; |
@@ -422,11 +419,22 @@ private RESTServiceResultIterator submitPlan(PlanBuilderBaseImpl.RequestPlan req |
422 | 419 | AbstractWriteHandle astHandle = requestPlan.getHandle(); |
423 | 420 | List<ContentParam> contentParams = requestPlan.getContentParams(); |
424 | 421 | final String path = determinePath(); |
425 | | - if (contentParams != null && !contentParams.isEmpty()) { |
426 | | - contentParams.add(new ContentParam(new PlanBuilderBaseImpl.PlanParamBase("query"), astHandle, null)); |
427 | | - return services.postMultipartForm(requestLogger, path, transaction, params, contentParams); |
428 | | - } |
429 | | - return services.postIteratedResource(requestLogger, path, transaction, params, astHandle); |
| 422 | + try { |
| 423 | + if (contentParams != null && !contentParams.isEmpty()) { |
| 424 | + contentParams.add(new ContentParam(new PlanBuilderBaseImpl.PlanParamBase("query"), astHandle, null)); |
| 425 | + return services.postMultipartForm(requestLogger, path, transaction, params, contentParams); |
| 426 | + } |
| 427 | + return services.postIteratedResource(requestLogger, path, transaction, params, astHandle); |
| 428 | + } catch (FailedRequestException ex) { |
| 429 | + String message = ex.getMessage(); |
| 430 | + if (message != null && message.contains("RESTAPI-UPDATEFROMQUERY")) { |
| 431 | + String betterMessage = "The Optic plan is attempting an update but was sent to the wrong REST API endpoint. " + |
| 432 | + "You must invoke `withUpdate(true)` on the instance of com.marklogic.client.row.RowManager that you " + |
| 433 | + "are using to submit the plan"; |
| 434 | + throw new FailedRequestException(betterMessage, ex.getFailedRequest()); |
| 435 | + } |
| 436 | + throw ex; |
| 437 | + } |
430 | 438 | } |
431 | 439 |
|
432 | 440 | private PlanBuilderBaseImpl.RequestPlan checkPlan(Plan plan) { |
|
0 commit comments