madrob commented on a change in pull request #1963: URL: https://github.com/apache/lucene-solr/pull/1963#discussion_r502660921
########## File path: solr/core/src/java/org/apache/solr/util/DOMUtil.java ########## @@ -39,9 +42,23 @@ public static final String XML_RESERVED_PREFIX = "xml"; + static final Set<String> NL_TAGS = ImmutableSet.of("str", "int","long","float","double","bool"); Review comment: can we use Set.of instead of ImmutableSet ########## File path: solr/solrj/src/java/org/apache/solr/common/ConfigNode.java ########## @@ -0,0 +1,90 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.apache.solr.common; + +import java.util.ArrayList; +import java.util.Collections; +import java.util.List; +import java.util.Set; +import java.util.function.Function; +import java.util.function.Predicate; + +import org.apache.solr.cluster.api.SimpleMap; + +/** + * A generic interface that represents a config file, mostly XML + */ +public interface ConfigNode { + ThreadLocal<Function<String,String>> SUBSTITUTES = new ThreadLocal<>(); Review comment: this probably needs to be static. ########## File path: solr/core/src/java/org/apache/solr/schema/IndexSchema.java ########## @@ -537,26 +554,30 @@ protected void readSchema(InputSource is) { } // /schema/defaultSearchField/text() - expression = stepsToPath(SCHEMA, "defaultSearchField", TEXT_FUNCTION); - node = (Node) xpath.evaluate(expression, document, XPathConstants.NODE); +// expression = stepsToPath(SCHEMA, "defaultSearchField", TEXT_FUNCTION); +// node = (Node) xpath.evaluate(expression, document, XPathConstants.NODE); + ConfigNode node = rootNode.child("defaultSearchField"); if (node != null) { throw new SolrException(ErrorCode.SERVER_ERROR, "Setting defaultSearchField in schema not supported since Solr 7"); } + node = rootNode.child("solrQueryParser"); Review comment: missing `@defaultOperator`? ########## File path: solr/solrj/src/java/org/apache/solr/common/ConfigNode.java ########## @@ -0,0 +1,90 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.apache.solr.common; + +import java.util.ArrayList; +import java.util.Collections; +import java.util.List; +import java.util.Set; +import java.util.function.Function; +import java.util.function.Predicate; + +import org.apache.solr.cluster.api.SimpleMap; + +/** + * A generic interface that represents a config file, mostly XML + */ +public interface ConfigNode { + ThreadLocal<Function<String,String>> SUBSTITUTES = new ThreadLocal<>(); + + /** + * Name of the tag + */ + String name(); + + /** + * Text value of the node + */ + String textValue(); + + /** + * Attributes + */ + SimpleMap<String> attributes(); + + /** + * Child by name + */ + default ConfigNode child(String name) { + return child(null, name); + } + + default ConfigNode child(Predicate<ConfigNode> test, String name) { + ConfigNode[] result = new ConfigNode[1]; + forEachChild(it -> { + if (name!=null && !name.equals(it.name())) return Boolean.TRUE; + if (test == null || test.test(it)) { + result[0] = it; + return Boolean.FALSE; + } + return Boolean.TRUE; + }); + return result[0]; + } + + default List<ConfigNode> children(Predicate<ConfigNode> test, String... nodeNames) { + return children(test, nodeNames == null ? Collections.emptySet() : Set.of(nodeNames)); + } + + default List<ConfigNode> children(Predicate<ConfigNode> test, Set<String> set) { + List<ConfigNode> result = new ArrayList<>(); + forEachChild(it -> { + if (set != null && !set.isEmpty() && !set.contains(it.name())) return Boolean.TRUE; + if (test == null || test.test(it)) result.add(it); + return Boolean.TRUE; + }); + return result; + } + + default List<ConfigNode> children(String name) { + return children(null, Collections.singleton(name)); + } + + void forEachChild(Function<ConfigNode, Boolean> fun); Review comment: I don't understand what the return value of the function is supposed to represent ########## File path: solr/solrj/src/java/org/apache/solr/common/ConfigNode.java ########## @@ -0,0 +1,90 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.apache.solr.common; + +import java.util.ArrayList; +import java.util.Collections; +import java.util.List; +import java.util.Set; +import java.util.function.Function; +import java.util.function.Predicate; + +import org.apache.solr.cluster.api.SimpleMap; + +/** + * A generic interface that represents a config file, mostly XML + */ +public interface ConfigNode { + ThreadLocal<Function<String,String>> SUBSTITUTES = new ThreadLocal<>(); + + /** + * Name of the tag + */ + String name(); + + /** + * Text value of the node + */ + String textValue(); + + /** + * Attributes + */ + SimpleMap<String> attributes(); + + /** + * Child by name + */ + default ConfigNode child(String name) { + return child(null, name); + } + + default ConfigNode child(Predicate<ConfigNode> test, String name) { Review comment: Please add javadoc for what these methods do ---------------------------------------------------------------- This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. For queries about this service, please contact Infrastructure at: us...@infra.apache.org --------------------------------------------------------------------- To unsubscribe, e-mail: issues-unsubscr...@lucene.apache.org For additional commands, e-mail: issues-h...@lucene.apache.org