noblepaul commented on a change in pull request #1432: URL: https://github.com/apache/lucene-solr/pull/1432#discussion_r412148113
########## File path: solr/core/src/java/org/apache/solr/handler/admin/ContainerPluginsApi.java ########## @@ -0,0 +1,178 @@ +/* + * 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.admin; + +import java.io.IOException; +import java.lang.invoke.MethodHandles; +import java.util.ArrayList; +import java.util.LinkedHashMap; +import java.util.List; +import java.util.Map; +import java.util.function.Function; +import java.util.function.Supplier; + +import org.apache.solr.api.AnnotatedApi; +import org.apache.solr.api.Command; +import org.apache.solr.api.CustomContainerPlugins; +import org.apache.solr.api.EndPoint; +import org.apache.solr.api.PayloadObj; +import org.apache.solr.client.solrj.SolrRequest.METHOD; +import org.apache.solr.client.solrj.request.beans.PluginMeta; +import org.apache.solr.common.cloud.SolrZkClient; +import org.apache.solr.common.cloud.ZkStateReader; +import org.apache.solr.common.util.Utils; +import org.apache.solr.core.CoreContainer; +import org.apache.solr.request.SolrQueryRequest; +import org.apache.solr.response.SolrQueryResponse; +import org.apache.solr.security.PermissionNameProvider; +import org.apache.zookeeper.KeeperException; +import org.apache.zookeeper.data.Stat; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + +import static org.apache.lucene.util.IOUtils.closeWhileHandlingException; + + +public class ContainerPluginsApi { + private static final Logger log = LoggerFactory.getLogger(MethodHandles.lookup().lookupClass()); + + public static final String PLUGIN = "plugin"; + private final Supplier<SolrZkClient> zkClientSupplier; + private final CoreContainer coreContainer; + public final Read readAPI = new Read(); + public final Edit editAPI = new Edit(); + + public ContainerPluginsApi(CoreContainer coreContainer) { + this.zkClientSupplier = coreContainer.zkClientSupplier; + this.coreContainer = coreContainer; + } + + @EndPoint(method = METHOD.GET, + path = "/cluster/plugin", + permission = PermissionNameProvider.Name.COLL_READ_PERM) + public class Read { + + @Command + public void list(SolrQueryRequest req, SolrQueryResponse rsp) throws IOException { + rsp.add(PLUGIN, plugins(zkClientSupplier)); + } + } + + @EndPoint(method = METHOD.POST, + path = "/cluster/plugin", + permission = PermissionNameProvider.Name.COLL_EDIT_PERM) + public class Edit { + + @Command(name = "add") + public void add(SolrQueryRequest req, SolrQueryResponse rsp, PayloadObj<PluginMeta> payload) throws IOException { + PluginMeta info = payload.get(); + validateConfig(payload, info); + if(payload.hasError()) return; + persistPlugins(map -> { + if (map.containsKey(info.name)) { + payload.addError(info.name + " already exists"); + return null; + } + map.put(info.name, info); + return map; + }); + } + + @Command(name = "remove") + public void remove(SolrQueryRequest req, SolrQueryResponse rsp, PayloadObj<String> payload) throws IOException { Review comment: We could, but , this is the convention that we follow ---------------------------------------------------------------- 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