diff --git a/server/src/main/java/org/elasticsearch/action/support/IndicesOptions.java b/server/src/main/java/org/elasticsearch/action/support/IndicesOptions.java index 2352fadab79..676112c2eb8 100644 --- a/server/src/main/java/org/elasticsearch/action/support/IndicesOptions.java +++ b/server/src/main/java/org/elasticsearch/action/support/IndicesOptions.java @@ -19,15 +19,18 @@ package org.elasticsearch.action.support; import org.elasticsearch.Version; +import org.elasticsearch.ElasticsearchParseException; +import org.elasticsearch.common.ParseField; import org.elasticsearch.common.io.stream.StreamInput; import org.elasticsearch.common.io.stream.StreamOutput; import org.elasticsearch.common.xcontent.ToXContent; import org.elasticsearch.common.xcontent.ToXContentFragment; import org.elasticsearch.common.xcontent.XContentBuilder; +import org.elasticsearch.common.xcontent.XContentParser; +import org.elasticsearch.common.xcontent.XContentParser.Token; import org.elasticsearch.rest.RestRequest; import java.io.IOException; -import java.util.Collection; import java.util.EnumSet; import java.util.Locale; import java.util.Map; @@ -59,25 +62,7 @@ public class IndicesOptions implements ToXContentFragment { // TODO why do we let patterns like "none,all" or "open,none,closed" get used. The location of 'none' in the array changes the // meaning of the resulting value for (String wildcard : wildcards) { - switch (wildcard) { - case "open": - states.add(OPEN); - break; - case "closed": - states.add(CLOSED); - break; - case "hidden": - states.add(HIDDEN); - break; - case "none": - states.clear(); - break; - case "all": - states = EnumSet.allOf(WildcardStates.class); - break; - default: - throw new IllegalArgumentException("No valid expand wildcard value [" + wildcard + "]"); - } + updateSetForValue(states, wildcard); } return states; @@ -94,6 +79,28 @@ public class IndicesOptions implements ToXContentFragment { } return builder; } + + private static void updateSetForValue(EnumSet states, String wildcard) { + switch (wildcard) { + case "open": + states.add(OPEN); + break; + case "closed": + states.add(CLOSED); + break; + case "hidden": + states.add(HIDDEN); + break; + case "none": + states.clear(); + break; + case "all": + states.addAll(EnumSet.allOf(WildcardStates.class)); + break; + default: + throw new IllegalArgumentException("No valid expand wildcard value [" + wildcard + "]"); + } + } } public enum Option { @@ -148,11 +155,6 @@ public class IndicesOptions implements ToXContentFragment { this.expandWildcards = expandWildcards; } - private IndicesOptions(Collection