+
+ /**
+ * This function accepts any JSON and will "blindly" write it to the
+ * document store.
+ *
+ * Note, eventually this "dynamic" flow should follow the same JSON-Schema
+ * validation procedure as the normal create index flow.
+ *
+ * @param dynamicSchema - The JSON string that will be sent to the document store.
+ * @param index - The name of the index to be created.
+ * @param documentStore - The document store specific interface.
+ * @return The result of the document store interface's operation.
+ */
+ public Response processCreateDynamicIndex(String dynamicSchema, HttpServletRequest request,
+ HttpHeaders headers, String index, DocumentStoreInterface documentStore) {
+
+ Response response = null;
+
+ Response validationResponse = validateRequest(request, headers, index, SearchDbMsgs.INDEX_CREATE_FAILURE);
+
+ if (validationResponse.getStatus() != Response.Status.OK.getStatusCode()) {
+ response = validationResponse;
+ } else {
+ OperationResult result = documentStore.createDynamicIndex(index, dynamicSchema);
+
+ int resultCode = (result.getResultCode() == 200) ? 201 : result.getResultCode();
+ String resultString = (result.getFailureCause() == null) ? result.getResult() : result.getFailureCause();
+
+ response = Response.status(resultCode).entity(resultString).build();
+ }
+
+ return response;
+ }