Apache Lucene open-source search software
SOLR-1255 An attempt to visit the replication admin page when its not a defined handler should display an approp message
Noble Paul6457b52936f6
diff --git a/src/java/org/apache/solr/core/RequestHandlers.java b/src/java/org/apache/solr/core/RequestHandlers.javaindex 3a4ad9a3de0..7cb70f602af 100644--- a/src/java/org/apache/solr/core/RequestHandlers.java+++ b/src/java/org/apache/solr/core/RequestHandlers.java@@ -66,7 +66,7 @@ final class RequestHandlers {public RequestHandlers(SolrCore core) {this.core = core;}-+/*** @return the RequestHandler registered at the given name*/@@ -74,6 +74,13 @@ final class RequestHandlers {return handlers.get(normalize(handlerName));}+ public SolrRequestHandler get(Class clazz) {+ for (SolrRequestHandler requestHandler : handlers.values()) {+ if(requestHandler.getClass() == clazz) return requestHandler;+ }+ return null;+ }+/*** Handlers must be initialized before calling this function. As soon as this is* called, the handler can immediately accept requests.diff --git a/src/java/org/apache/solr/core/SolrCore.java b/src/java/org/apache/solr/core/SolrCore.javaindex b9e3e0e4d92..9cbd0bb3987 100644--- a/src/java/org/apache/solr/core/SolrCore.java+++ b/src/java/org/apache/solr/core/SolrCore.java@@ -767,6 +767,10 @@ public final class SolrCore implements SolrInfoMBean {public SolrRequestHandler getRequestHandler(String handlerName) {return reqHandlers.get(handlerName);}++ public SolrRequestHandler getRequestHandler(Class clazz) {+ return reqHandlers.get(clazz);+ }/*** Returns an unmodifieable Map containing the registered handlersdiff --git a/src/webapp/web/admin/index.jsp b/src/webapp/web/admin/index.jspindex c9f0473ae0b..b8fec41e2af 100644--- a/src/webapp/web/admin/index.jsp+++ b/src/webapp/web/admin/index.jsp@@ -24,11 +24,12 @@<%@ page import="java.util.List" %><%@ page import="java.util.Collection" %><%@ page import="org.apache.solr.request.SolrRequestHandler"%>+<%@ page import="org.apache.solr.handler.ReplicationHandler" %><%-- jsp:include page="header.jsp"/ --%><%-- do a verbatim include so we can use the local vars --%><%@include file="header.jsp" %>-<%SolrRequestHandler replicationhandler = core.getRequestHandler("/replication");%>+<%SolrRequestHandler replicationhandler = core.getRequestHandler(ReplicationHandler.class);%><br clear="all"><table>diff --git a/src/webapp/web/admin/replication/header.jsp b/src/webapp/web/admin/replication/header.jspindex 58689c1a5ad..d4eb6564d4a 100644--- a/src/webapp/web/admin/replication/header.jsp+++ b/src/webapp/web/admin/replication/header.jsp@@ -21,14 +21,14 @@org.apache.solr.request.LocalSolrQueryRequest,org.apache.solr.request.SolrQueryResponse,org.apache.solr.request.SolrRequestHandler"%>--<html>-<head>-+<%@ page import="org.apache.solr.handler.ReplicationHandler" %><%request.setCharacterEncoding("UTF-8");%>+<html>+<head>+<%@include file="../_info.jsp" %><script>@@ -55,7 +55,11 @@ public NamedList executeCommand(String command, SolrCore core, SolrRequestHandle%><%-final SolrRequestHandler rh = core.getRequestHandler("/replication");+final SolrRequestHandler rh = core.getRequestHandler(ReplicationHandler.class);+ if(rh == null){+ response.sendError( 404, "No ReplicationHandler registered" );+ return;+ }NamedList namedlist = executeCommand("details",core,rh);NamedList detailsMap = (NamedList)namedlist.get("details");if(detailsMap != null)