org.elasticsearch.action.ActionRequestValidationException Java Examples
The following examples show how to use
org.elasticsearch.action.ActionRequestValidationException.
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: AddFeaturesToSetAction.java From elasticsearch-learning-to-rank with Apache License 2.0 | 6 votes |
@Override public ActionRequestValidationException validate() { ActionRequestValidationException arve = null; if (store == null) { arve = addValidationError("store must be set", null); } if (featureNameQuery != null && features != null && !features.isEmpty()) { arve = addValidationError("if featureNameQuery is set features cannot", arve); } else if (featureNameQuery == null && (features == null || features.isEmpty())) { arve = addValidationError("either featureNameQuery or features must be set", arve); } if (featureSet == null) { arve = addValidationError("featureSet must be set", arve); } return arve; }
Example #2
Source File: AnalyzeRequest.java From Elasticsearch with Apache License 2.0 | 5 votes |
@Override public ActionRequestValidationException validate() { ActionRequestValidationException validationException = null; if (text == null || text.length == 0) { validationException = addValidationError("text is missing", validationException); } return validationException; }
Example #3
Source File: AnomalyResultRequest.java From anomaly-detection with Apache License 2.0 | 5 votes |
@Override public ActionRequestValidationException validate() { ActionRequestValidationException validationException = null; if (Strings.isEmpty(adID)) { validationException = addValidationError(CommonErrorMessages.AD_ID_MISSING_MSG, validationException); } if (start <= 0 || end <= 0 || start > end) { validationException = addValidationError( String.format(Locale.ROOT, "%s: start %d, end %d", INVALID_TIMESTAMP_ERR_MSG, start, end), validationException ); } return validationException; }
Example #4
Source File: GetRequest.java From Elasticsearch with Apache License 2.0 | 5 votes |
@Override public ActionRequestValidationException validate() { ActionRequestValidationException validationException = super.validateNonNullIndex(); if (type == null) { validationException = ValidateActions.addValidationError("type is missing", validationException); } if (id == null) { validationException = ValidateActions.addValidationError("id is missing", validationException); } if (!versionType.validateVersionForReads(version)) { validationException = ValidateActions.addValidationError("illegal version value [" + version + "] for version type [" + versionType.name() + "]", validationException); } return validationException; }
Example #5
Source File: InstanceShardOperationRequest.java From Elasticsearch with Apache License 2.0 | 5 votes |
@Override public ActionRequestValidationException validate() { ActionRequestValidationException validationException = null; if (index == null) { validationException = ValidateActions.addValidationError("index is missing", validationException); } return validationException; }
Example #6
Source File: IngestRequestTest.java From elasticsearch-helper with Apache License 2.0 | 5 votes |
@Test(expected = ActionRequestValidationException.class) public void testIngest4() { Client client = client("1"); IndexRequest r = Requests.indexRequest().index(null).type(null).id(null); IngestRequestBuilder builder = new IngestRequestBuilder(client, IngestAction.INSTANCE) .add(r); client.execute(IngestAction.INSTANCE, builder.request()).actionGet(); }
Example #7
Source File: AbstractRequestBuilder.java From elasticshell with Apache License 2.0 | 5 votes |
/** * Executes the underlying request after the request validation * @return the result of the execution */ public Output execute() { ActionRequestValidationException validationException = request().validate(); if (validationException != null) { throw validationException; } return responseToOutput(request, doExecute(request()).actionGet()); }
Example #8
Source File: TermsByQueryRequest.java From siren-join with GNU Affero General Public License v3.0 | 5 votes |
/** * Validates the request * * @return null if valid, exception otherwise */ @Override public ActionRequestValidationException validate() { ActionRequestValidationException validationException = super.validate(); if (termsEncoding != null && termsEncoding.equals(TermsEncoding.BYTES)) { if (maxTermsPerShard == null) { validationException = ValidateActions.addValidationError("maxTermsPerShard not specified for terms encoding [bytes]", validationException); } } return validationException; }
Example #9
Source File: DeleteIndexedScriptRequest.java From Elasticsearch with Apache License 2.0 | 5 votes |
@Override public ActionRequestValidationException validate() { ActionRequestValidationException validationException = null; if (scriptLang == null) { validationException = addValidationError("scriptLang is missing", validationException); } if (id == null) { validationException = addValidationError("id is missing", validationException); } if (!versionType.validateVersionForWrites(version)) { validationException = addValidationError("illegal version value [" + version + "] for version scriptLang [" + versionType.name() + "]", validationException); } return validationException; }
Example #10
Source File: IngestRequestTest.java From elasticsearch-helper with Apache License 2.0 | 5 votes |
@Test(expected = ActionRequestValidationException.class) public void testIngest2() { Client client = client("1"); IngestRequestBuilder builder = new IngestRequestBuilder(client, IngestAction.INSTANCE) .add((IndexRequest)null); client.execute(IngestAction.INSTANCE, builder.request()).actionGet(); }
Example #11
Source File: ResetWhitelistRequest.java From Elasticsearch with Apache License 2.0 | 5 votes |
@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; }
Example #12
Source File: DeleteIndexTemplateRequest.java From Elasticsearch with Apache License 2.0 | 5 votes |
@Override public ActionRequestValidationException validate() { ActionRequestValidationException validationException = null; if (name == null) { validationException = addValidationError("name is missing", validationException); } return validationException; }
Example #13
Source File: IngestReplicaShardRequest.java From elasticsearch-helper with Apache License 2.0 | 5 votes |
@Override public ActionRequestValidationException validate() { ActionRequestValidationException validationException = null; if (index == null) { validationException = addValidationError("index is missing", null); } return validationException; }
Example #14
Source File: ExplainRequest.java From Elasticsearch with Apache License 2.0 | 5 votes |
@Override public ActionRequestValidationException validate() { ActionRequestValidationException validationException = super.validateNonNullIndex(); if (type == null) { validationException = ValidateActions.addValidationError("type is missing", validationException); } if (id == null) { validationException = ValidateActions.addValidationError("id is missing", validationException); } if (source == null) { validationException = ValidateActions.addValidationError("source is missing", validationException); } return validationException; }
Example #15
Source File: UpdateRequest.java From Elasticsearch with Apache License 2.0 | 5 votes |
@Override public ActionRequestValidationException validate() { ActionRequestValidationException validationException = super.validate(); if (type == null) { validationException = addValidationError("type is missing", validationException); } if (id == null) { validationException = addValidationError("id is missing", validationException); } if (!(versionType == VersionType.INTERNAL || versionType == VersionType.FORCE)) { validationException = addValidationError("version type [" + versionType + "] is not supported by the update API", validationException); } else { if (version != Versions.MATCH_ANY && retryOnConflict > 0) { validationException = addValidationError("can't provide both retry_on_conflict and a specific version", validationException); } if (!versionType.validateVersionForWrites(version)) { validationException = addValidationError("illegal version value [" + version + "] for version type [" + versionType.name() + "]", validationException); } } if (script == null && doc == null) { validationException = addValidationError("script or doc is missing", validationException); } if (script != null && doc != null) { validationException = addValidationError("can't provide both script and doc", validationException); } if (doc == null && docAsUpsert) { validationException = addValidationError("doc must be specified if doc_as_upsert is enabled", validationException); } return validationException; }
Example #16
Source File: AlterTenantPropertyRequest.java From Elasticsearch with Apache License 2.0 | 5 votes |
@Override public ActionRequestValidationException validate() { if (nodeNum < 0) { ActionRequestValidationException validationException = new ActionRequestValidationException(); validationException.addValidationError("instance num must > 0"); } return null; }
Example #17
Source File: SearchScrollRequest.java From Elasticsearch with Apache License 2.0 | 5 votes |
@Override public ActionRequestValidationException validate() { ActionRequestValidationException validationException = null; if (scrollId == null) { validationException = addValidationError("scrollId is missing", validationException); } return validationException; }
Example #18
Source File: RepairTenantRequest.java From Elasticsearch with Apache License 2.0 | 5 votes |
@Override public ActionRequestValidationException validate() { if (tenantNames == null || tenantNames.length < 1) { ActionRequestValidationException validationException = new ActionRequestValidationException(); validationException.addValidationError("should specify a tenant"); return validationException; } return null; }
Example #19
Source File: HttpAction.java From elasticsearch-helper with Apache License 2.0 | 5 votes |
public final void execute(HttpInvocationContext<Request,Response> httpInvocationContext, ActionListener<Response> listener) { ActionRequestValidationException validationException = httpInvocationContext.getRequest().validate(); if (validationException != null) { listener.onFailure(validationException); return; } httpInvocationContext.setListener(listener); httpInvocationContext.setMillis(System.currentTimeMillis()); try { doExecute(httpInvocationContext); } catch(Throwable t) { logger.error("exception during http action execution", t); listener.onFailure(t); } }
Example #20
Source File: IngestRequestTest.java From elasticsearch-helper with Apache License 2.0 | 5 votes |
@Test(expected = ActionRequestValidationException.class) public void testIngest3() { Client client = client("1"); IndexRequest r = new IndexRequestBuilder(client, IndexAction.INSTANCE).request(); IngestRequestBuilder builder = new IngestRequestBuilder(client, IngestAction.INSTANCE) .add(r); client.execute(IngestAction.INSTANCE, builder.request()).actionGet(); }
Example #21
Source File: GetIndexedScriptRequest.java From Elasticsearch with Apache License 2.0 | 5 votes |
@Override public ActionRequestValidationException validate() { ActionRequestValidationException validationException = null; if (scriptLang == null) { validationException = ValidateActions.addValidationError("type is missing", validationException); } if (id == null) { validationException = ValidateActions.addValidationError("id is missing", validationException); } if (!versionType.validateVersionForReads(version)) { validationException = ValidateActions.addValidationError("illegal version value [" + version + "] for version type [" + versionType.name() + "]", validationException); } return validationException; }
Example #22
Source File: PutWarmerRequest.java From Elasticsearch with Apache License 2.0 | 5 votes |
@Override public ActionRequestValidationException validate() { ActionRequestValidationException validationException = null; if (searchRequest == null) { validationException = addValidationError("search request is missing", validationException); } else { validationException = searchRequest.validate(); } if (name == null) { validationException = addValidationError("name is missing", validationException); } return validationException; }
Example #23
Source File: DeleteRequest.java From Elasticsearch with Apache License 2.0 | 5 votes |
@Override public ActionRequestValidationException validate() { ActionRequestValidationException validationException = super.validate(); if (type == null) { validationException = addValidationError("type is missing", validationException); } if (id == null) { validationException = addValidationError("id is missing", validationException); } if (!versionType.validateVersionForWrites(version)) { validationException = addValidationError("illegal version value [" + version + "] for version type [" + versionType.name() + "]", validationException); } return validationException; }
Example #24
Source File: RestGetSourceAction.java From Elasticsearch with Apache License 2.0 | 5 votes |
@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); } } }); }
Example #25
Source File: DeleteWarmerRequest.java From Elasticsearch with Apache License 2.0 | 5 votes |
@Override public ActionRequestValidationException validate() { ActionRequestValidationException validationException = null; if (CollectionUtils.isEmpty(names)) { validationException = addValidationError("warmer names are missing", validationException); } else { validationException = checkForEmptyString(validationException, names); } if (CollectionUtils.isEmpty(indices)) { validationException = addValidationError("indices are missing", validationException); } else { validationException = checkForEmptyString(validationException, indices); } return validationException; }
Example #26
Source File: IngestLeaderShardRequest.java From elasticsearch-helper with Apache License 2.0 | 5 votes |
@Override public ActionRequestValidationException validate() { ActionRequestValidationException validationException = null; if (index == null) { validationException = addValidationError("index is missing", null); } return validationException; }
Example #27
Source File: IndicesAliasesRequest.java From Elasticsearch with Apache License 2.0 | 5 votes |
@Override public ActionRequestValidationException validate() { ActionRequestValidationException validationException = null; if (allAliasActions.isEmpty()) { return addValidationError("Must specify at least one alias action", validationException); } for (AliasActions aliasAction : allAliasActions) { if (CollectionUtils.isEmpty(aliasAction.aliases)) { validationException = addValidationError("Alias action [" + aliasAction.actionType().name().toLowerCase(Locale.ENGLISH) + "]: Property [alias/aliases] is either missing or null", validationException); } else { for (String alias : aliasAction.aliases) { if (!Strings.hasText(alias)) { validationException = addValidationError("Alias action [" + aliasAction.actionType().name().toLowerCase(Locale.ENGLISH) + "]: [alias/aliases] may not be empty string", validationException); } } } if (CollectionUtils.isEmpty(aliasAction.indices)) { validationException = addValidationError("Alias action [" + aliasAction.actionType().name().toLowerCase(Locale.ENGLISH) + "]: Property [index/indices] is either missing or null", validationException); } else { for (String index : aliasAction.indices) { if (!Strings.hasText(index)) { validationException = addValidationError("Alias action [" + aliasAction.actionType().name().toLowerCase(Locale.ENGLISH) + "]: [index/indices] may not be empty string", validationException); } } } } return validationException; }
Example #28
Source File: CloseIndexRequest.java From Elasticsearch with Apache License 2.0 | 5 votes |
@Override public ActionRequestValidationException validate() { ActionRequestValidationException validationException = null; if (CollectionUtils.isEmpty(indices)) { validationException = addValidationError("index is missing", validationException); } return validationException; }
Example #29
Source File: UpgradeSettingsRequest.java From Elasticsearch with Apache License 2.0 | 5 votes |
@Override public ActionRequestValidationException validate() { ActionRequestValidationException validationException = null; if (versions.isEmpty()) { validationException = addValidationError("no indices to update", validationException); } return validationException; }
Example #30
Source File: SingleShardRequest.java From Elasticsearch with Apache License 2.0 | 5 votes |
/** * @return a validation exception if the index property hasn't been set */ protected ActionRequestValidationException validateNonNullIndex() { ActionRequestValidationException validationException = null; if (index == null) { validationException = ValidateActions.addValidationError("index is missing", validationException); } return validationException; }