Deprecated ToXContent.Params#paramAsBooleanOptional in favour of paramAsBoolean
Closes #4817
This commit is contained in:
parent
66ed9a855a
commit
8f96930638
|
@ -156,13 +156,16 @@ public class TransportGetFieldMappingsAction extends TransportClusterInfoAction<
|
||||||
return defaultValue;
|
return defaultValue;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
public Boolean paramAsBoolean(String key, Boolean defaultValue) {
|
||||||
public Boolean paramAsBooleanOptional(String key, Boolean defaultValue) {
|
|
||||||
if (INCLUDE_DEFAULTS.equals(key)) {
|
if (INCLUDE_DEFAULTS.equals(key)) {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
return defaultValue;
|
return defaultValue;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override @Deprecated
|
||||||
|
public Boolean paramAsBooleanOptional(String key, Boolean defaultValue) {
|
||||||
|
return paramAsBoolean(key, defaultValue);
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
|
@ -36,6 +36,13 @@ public interface ToXContent {
|
||||||
|
|
||||||
boolean paramAsBoolean(String key, boolean defaultValue);
|
boolean paramAsBoolean(String key, boolean defaultValue);
|
||||||
|
|
||||||
|
Boolean paramAsBoolean(String key, Boolean defaultValue);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @deprecated since 1.0.0
|
||||||
|
* use {@link ToXContent.Params#paramAsBoolean(String, Boolean)} instead
|
||||||
|
*/
|
||||||
|
@Deprecated
|
||||||
Boolean paramAsBooleanOptional(String key, Boolean defaultValue);
|
Boolean paramAsBooleanOptional(String key, Boolean defaultValue);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -56,9 +63,14 @@ public interface ToXContent {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Boolean paramAsBooleanOptional(String key, Boolean defaultValue) {
|
public Boolean paramAsBoolean(String key, Boolean defaultValue) {
|
||||||
return defaultValue;
|
return defaultValue;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override @Deprecated
|
||||||
|
public Boolean paramAsBooleanOptional(String key, Boolean defaultValue) {
|
||||||
|
return paramAsBoolean(key, defaultValue);
|
||||||
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
public static class MapParams implements Params {
|
public static class MapParams implements Params {
|
||||||
|
@ -89,9 +101,14 @@ public interface ToXContent {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Boolean paramAsBooleanOptional(String key, Boolean defaultValue) {
|
public Boolean paramAsBoolean(String key, Boolean defaultValue) {
|
||||||
return Booleans.parseBoolean(param(key), defaultValue);
|
return Booleans.parseBoolean(param(key), defaultValue);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override @Deprecated
|
||||||
|
public Boolean paramAsBooleanOptional(String key, Boolean defaultValue) {
|
||||||
|
return paramAsBoolean(key, defaultValue);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public static class DelegatingMapParams extends MapParams {
|
public static class DelegatingMapParams extends MapParams {
|
||||||
|
@ -119,6 +136,11 @@ public interface ToXContent {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
public Boolean paramAsBoolean(String key, Boolean defaultValue) {
|
||||||
|
return super.paramAsBoolean(key, delegate.paramAsBoolean(key, defaultValue));
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override @Deprecated
|
||||||
public Boolean paramAsBooleanOptional(String key, Boolean defaultValue) {
|
public Boolean paramAsBooleanOptional(String key, Boolean defaultValue) {
|
||||||
return super.paramAsBooleanOptional(key, delegate.paramAsBooleanOptional(key, defaultValue));
|
return super.paramAsBooleanOptional(key, delegate.paramAsBooleanOptional(key, defaultValue));
|
||||||
}
|
}
|
||||||
|
|
|
@ -135,10 +135,15 @@ public abstract class RestRequest implements ToXContent.Params {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Boolean paramAsBooleanOptional(String key, Boolean defaultValue) {
|
public Boolean paramAsBoolean(String key, Boolean defaultValue) {
|
||||||
return Booleans.parseBoolean(param(key), defaultValue);
|
return Booleans.parseBoolean(param(key), defaultValue);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override @Deprecated
|
||||||
|
public Boolean paramAsBooleanOptional(String key, Boolean defaultValue) {
|
||||||
|
return paramAsBoolean(key, defaultValue);
|
||||||
|
}
|
||||||
|
|
||||||
public TimeValue paramAsTime(String key, TimeValue defaultValue) {
|
public TimeValue paramAsTime(String key, TimeValue defaultValue) {
|
||||||
return parseTimeValue(param(key), defaultValue);
|
return parseTimeValue(param(key), defaultValue);
|
||||||
}
|
}
|
||||||
|
|
|
@ -76,7 +76,7 @@ public class RestExplainAction extends BaseRestHandler {
|
||||||
queryStringBuilder.analyzer(request.param("analyzer"));
|
queryStringBuilder.analyzer(request.param("analyzer"));
|
||||||
queryStringBuilder.analyzeWildcard(request.paramAsBoolean("analyze_wildcard", false));
|
queryStringBuilder.analyzeWildcard(request.paramAsBoolean("analyze_wildcard", false));
|
||||||
queryStringBuilder.lowercaseExpandedTerms(request.paramAsBoolean("lowercase_expanded_terms", true));
|
queryStringBuilder.lowercaseExpandedTerms(request.paramAsBoolean("lowercase_expanded_terms", true));
|
||||||
queryStringBuilder.lenient(request.paramAsBooleanOptional("lenient", null));
|
queryStringBuilder.lenient(request.paramAsBoolean("lenient", null));
|
||||||
String defaultOperator = request.param("default_operator");
|
String defaultOperator = request.param("default_operator");
|
||||||
if (defaultOperator != null) {
|
if (defaultOperator != null) {
|
||||||
if ("OR".equals(defaultOperator)) {
|
if ("OR".equals(defaultOperator)) {
|
||||||
|
|
|
@ -23,7 +23,6 @@ import org.elasticsearch.action.ActionListener;
|
||||||
import org.elasticsearch.action.get.GetRequest;
|
import org.elasticsearch.action.get.GetRequest;
|
||||||
import org.elasticsearch.action.get.GetResponse;
|
import org.elasticsearch.action.get.GetResponse;
|
||||||
import org.elasticsearch.client.Client;
|
import org.elasticsearch.client.Client;
|
||||||
import org.elasticsearch.common.Booleans;
|
|
||||||
import org.elasticsearch.common.Strings;
|
import org.elasticsearch.common.Strings;
|
||||||
import org.elasticsearch.common.inject.Inject;
|
import org.elasticsearch.common.inject.Inject;
|
||||||
import org.elasticsearch.common.settings.Settings;
|
import org.elasticsearch.common.settings.Settings;
|
||||||
|
@ -60,7 +59,7 @@ public class RestGetAction extends BaseRestHandler {
|
||||||
getRequest.routing(request.param("routing")); // order is important, set it after routing, so it will set the routing
|
getRequest.routing(request.param("routing")); // order is important, set it after routing, so it will set the routing
|
||||||
getRequest.parent(request.param("parent"));
|
getRequest.parent(request.param("parent"));
|
||||||
getRequest.preference(request.param("preference"));
|
getRequest.preference(request.param("preference"));
|
||||||
getRequest.realtime(request.paramAsBooleanOptional("realtime", null));
|
getRequest.realtime(request.paramAsBoolean("realtime", null));
|
||||||
|
|
||||||
String sField = request.param("fields");
|
String sField = request.param("fields");
|
||||||
if (sField != null) {
|
if (sField != null) {
|
||||||
|
|
|
@ -58,7 +58,7 @@ public class RestGetSourceAction extends BaseRestHandler {
|
||||||
getRequest.routing(request.param("routing")); // order is important, set it after routing, so it will set the routing
|
getRequest.routing(request.param("routing")); // order is important, set it after routing, so it will set the routing
|
||||||
getRequest.parent(request.param("parent"));
|
getRequest.parent(request.param("parent"));
|
||||||
getRequest.preference(request.param("preference"));
|
getRequest.preference(request.param("preference"));
|
||||||
getRequest.realtime(request.paramAsBooleanOptional("realtime", null));
|
getRequest.realtime(request.paramAsBoolean("realtime", null));
|
||||||
|
|
||||||
getRequest.fetchSourceContext(FetchSourceContext.parseFromRestRequest(request));
|
getRequest.fetchSourceContext(FetchSourceContext.parseFromRestRequest(request));
|
||||||
|
|
||||||
|
|
|
@ -54,7 +54,7 @@ public class RestHeadAction extends BaseRestHandler {
|
||||||
getRequest.routing(request.param("routing")); // order is important, set it after routing, so it will set the routing
|
getRequest.routing(request.param("routing")); // order is important, set it after routing, so it will set the routing
|
||||||
getRequest.parent(request.param("parent"));
|
getRequest.parent(request.param("parent"));
|
||||||
getRequest.preference(request.param("preference"));
|
getRequest.preference(request.param("preference"));
|
||||||
getRequest.realtime(request.paramAsBooleanOptional("realtime", null));
|
getRequest.realtime(request.paramAsBoolean("realtime", null));
|
||||||
// don't get any fields back...
|
// don't get any fields back...
|
||||||
getRequest.fields(Strings.EMPTY_ARRAY);
|
getRequest.fields(Strings.EMPTY_ARRAY);
|
||||||
// TODO we can also just return the document size as Content-Length
|
// TODO we can also just return the document size as Content-Length
|
||||||
|
|
|
@ -61,7 +61,7 @@ public class RestMultiGetAction extends BaseRestHandler {
|
||||||
multiGetRequest.listenerThreaded(false);
|
multiGetRequest.listenerThreaded(false);
|
||||||
multiGetRequest.refresh(request.paramAsBoolean("refresh", multiGetRequest.refresh()));
|
multiGetRequest.refresh(request.paramAsBoolean("refresh", multiGetRequest.refresh()));
|
||||||
multiGetRequest.preference(request.param("preference"));
|
multiGetRequest.preference(request.param("preference"));
|
||||||
multiGetRequest.realtime(request.paramAsBooleanOptional("realtime", null));
|
multiGetRequest.realtime(request.paramAsBoolean("realtime", null));
|
||||||
|
|
||||||
String[] sFields = null;
|
String[] sFields = null;
|
||||||
String sField = request.param("fields");
|
String sField = request.param("fields");
|
||||||
|
|
|
@ -86,7 +86,7 @@ public class RestPercolateAction extends BaseRestHandler {
|
||||||
getRequest.routing(restRequest.param("routing"));
|
getRequest.routing(restRequest.param("routing"));
|
||||||
getRequest.preference(restRequest.param("preference"));
|
getRequest.preference(restRequest.param("preference"));
|
||||||
getRequest.refresh(restRequest.paramAsBoolean("refresh", getRequest.refresh()));
|
getRequest.refresh(restRequest.paramAsBoolean("refresh", getRequest.refresh()));
|
||||||
getRequest.realtime(restRequest.paramAsBooleanOptional("realtime", null));
|
getRequest.realtime(restRequest.paramAsBoolean("realtime", null));
|
||||||
getRequest.version(RestActions.parseVersion(restRequest));
|
getRequest.version(RestActions.parseVersion(restRequest));
|
||||||
getRequest.versionType(VersionType.fromString(restRequest.param("version_type"), getRequest.versionType()));
|
getRequest.versionType(VersionType.fromString(restRequest.param("version_type"), getRequest.versionType()));
|
||||||
|
|
||||||
|
|
|
@ -156,7 +156,7 @@ public class RestSearchAction extends BaseRestHandler {
|
||||||
queryBuilder.analyzer(request.param("analyzer"));
|
queryBuilder.analyzer(request.param("analyzer"));
|
||||||
queryBuilder.analyzeWildcard(request.paramAsBoolean("analyze_wildcard", false));
|
queryBuilder.analyzeWildcard(request.paramAsBoolean("analyze_wildcard", false));
|
||||||
queryBuilder.lowercaseExpandedTerms(request.paramAsBoolean("lowercase_expanded_terms", true));
|
queryBuilder.lowercaseExpandedTerms(request.paramAsBoolean("lowercase_expanded_terms", true));
|
||||||
queryBuilder.lenient(request.paramAsBooleanOptional("lenient", null));
|
queryBuilder.lenient(request.paramAsBoolean("lenient", null));
|
||||||
String defaultOperator = request.param("default_operator");
|
String defaultOperator = request.param("default_operator");
|
||||||
if (defaultOperator != null) {
|
if (defaultOperator != null) {
|
||||||
if ("OR".equals(defaultOperator)) {
|
if ("OR".equals(defaultOperator)) {
|
||||||
|
@ -192,13 +192,13 @@ public class RestSearchAction extends BaseRestHandler {
|
||||||
if (searchSourceBuilder == null) {
|
if (searchSourceBuilder == null) {
|
||||||
searchSourceBuilder = new SearchSourceBuilder();
|
searchSourceBuilder = new SearchSourceBuilder();
|
||||||
}
|
}
|
||||||
searchSourceBuilder.explain(request.paramAsBooleanOptional("explain", null));
|
searchSourceBuilder.explain(request.paramAsBoolean("explain", null));
|
||||||
}
|
}
|
||||||
if (request.hasParam("version")) {
|
if (request.hasParam("version")) {
|
||||||
if (searchSourceBuilder == null) {
|
if (searchSourceBuilder == null) {
|
||||||
searchSourceBuilder = new SearchSourceBuilder();
|
searchSourceBuilder = new SearchSourceBuilder();
|
||||||
}
|
}
|
||||||
searchSourceBuilder.version(request.paramAsBooleanOptional("version", null));
|
searchSourceBuilder.version(request.paramAsBoolean("version", null));
|
||||||
}
|
}
|
||||||
if (request.hasParam("timeout")) {
|
if (request.hasParam("timeout")) {
|
||||||
if (searchSourceBuilder == null) {
|
if (searchSourceBuilder == null) {
|
||||||
|
|
Loading…
Reference in New Issue