当前位置: 首页>>代码示例>>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;未经允许,请勿转载。