當前位置: 首頁>>代碼示例>>Java>>正文


Java ActionRequestValidationException類代碼示例

本文整理匯總了Java中org.elasticsearch.action.ActionRequestValidationException的典型用法代碼示例。如果您正苦於以下問題:Java ActionRequestValidationException類的具體用法?Java ActionRequestValidationException怎麽用?Java ActionRequestValidationException使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。


ActionRequestValidationException類屬於org.elasticsearch.action包,在下文中一共展示了ActionRequestValidationException類的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: validate

import org.elasticsearch.action.ActionRequestValidationException; //導入依賴的package包/類
@Override
public ActionRequestValidationException validate() {
    ActionRequestValidationException validationException = null;

    if (id == null || id.isEmpty()) {
        validationException = addValidationError("must specify id for stored script", validationException);
    } else if (id.contains("#")) {
        validationException = addValidationError("id cannot contain '#' for stored script", validationException);
    }

    if (lang != null && lang.contains("#")) {
        validationException = addValidationError("lang cannot contain '#' for stored script", validationException);
    }

    return validationException;
}
 
開發者ID:justor,項目名稱:elasticsearch_my,代碼行數:17,代碼來源:GetStoredScriptRequest.java

示例2: validate

import org.elasticsearch.action.ActionRequestValidationException; //導入依賴的package包/類
@Override
public ActionRequestValidationException validate() {
    ActionRequestValidationException validationException = null;
    if (items.isEmpty()) {
        validationException = ValidateActions.addValidationError("no documents to get", validationException);
    } else {
        for (int i = 0; i < items.size(); i++) {
            Item item = items.get(i);
            if (item.index() == null) {
                validationException = ValidateActions.addValidationError("index is missing for doc " + i, validationException);
            }
            if (item.id() == null) {
                validationException = ValidateActions.addValidationError("id is missing for doc " + i, validationException);
            }
        }
    }
    return validationException;
}
 
開發者ID:justor,項目名稱:elasticsearch_my,代碼行數:19,代碼來源:MultiGetRequest.java

示例3: validateAgainstAliases

import org.elasticsearch.action.ActionRequestValidationException; //導入依賴的package包/類
/**
 * Throws an ActionRequestValidationException if the request tries to index
 * back into the same index or into an index that points to two indexes.
 * This cannot be done during request validation because the cluster state
 * isn't available then. Package private for testing.
 */
static void validateAgainstAliases(SearchRequest source, IndexRequest destination, RemoteInfo remoteInfo,
                                     IndexNameExpressionResolver indexNameExpressionResolver, AutoCreateIndex autoCreateIndex,
                                     ClusterState clusterState) {
    if (remoteInfo != null) {
        return;
    }
    String target = destination.index();
    if (false == autoCreateIndex.shouldAutoCreate(target, clusterState)) {
        /*
         * If we're going to autocreate the index we don't need to resolve
         * it. This is the same sort of dance that TransportIndexRequest
         * uses to decide to autocreate the index.
         */
        target = indexNameExpressionResolver.concreteIndexNames(clusterState, destination)[0];
    }
    for (String sourceIndex : indexNameExpressionResolver.concreteIndexNames(clusterState, source)) {
        if (sourceIndex.equals(target)) {
            ActionRequestValidationException e = new ActionRequestValidationException();
            e.addValidationError("reindex cannot write into an index its reading from [" + target + ']');
            throw e;
        }
    }
}
 
開發者ID:justor,項目名稱:elasticsearch_my,代碼行數:30,代碼來源:TransportReindexAction.java

示例4: performRequestAsync

import org.elasticsearch.action.ActionRequestValidationException; //導入依賴的package包/類
<Req extends ActionRequest, Resp> void performRequestAsync(Req request,
                                                           CheckedFunction<Req, Request, IOException> requestConverter,
                                                           CheckedFunction<Response, Resp, IOException> responseConverter,
                                                           ActionListener<Resp> listener, Set<Integer> ignores, Header... headers) {
    ActionRequestValidationException validationException = request.validate();
    if (validationException != null) {
        listener.onFailure(validationException);
        return;
    }
    Request req;
    try {
        req = requestConverter.apply(request);
    } catch (Exception e) {
        listener.onFailure(e);
        return;
    }

    ResponseListener responseListener = wrapResponseListener(responseConverter, listener, ignores);
    client.performRequestAsync(req.method, req.endpoint, req.params, req.entity, responseListener, headers);
}
 
開發者ID:justor,項目名稱:elasticsearch_my,代碼行數:21,代碼來源:RestHighLevelClient.java

示例5: validate

