当前位置: 首页>>代码示例>>Java>>正文


Java ActionRequestValidationException.addValidationError方法代码示例

本文整理汇总了Java中org.elasticsearch.action.ActionRequestValidationException.addValidationError方法的典型用法代码示例。如果您正苦于以下问题:Java ActionRequestValidationException.addValidationError方法的具体用法?Java ActionRequestValidationException.addValidationError怎么用?Java ActionRequestValidationException.addValidationError使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在org.elasticsearch.action.ActionRequestValidationException的用法示例。


在下文中一共展示了ActionRequestValidationException.addValidationError方法的10个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: 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

示例2: testRequestValidation

import org.elasticsearch.action.ActionRequestValidationException; //导入方法依赖的package包/类
public void testRequestValidation() {
    ActionRequestValidationException validationException = new ActionRequestValidationException();
    validationException.addValidationError("validation error");
    ActionRequest request = new ActionRequest() {
        @Override
        public ActionRequestValidationException validate() {
            return validationException;
        }
    };

    {
        ActionRequestValidationException actualException = expectThrows(ActionRequestValidationException.class,
                () -> restHighLevelClient.performRequest(request, null, null, null));
        assertSame(validationException, actualException);
    }
    {
        TrackingActionListener trackingActionListener = new TrackingActionListener();
        restHighLevelClient.performRequestAsync(request, null, null, trackingActionListener, null);
        assertSame(validationException, trackingActionListener.exception.get());
    }
}
 
开发者ID:justor,项目名称:elasticsearch_my,代码行数:22,代码来源:RestHighLevelClientTests.java

示例3: prepareRequest

import org.elasticsearch.action.ActionRequestValidationException; //导入方法依赖的package包/类
@Override
public RestChannelConsumer prepareRequest(final RestRequest request, final NodeClient client) throws IOException {
    final GetRequest getRequest = new GetRequest(request.param("index"), request.param("type"), request.param("id"));
    getRequest.operationThreaded(true);
    getRequest.refresh(request.paramAsBoolean("refresh", getRequest.refresh()));
    getRequest.routing(request.param("routing"));
    getRequest.parent(request.param("parent"));
    getRequest.preference(request.param("preference"));
    getRequest.realtime(request.paramAsBoolean("realtime", getRequest.realtime()));

    getRequest.fetchSourceContext(FetchSourceContext.parseFromRestRequest(request));

    return channel -> {
        if (getRequest.fetchSourceContext() != null && !getRequest.fetchSourceContext().fetchSource()) {
            final ActionRequestValidationException validationError = new ActionRequestValidationException();
            validationError.addValidationError("fetching source can not be disabled");
            channel.sendResponse(new BytesRestResponse(channel, validationError));
        } else {
            client.get(getRequest, new RestResponseListener<GetResponse>(channel) {
                @Override
                public RestResponse buildResponse(final GetResponse response) throws Exception {
                    final XContentBuilder builder = channel.newBuilder(request.getXContentType(), false);
                    // check if doc source (or doc itself) is missing
                    if (response.isSourceEmpty()) {
                        return new BytesRestResponse(NOT_FOUND, builder);
                    } else {
                        builder.rawValue(response.getSourceInternal());
                        return new BytesRestResponse(OK, builder);
                    }
                }
            });
        }
    };
}
 
开发者ID:justor,项目名称:elasticsearch_my,代码行数:35,代码来源:RestGetSourceAction.java

示例4: validate

import org.elasticsearch.action.ActionRequestValidationException; //导入方法依赖的package包/类
@Override
public ActionRequestValidationException validate() {
    String usernameWithoutTenant = UserProperty.getUsernameWithoutTenantFromFullUsername(username);
    if (UserProperty.ROOT_NAME.equalsIgnoreCase(usernameWithoutTenant)) {
        ActionRequestValidationException invalidRequestError = new ActionRequestValidationException();
        invalidRequestError.addValidationError("could not set root's whitelist");
        return invalidRequestError;
    }
    return null;
}
 
开发者ID:baidu,项目名称:Elasticsearch,代码行数:11,代码来源:ResetWhitelistRequest.java

示例5: validate

import org.elasticsearch.action.ActionRequestValidationException; //导入方法依赖的package包/类
@Override
public ActionRequestValidationException validate() {
    String usernameWithoutTenant = UserProperty.getUsernameWithoutTenantFromFullUsername(username);
    if (UserProperty.ROOT_NAME.equalsIgnoreCase(usernameWithoutTenant)) {
        ActionRequestValidationException invalidRequestError = new ActionRequestValidationException();
        invalidRequestError.addValidationError("could drop root user");
        return invalidRequestError;
    }
    return null;
}
 
