Apache Solr open-source search software
SOLR-3679: admin ui shows error message if creating a new core fails
Stefan Matheisa778718872bc
diff --git a/solr/CHANGES.txt b/solr/CHANGES.txtindex 26f49d37225..33e3a17188a 100644--- a/solr/CHANGES.txt+++ b/solr/CHANGES.txt@@ -129,6 +129,7 @@ Bug Fixeslater when a filter of the same term was specified.(Günter Hipler, hossman, yonik)+* SOLR-3679: Core Admin UI gives no feedback if "Add Core" fails (steffkes, hossman)Other Changes----------------------diff --git a/solr/core/src/java/org/apache/solr/handler/admin/CoreAdminHandler.java b/solr/core/src/java/org/apache/solr/handler/admin/CoreAdminHandler.javaindex e85997b5444..1c299a1e301 100644--- a/solr/core/src/java/org/apache/solr/handler/admin/CoreAdminHandler.java+++ b/solr/core/src/java/org/apache/solr/handler/admin/CoreAdminHandler.java@@ -442,9 +442,13 @@ public class CoreAdminHandler extends RequestHandlerBase {* @throws SolrException in case of a configuration error.*/protected boolean handleCreateAction(SolrQueryRequest req, SolrQueryResponse rsp) throws SolrException {+ SolrParams params = req.getParams();+ String name = params.get(CoreAdminParams.NAME);+ if (null == name || "".equals(name)) {+ throw new SolrException(SolrException.ErrorCode.BAD_REQUEST,+ "Core name is mandatory to CREATE a SolrCore");+ }try {- SolrParams params = req.getParams();- String name = params.get(CoreAdminParams.NAME);//for now, do not allow creating new core with same name when in cloud mode//XXX perhaps it should just be unregistered from cloud before readding it?,@@ -518,7 +522,8 @@ public class CoreAdminHandler extends RequestHandlerBase {return coreContainer.isPersistent();} catch (Exception ex) {throw new SolrException(SolrException.ErrorCode.BAD_REQUEST,- "Error executing default implementation of CREATE", ex);+ "Error CREATEing SolrCore '" + name + "': " ++ ex.getMessage(), ex);}}diff --git a/solr/webapp/web/css/styles/cores.css b/solr/webapp/web/css/styles/cores.cssindex c60f25d0e38..2481105f83d 100644--- a/solr/webapp/web/css/styles/cores.css+++ b/solr/webapp/web/css/styles/cores.css@@ -46,6 +46,12 @@display: none;}+#content #cores .actions form .error+{+ color: #800;+ display: none;+}+#content #cores .actions form p{padding-bottom: 8px;@@ -62,7 +68,8 @@#content #cores .actions form input,#content #cores .actions form select,-#content #cores .actions form .buttons+#content #cores .actions form .buttons,+#content #cores .actions form .error span{float: right;width: 73%;diff --git a/solr/webapp/web/js/scripts/cores.js b/solr/webapp/web/js/scripts/cores.jsindex 05f21b1f71b..cf5cf1c5d96 100644--- a/solr/webapp/web/js/scripts/cores.js+++ b/solr/webapp/web/js/scripts/cores.js@@ -365,6 +365,12 @@ sammy.get},error : function( xhr, text_status, error_thrown ){+ var response = null;+ eval( 'response = ' + xhr.responseText + ';' );++ var error_elem = $( '.error', div_action.filter( ':visible' ) );+ error_elem.show();+ $( 'span', error_elem ).text( response.error.msg );},complete : function(){diff --git a/solr/webapp/web/tpl/cores.html b/solr/webapp/web/tpl/cores.htmlindex cf6e1f3472a..fba06b60d0e 100644--- a/solr/webapp/web/tpl/cores.html+++ b/solr/webapp/web/tpl/cores.html@@ -36,19 +36,19 @@ limitations under the License.<input type="hidden" name="action" value="CREATE"><p class="clearfix"><label for="add_name">name:</label>- <input type="text" name="name" id="add_name" placeholder="new_core"></p>+ <input type="text" name="name" id="add_name" value="new_core"></p><p class="clearfix"><label for="add_instanceDir">instanceDir:</label>- <input type="text" name="instanceDir" id="add_instanceDir" placeholder="new_core"></p>+ <input type="text" name="instanceDir" id="add_instanceDir" value="new_core"></p><p class="clearfix"><label for="add_dataDir">dataDir:</label>- <input type="text" name="dataDir" id="dataDir" placeholder="data"></p>+ <input type="text" name="dataDir" id="dataDir" value="data"></p><p class="clearfix"><label for="add_config">config:</label>- <input type="text" name="config" id="add_config" placeholder="solrconfig.xml"></p>+ <input type="text" name="config" id="add_config" value="solrconfig.xml"></p><p class="clearfix"><label for="add_schema">schema:</label>- <input type="text" name="schema" id="add_schema" placeholder="schema.xml"></p>+ <input type="text" name="schema" id="add_schema" value="schema.xml"></p><div class="cloud">@@ -60,6 +60,12 @@ limitations under the License.</div>+ <p class="clearfix error">++ <span></span>++ </p>+<p class="clearfix buttons"><button type="submit" class="submit"><span>Add Core</span></button><button type="reset" class="reset"><span>Cancel</span></button>