noblepaul commented on a change in pull request #1015: SOLR-13936 : expose endpoint to support changing schema without collection URL: https://github.com/apache/lucene-solr/pull/1015#discussion_r348220622
########## File path: solr/core/src/java/org/apache/solr/handler/ConfigSetSchemaHandler.java ########## @@ -0,0 +1,125 @@ +/* + * 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.handler; + +import javax.xml.parsers.ParserConfigurationException; +import java.io.IOException; +import java.lang.invoke.MethodHandles; +import java.util.Iterator; +import java.util.List; +import java.util.Map; + +import org.apache.solr.api.ApiBag; +import org.apache.solr.api.Command; +import org.apache.solr.api.EndPoint; +import org.apache.solr.client.solrj.SolrRequest; +import org.apache.solr.common.SolrException; +import org.apache.solr.common.cloud.ZkConfigManager; +import org.apache.solr.core.CoreContainer; +import org.apache.solr.core.SolrConfig; +import org.apache.solr.request.SolrQueryRequest; +import org.apache.solr.response.SolrQueryResponse; +import org.apache.solr.schema.ManagedIndexSchema; +import org.apache.solr.schema.SchemaManager; +import org.apache.solr.security.PermissionNameProvider; +import org.apache.solr.util.ConfigSetResourceUtil; +import org.apache.zookeeper.data.Stat; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; +import org.xml.sax.InputSource; +import org.xml.sax.SAXException; + +public class ConfigSetSchemaHandler { + private static final Logger log = LoggerFactory.getLogger(MethodHandles.lookup().lookupClass()); + private final CoreContainer coreContainer; + private static final String SCHEMA_NAME = "managed-schema"; + private static final String CONFIG_PREFIX = ZkConfigManager.CONFIGS_ZKNODE + "/"; + private static final String PATH_PREFIX = "/cluster/configset/"; + private static final String PATH_POSTFIX_SCHEMA = "/schema"; + + public ConfigSetSchemaHandler(CoreContainer coreContainer) { + this.coreContainer = coreContainer; + } + + public final Write write = new Write(); + public final Read read = new Read(); + + @EndPoint(method = SolrRequest.METHOD.GET, + path = {PATH_PREFIX, PATH_PREFIX + "{name}" + PATH_POSTFIX_SCHEMA}, + permission = PermissionNameProvider.Name.SCHEMA_READ_PERM) + public class Read { + @Command() + public void get(SolrQueryRequest req, SolrQueryResponse rsp) throws Exception { + String configSetName = req.getPathTemplateValues().get("name"); + //@todo apv remove query param ? + //@todo apv check get version call + String schemaPath = req.getParams().get("query"); + //populating ManagedSchema + SolrConfig config = getSolrConfig(configSetName); + ManagedIndexSchema schema = getManagedSchema(configSetName, config); + //running operations + Map<String, Object> params = new SchemaManager().executeGET(schemaPath, schema, req.getParams(), coreContainer.getResourceLoader()); + Iterator<String> iterator = params.keySet().iterator(); + while (iterator.hasNext()) { + String key = iterator.next(); + rsp.add(key, params.get(key)); + } + } + } + + @EndPoint(method = SolrRequest.METHOD.POST, + path = PATH_PREFIX + "{name}" + PATH_POSTFIX_SCHEMA, Review comment: There is one more endpoint you need to build `/cluster/configset/{name}/config/overlay` ---------------------------------------------------------------- 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 With regards, Apache Git Services --------------------------------------------------------------------- To unsubscribe, e-mail: issues-unsubscr...@lucene.apache.org For additional commands, e-mail: issues-h...@lucene.apache.org