import org.elasticsearch.action.ActionRequestValidationException; //導入依賴的package包/類
@Override
public ActionRequestValidationException validate() {
    ActionRequestValidationException validationException = null;
    if (type == null) {
        validationException = addValidationError("mapping type is missing", validationException);
    }else if (type.isEmpty()) {
        validationException = addValidationError("mapping type is empty", validationException);
    }
    if (source == null) {
        validationException = addValidationError("mapping source is missing", validationException);
    } else if (source.isEmpty()) {
        validationException = addValidationError("mapping source is empty", validationException);
    }
    if (concreteIndex != null && (indices != null && indices.length > 0)) {
        validationException = addValidationError("either concrete index or unresolved indices can be set, concrete index: ["
            + concreteIndex + "] and indices: " + Arrays.asList(indices) , validationException);
    }
    return validationException;
}
 
開發者ID:justor,項目名稱:elasticsearch_my,代碼行數:20,代碼來源:PutMappingRequest.java

示例6: validate

import org.elasticsearch.action.ActionRequestValidationException; //導入依賴的package包/類
@Override
public ActionRequestValidationException validate() {
    ActionRequestValidationException validationException = null;
    if (snapshot == null) {
        validationException = addValidationError("name is missing", validationException);
    }
    if (repository == null) {
        validationException = addValidationError("repository is missing", validationException);
    }
    if (indices == null) {
        validationException = addValidationError("indices are missing", validationException);
    }
    if (indicesOptions == null) {
        validationException = addValidationError("indicesOptions is missing", validationException);
    }
    if (settings == null) {
        validationException = addValidationError("settings are missing", validationException);
    }
    if (indexSettings == null) {
        validationException = addValidationError("indexSettings are missing", validationException);
    }
    if (ignoreIndexSettings == null) {
        validationException = addValidationError("ignoreIndexSettings are missing", validationException);
    }
    return validationException;
}
 
開發者ID:baidu,項目名稱:Elasticsearch,代碼行數:27,代碼來源:RestoreSnapshotRequest.java

示例7: validate

import org.elasticsearch.action.ActionRequestValidationException; //導入依賴的package包/類
@Override
public ActionRequestValidationException validate() {
    ActionRequestValidationException validationException = null;

    if (id == null || id.isEmpty()) {
        validationException = addValidationError("must specify id for stored script", validationException);
    } else if (id.contains("#")) {
        validationException = addValidationError("id cannot contain '#' for stored script", validationException);
    }

    if (lang != null && lang.contains("#")) {
        validationException = addValidationError("lang cannot contain '#' for stored script", validationException);
    }

    if (content == null) {
        validationException = addValidationError("must specify code for stored script", validationException);
    }

    return validationException;
}
 
開發者ID:justor,項目名稱:elasticsearch_my,代碼行數:21,代碼來源:PutStoredScriptRequest.java

示例8: execute

import org.elasticsearch.action.ActionRequestValidationException; //導入依賴的package包/類
/**
 * Use this method when the transport action should continue to run in the context of the current task
 */
public final void execute(Task task, Request request, ActionListener<Response> listener) {

    ActionRequestValidationException validationException = request.validate();
    if (validationException != null) {
        listener.onFailure(validationException);
        return;
    }

    if (filters.length == 0) {
        try {
            doExecute(task, request, listener);
        } catch(Throwable t) {
            logger.trace("Error during transport action execution.", t);
            listener.onFailure(t);
        }
    } else {
        RequestFilterChain requestFilterChain = new RequestFilterChain<>(this, logger);
        requestFilterChain.proceed(task, actionName, request, listener);
    }
}
 
開發者ID:baidu,項目名稱:Elasticsearch,代碼行數:24,代碼來源:TransportAction.java

示例9: testUpdateRequestWithBothScriptAndDoc

import org.elasticsearch.action.ActionRequestValidationException; //導入依賴的package包/類
public void testUpdateRequestWithBothScriptAndDoc() throws Exception {
    createTestIndex();
    ensureGreen();

    try {
        client().prepareUpdate(indexOrAlias(), "type1", "1")
                .setDoc(XContentFactory.jsonBuilder().startObject().field("field", 1).endObject())
                .setScript(new Script(ScriptType.INLINE, "field_inc", "field", Collections.emptyMap()))
                .execute().actionGet();
        fail("Should have thrown ActionRequestValidationException");
    } catch (ActionRequestValidationException e) {
        assertThat(e.validationErrors().size(), equalTo(1));
        assertThat(e.validationErrors().get(0), containsString("can't provide both script and doc"));
        assertThat(e.getMessage(), containsString("can't provide both script and doc"));
    }
}
 
開發者ID:justor,項目名稱:elasticsearch_my,代碼行數:17,代碼來源:UpdateIT.java

示例10: doPrepareRequest

