gerlowskija commented on code in PR #955:
URL: https://github.com/apache/solr/pull/955#discussion_r935971223


##########
solr/core/src/java/org/apache/solr/handler/configsets/UploadConfigSetAPI.java:
##########
@@ -0,0 +1,136 @@
+/*
+ * 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.configsets;
+
+
+import org.apache.commons.io.IOUtils;
+import org.apache.solr.api.EndPoint;
+import org.apache.solr.common.SolrException;
+import org.apache.solr.common.params.ConfigSetParams;
+import org.apache.solr.core.ConfigSetService;
+import org.apache.solr.core.CoreContainer;
+import org.apache.solr.request.SolrQueryRequest;
+import org.apache.solr.response.SolrQueryResponse;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+import java.io.IOException;
+import java.io.InputStream;
+import java.lang.invoke.MethodHandles;
+import java.nio.charset.StandardCharsets;
+import java.util.Collections;
+import java.util.List;
+import java.util.Map;
+import java.util.zip.ZipEntry;
+import java.util.zip.ZipInputStream;
+
+import static org.apache.solr.client.solrj.SolrRequest.METHOD.PUT;
+import static 
org.apache.solr.security.PermissionNameProvider.Name.CONFIG_EDIT_PERM;
+
+/**
+ * V2 API for uploading a new configset (or overwriting an existing one).
+ *
+ * <p>This API (PUT /v2/cluster/configs/configsetName) is analogous to the v1
+ * /admin/configs?action=UPLOAD command.
+ *
+ */
+public class UploadConfigSetAPI extends ConfigSetAPIBase {
+
+    public static final String CONFIGSET_NAME_PLACEHOLDER = "name";
+
+
+    private static final Logger log = 
LoggerFactory.getLogger(MethodHandles.lookup().lookupClass());
+
+    public UploadConfigSetAPI(CoreContainer coreContainer) {
+        super(coreContainer);
+    }
+
+    @EndPoint(method = PUT, path = "/cluster/configs/{name}", permission = 
CONFIG_EDIT_PERM)
+    public void uploadConfigSet(SolrQueryRequest req, SolrQueryResponse rsp) 
throws Exception {
+        ensureConfigSetUploadEnabled();
+
+        final String configSetName = req.getPathTemplateValues().get("name");
+        boolean overwritesExisting = 
configSetService.checkConfigExists(configSetName);
+        boolean requestIsTrusted = isTrusted(req.getUserPrincipal(), 
coreContainer.getAuthenticationPlugin());
+        // Get upload parameters
+        boolean allowOverwrite = 
req.getParams().getBool(ConfigSetParams.OVERWRITE, true);
+        boolean cleanup = req.getParams().getBool(ConfigSetParams.CLEANUP, 
false);
+        final InputStream inputStream = ensureNonEmptyInputStream(req);
+
+        if (overwritesExisting && !allowOverwrite) {
+            throw new SolrException(
+                    SolrException.ErrorCode.BAD_REQUEST,
+                    "The configuration " + configSetName + " already exists in 
zookeeper");

Review Comment:
   👍  - I think that string-literal came from ConfigsetHandler, but I'll amend 
it since it's a quick fix.



-- 
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.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to