开发者ID:baidu,项目名称:Elasticsearch,代码行数:11,代码来源:DropUserRequest.java

示例6: validate

import org.elasticsearch.action.ActionRequestValidationException; //导入方法依赖的package包/类
@Override
public ActionRequestValidationException validate() {
    String usernameWithoutTenant = UserProperty.getUsernameWithoutTenantFromFullUsername(username);
    if (UserProperty.ROOT_NAME.equalsIgnoreCase(usernameWithoutTenant)) {
        ActionRequestValidationException invalidRequestError = new ActionRequestValidationException();
        invalidRequestError.addValidationError("could not grant or revoke privilege to root user");
        return invalidRequestError;
    }
    return null;
}
 
开发者ID:baidu,项目名称:Elasticsearch,代码行数:11,代码来源:GrantOrRevokeUserPrivilegeRequest.java

示例7: validate

import org.elasticsearch.action.ActionRequestValidationException; //导入方法依赖的package包/类
@Override
public ActionRequestValidationException validate() {
    if (nodeNum < 0) {
        ActionRequestValidationException validationException = new ActionRequestValidationException();
        validationException.addValidationError("instance num must > 0");
    }
    return null;
}
 
开发者ID:baidu,项目名称:Elasticsearch,代码行数:9,代码来源:AlterTenantPropertyRequest.java

示例8: validate

import org.elasticsearch.action.ActionRequestValidationException; //导入方法依赖的package包/类
@Override
public ActionRequestValidationException validate() {
    if (tenantNames == null || tenantNames.length < 1) {
        ActionRequestValidationException validationException = new ActionRequestValidationException();
        validationException.addValidationError("should specify a tenant");
        return validationException;
    }
    return null;
}
 
开发者ID:baidu,项目名称:Elasticsearch,代码行数:10,代码来源:RepairTenantRequest.java

示例9: validate

import org.elasticsearch.action.ActionRequestValidationException; //导入方法依赖的package包/类
@Override
public ActionRequestValidationException validate() {
    if (stmt == null) {
        ActionRequestValidationException e =  new ActionRequestValidationException();
        e.addValidationError("Attribute 'stmt' must not be null");
        return e;
    }
    return null;
}
 
开发者ID:baidu,项目名称:Elasticsearch,代码行数:10,代码来源:SQLBaseRequest.java

示例10: handleRequest

import org.elasticsearch.action.ActionRequestValidationException; //导入方法依赖的package包/类
@Override
public void handleRequest(final RestRequest request, final RestChannel channel, final Client client) {
    final GetRequest getRequest = new GetRequest(request.param("index"), request.param("type"), request.param("id"));
    getRequest.operationThreaded(true);
    getRequest.refresh(request.paramAsBoolean("refresh", getRequest.refresh()));
    getRequest.routing(request.param("routing"));  // order is important, set it after routing, so it will set the routing
    getRequest.parent(request.param("parent"));
    getRequest.preference(request.param("preference"));
    getRequest.realtime(request.paramAsBoolean("realtime", null));

    getRequest.fetchSourceContext(FetchSourceContext.parseFromRestRequest(request));

    if (getRequest.fetchSourceContext() != null && !getRequest.fetchSourceContext().fetchSource()) {
        try {
            ActionRequestValidationException validationError = new ActionRequestValidationException();
            validationError.addValidationError("fetching source can not be disabled");
            channel.sendResponse(new BytesRestResponse(channel, validationError));
        } catch (IOException e) {
            logger.error("Failed to send failure response", e);
        }
    }

    client.get(getRequest, new RestResponseListener<GetResponse>(channel) {
        @Override
        public RestResponse buildResponse(GetResponse response) throws Exception {
            XContentBuilder builder = channel.newBuilder(response.getSourceInternal(), false);
            if (!response.isExists()) {
                return new BytesRestResponse(NOT_FOUND, builder);
            } else {
                builder.rawValue(response.getSourceInternal());
                return new BytesRestResponse(OK, builder);
            }
        }
    });
}
 
开发者ID:baidu,项目名称:Elasticsearch,代码行数:36,代码来源:RestGetSourceAction.java


注:本文中的org.elasticsearch.action.ActionRequestValidationException.addValidationError方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。