import org.elasticsearch.action.ActionRequestValidationException; //導入依賴的package包/類
protected RestChannelConsumer doPrepareRequest(RestRequest request, NodeClient client,
                                               boolean includeCreated, boolean includeUpdated) throws IOException {
    // Build the internal request
    Request internal = setCommonOptions(request, buildRequest(request));

    // Executes the request and waits for completion
    if (request.paramAsBoolean("wait_for_completion", true)) {
        Map<String, String> params = new HashMap<>();
        params.put(BulkByScrollTask.Status.INCLUDE_CREATED, Boolean.toString(includeCreated));
        params.put(BulkByScrollTask.Status.INCLUDE_UPDATED, Boolean.toString(includeUpdated));

        return channel -> client.executeLocally(action, internal, new BulkIndexByScrollResponseContentListener(channel, params));
    } else {
        internal.setShouldStoreResult(true);
    }

    /*
     * Let's try and validate before forking so the user gets some error. The
     * task can't totally validate until it starts but this is better than
     * nothing.
     */
    ActionRequestValidationException validationException = internal.validate();
    if (validationException != null) {
        throw validationException;
    }
    return sendTask(client.getLocalNodeId(), client.executeLocally(action, internal, LoggingTaskListener.instance()));
}
 
開發者ID:justor,項目名稱:elasticsearch_my,代碼行數:28,代碼來源:AbstractBaseReindexRestHandler.java

示例11: validate

import org.elasticsearch.action.ActionRequestValidationException; //導入依賴的package包/類
@Override
public ActionRequestValidationException validate() {
    ActionRequestValidationException validationException = null;
    if (name == null) {
        validationException = addValidationError("name is missing", validationException);
    }
    return validationException;
}
 
開發者ID:baidu,項目名稱:Elasticsearch,代碼行數:9,代碼來源:DeleteIndexTemplateRequest.java

示例12: validate

import org.elasticsearch.action.ActionRequestValidationException; //導入依賴的package包/類
@Override
public ActionRequestValidationException validate() {
    ActionRequestValidationException validationException = null;
    if (repositories == null) {
        validationException = addValidationError("repositories is null", validationException);
    }
    return validationException;
}
 
開發者ID:baidu,項目名稱:Elasticsearch,代碼行數:9,代碼來源:GetRepositoriesRequest.java

示例13: testReindexFromRemoteDoesNotSupportSearchQuery

import org.elasticsearch.action.ActionRequestValidationException; //導入依賴的package包/類
public void testReindexFromRemoteDoesNotSupportSearchQuery() {
    ReindexRequest reindex = newRequest();
    reindex.setRemoteInfo(
            new RemoteInfo(randomAsciiOfLength(5), randomAsciiOfLength(5), between(1, Integer.MAX_VALUE), new BytesArray("real_query"),
                    null, null, emptyMap(), RemoteInfo.DEFAULT_SOCKET_TIMEOUT, RemoteInfo.DEFAULT_CONNECT_TIMEOUT));
    reindex.getSearchRequest().source().query(matchAllQuery()); // Unsupported place to put query
    ActionRequestValidationException e = reindex.validate();
    assertEquals("Validation Failed: 1: reindex from remote sources should use RemoteInfo's query instead of source's query;",
            e.getMessage());
}
 
開發者ID:justor,項目名稱:elasticsearch_my,代碼行數:11,代碼來源:ReindexRequestTests.java

示例14: testReindexFromRemoteDoesNotSupportWorkers

import org.elasticsearch.action.ActionRequestValidationException; //導入依賴的package包/類
public void testReindexFromRemoteDoesNotSupportWorkers() {
    ReindexRequest reindex = newRequest();
    reindex.setRemoteInfo(
            new RemoteInfo(randomAsciiOfLength(5), randomAsciiOfLength(5), between(1, Integer.MAX_VALUE), new BytesArray("real_query"),
                    null, null, emptyMap(), RemoteInfo.DEFAULT_SOCKET_TIMEOUT, RemoteInfo.DEFAULT_CONNECT_TIMEOUT));
    reindex.setSlices(between(2, Integer.MAX_VALUE));
    ActionRequestValidationException e = reindex.validate();
    assertEquals(
            "Validation Failed: 1: reindex from remote sources doesn't support workers > 1 but was [" + reindex.getSlices() + "];",
            e.getMessage());
}
 
開發者ID:justor,項目名稱:elasticsearch_my,代碼行數:12,代碼來源:ReindexRequestTests.java

示例15: validate

import org.elasticsearch.action.ActionRequestValidationException; //導入依賴的package包/類
@Override
public ActionRequestValidationException validate() {
    ActionRequestValidationException validationException = null;
    if (transientSettings.getAsMap().isEmpty() && persistentSettings.getAsMap().isEmpty()
            && transientSettingsToRemove.size() == 0
            && persistentSettingsToRemove.size() == 0) {
        validationException = addValidationError("no settings to update", validationException);
    }
    return validationException;
}
 
開發者ID:baidu,項目名稱:Elasticsearch,代碼行數:11,代碼來源:ClusterUpdateSettingsRequest.java


注:本文中的org.elasticsearch.action.ActionRequestValidationException類示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。