mirror of https://github.com/apache/lucene.git
SOLR-1930: remove solr servlet
git-svn-id: https://svn.apache.org/repos/asf/lucene/dev/trunk@1054016 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
parent
d55a467fbd
commit
e855000828
|
@ -1,130 +0,0 @@
|
||||||
/**
|
|
||||||
* 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.servlet;
|
|
||||||
|
|
||||||
import java.io.File;
|
|
||||||
import java.io.IOException;
|
|
||||||
import java.io.PrintWriter;
|
|
||||||
|
|
||||||
import org.apache.solr.common.params.CommonParams;
|
|
||||||
import org.apache.solr.request.SolrRequestInfo;
|
|
||||||
import org.slf4j.Logger;
|
|
||||||
import org.slf4j.LoggerFactory;
|
|
||||||
|
|
||||||
import javax.servlet.ServletException;
|
|
||||||
import javax.servlet.http.HttpServlet;
|
|
||||||
import javax.servlet.http.HttpServletRequest;
|
|
||||||
import javax.servlet.http.HttpServletResponse;
|
|
||||||
|
|
||||||
import org.apache.solr.common.SolrException;
|
|
||||||
import org.apache.solr.core.SolrCore;
|
|
||||||
import org.apache.solr.core.SolrResourceLoader;
|
|
||||||
import org.apache.solr.request.SolrRequestHandler;
|
|
||||||
import org.apache.solr.response.QueryResponseWriter;
|
|
||||||
import org.apache.solr.response.SolrQueryResponse;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @deprecated Register a standard request handler instead of using this
|
|
||||||
* servlet. Add <requestHandler name="standard"
|
|
||||||
* class="solr.StandardRequestHandler" default="true"> to
|
|
||||||
* solrconfig.xml.
|
|
||||||
*/
|
|
||||||
|
|
||||||
@Deprecated
|
|
||||||
public class SolrServlet extends HttpServlet {
|
|
||||||
|
|
||||||
final Logger log = LoggerFactory.getLogger(SolrServlet.class);
|
|
||||||
private boolean hasMulticore = false;
|
|
||||||
|
|
||||||
public void init() throws ServletException {
|
|
||||||
log.info("SolrServlet.init()");
|
|
||||||
|
|
||||||
// Check if the "solr.xml" file exists -- if so, this is an invalid servlet
|
|
||||||
// (even if there is only one core...)
|
|
||||||
String instanceDir = SolrResourceLoader.locateInstanceDir();
|
|
||||||
File fconf = new File(instanceDir, "solr.xml");
|
|
||||||
hasMulticore = fconf.exists();
|
|
||||||
|
|
||||||
// we deliberately do not initialize a SolrCore because of SOLR-597
|
|
||||||
// https://issues.apache.org/jira/browse/SOLR-597
|
|
||||||
log.info("SolrServlet.init() done");
|
|
||||||
}
|
|
||||||
|
|
||||||
public void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
|
|
||||||
doGet(request,response);
|
|
||||||
}
|
|
||||||
|
|
||||||
public void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
|
|
||||||
if( hasMulticore ) {
|
|
||||||
response.sendError( 400, "Missing solr core name in path" );
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
final SolrCore core = SolrCore.getSolrCore();
|
|
||||||
SolrServletRequest solrReq = new SolrServletRequest(core, request);;
|
|
||||||
SolrQueryResponse solrRsp = new SolrQueryResponse();
|
|
||||||
try {
|
|
||||||
String qt = solrReq.getParams().get(CommonParams.QT);
|
|
||||||
SolrRequestHandler handler = core.getRequestHandler(solrReq.getParams().get(CommonParams.QT));
|
|
||||||
if (handler==null) {
|
|
||||||
log.warn("Unknown Request Handler '" + qt +"' :" + solrReq);
|
|
||||||
throw new SolrException(SolrException.ErrorCode.BAD_REQUEST,"Unknown Request Handler '" + qt + "'", true);
|
|
||||||
}
|
|
||||||
SolrRequestInfo.setRequestInfo(new SolrRequestInfo(solrReq, solrRsp));
|
|
||||||
core.execute(handler, solrReq, solrRsp );
|
|
||||||
if (solrRsp.getException() == null) {
|
|
||||||
QueryResponseWriter responseWriter = core.getQueryResponseWriter(solrReq);
|
|
||||||
response.setContentType(responseWriter.getContentType(solrReq, solrRsp));
|
|
||||||
PrintWriter out = response.getWriter();
|
|
||||||
responseWriter.write(out, solrReq, solrRsp);
|
|
||||||
} else {
|
|
||||||
Exception e = solrRsp.getException();
|
|
||||||
int rc=500;
|
|
||||||
if (e instanceof SolrException) {
|
|
||||||
rc=((SolrException)e).code();
|
|
||||||
}
|
|
||||||
sendErr(rc, SolrException.toStr(e), request, response);
|
|
||||||
}
|
|
||||||
} catch (SolrException e) {
|
|
||||||
if (!e.logged) SolrException.log(log,e);
|
|
||||||
sendErr(e.code(), SolrException.toStr(e), request, response);
|
|
||||||
} catch (Throwable e) {
|
|
||||||
SolrException.log(log,e);
|
|
||||||
sendErr(500, SolrException.toStr(e), request, response);
|
|
||||||
} finally {
|
|
||||||
// This releases the IndexReader associated with the request
|
|
||||||
solrReq.close();
|
|
||||||
SolrRequestInfo.clearRequestInfo();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
final void sendErr(int rc, String msg, HttpServletRequest request, HttpServletResponse response) {
|
|
||||||
try {
|
|
||||||
// hmmm, what if this was already set to text/xml?
|
|
||||||
try{
|
|
||||||
response.setContentType(QueryResponseWriter.CONTENT_TYPE_TEXT_UTF8);
|
|
||||||
// response.setCharacterEncoding("UTF-8");
|
|
||||||
} catch (Exception e) {}
|
|
||||||
try{response.setStatus(rc);} catch (Exception e) {}
|
|
||||||
PrintWriter writer = response.getWriter();
|
|
||||||
writer.write(msg);
|
|
||||||
} catch (IOException e) {
|
|
||||||
SolrException.log(log,e);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -1,33 +0,0 @@
|
||||||
/**
|
|
||||||
* 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.servlet;
|
|
||||||
|
|
||||||
import org.apache.solr.request.SolrQueryRequestBase;
|
|
||||||
import org.apache.solr.request.ServletSolrParams;
|
|
||||||
import org.apache.solr.core.SolrCore;
|
|
||||||
|
|
||||||
import javax.servlet.http.HttpServletRequest;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @version $Id$
|
|
||||||
*/
|
|
||||||
class SolrServletRequest extends SolrQueryRequestBase {
|
|
||||||
public SolrServletRequest(SolrCore core, HttpServletRequest req) {
|
|
||||||
super(core, new ServletSolrParams(req));
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -1,81 +0,0 @@
|
||||||
package org.apache.solr.servlet;/**
|
|
||||||
* 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.
|
|
||||||
*/
|
|
||||||
|
|
||||||
import java.io.BufferedReader;
|
|
||||||
import java.io.File;
|
|
||||||
import java.io.IOException;
|
|
||||||
import java.io.PrintWriter;
|
|
||||||
import org.slf4j.Logger;
|
|
||||||
import org.slf4j.LoggerFactory;
|
|
||||||
|
|
||||||
import javax.servlet.ServletException;
|
|
||||||
import javax.servlet.http.HttpServlet;
|
|
||||||
import javax.servlet.http.HttpServletRequest;
|
|
||||||
import javax.servlet.http.HttpServletResponse;
|
|
||||||
|
|
||||||
import org.apache.solr.core.SolrResourceLoader;
|
|
||||||
import org.apache.solr.handler.XmlUpdateRequestHandler;
|
|
||||||
import org.apache.solr.response.QueryResponseWriter;
|
|
||||||
import org.apache.solr.response.XMLResponseWriter;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @version $Id$
|
|
||||||
*
|
|
||||||
* @deprecated Register a request handler to /update rather then use this servlet. Add: <requestHandler name="/update" class="solr.XmlUpdateRequestHandler" > to your solrconfig.xml
|
|
||||||
*/
|
|
||||||
@Deprecated
|
|
||||||
public class SolrUpdateServlet extends HttpServlet {
|
|
||||||
final Logger log = LoggerFactory.getLogger(SolrUpdateServlet.class);
|
|
||||||
|
|
||||||
XmlUpdateRequestHandler legacyUpdateHandler;
|
|
||||||
XMLResponseWriter xmlResponseWriter;
|
|
||||||
private boolean hasMulticore = false;
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void init() throws ServletException
|
|
||||||
{
|
|
||||||
legacyUpdateHandler = new XmlUpdateRequestHandler();
|
|
||||||
legacyUpdateHandler.init( null );
|
|
||||||
|
|
||||||
// Check if the "solr.xml" file exists -- if so, this is an invalid servlet
|
|
||||||
// (even if there is only one core...)
|
|
||||||
String instanceDir = SolrResourceLoader.locateInstanceDir();
|
|
||||||
File fconf = new File(instanceDir, "solr.xml");
|
|
||||||
hasMulticore = fconf.exists();
|
|
||||||
|
|
||||||
log.info("SolrUpdateServlet.init() done");
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
|
|
||||||
if( hasMulticore ) {
|
|
||||||
response.sendError( 400, "Missing solr core name in path" );
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
BufferedReader requestReader = request.getReader();
|
|
||||||
response.setContentType(QueryResponseWriter.CONTENT_TYPE_XML_UTF8);
|
|
||||||
|
|
||||||
if( request.getQueryString() != null ) {
|
|
||||||
log.warn(
|
|
||||||
"The @Deprecated SolrUpdateServlet does not accept query parameters: "+request.getQueryString()+"\n"
|
|
||||||
+" If you are using solrj, make sure to register a request handler to /update rather then use this servlet.\n"
|
|
||||||
+" Add: <requestHandler name=\"/update\" class=\"solr.XmlUpdateRequestHandler\" > to your solrconfig.xml\n\n" );
|
|
||||||
}
|
|
||||||
PrintWriter writer = response.getWriter();
|
|
||||||
legacyUpdateHandler.doLegacyUpdate(requestReader, writer);
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -83,62 +83,16 @@
|
||||||
<url-pattern>/*</url-pattern>
|
<url-pattern>/*</url-pattern>
|
||||||
</filter-mapping>
|
</filter-mapping>
|
||||||
|
|
||||||
<!-- Otherwise it will continue to the old servlets -->
|
|
||||||
|
|
||||||
<servlet>
|
|
||||||
<servlet-name>SolrServer</servlet-name>
|
|
||||||
<display-name>Solr</display-name>
|
|
||||||
<description>Solr Server</description>
|
|
||||||
<servlet-class>org.apache.solr.servlet.SolrServlet</servlet-class>
|
|
||||||
<load-on-startup>1</load-on-startup>
|
|
||||||
</servlet>
|
|
||||||
|
|
||||||
<servlet>
|
|
||||||
<servlet-name>SolrUpdate</servlet-name>
|
|
||||||
<display-name>SolrUpdate</display-name>
|
|
||||||
<description>Solr Update Handler</description>
|
|
||||||
<servlet-class>org.apache.solr.servlet.SolrUpdateServlet</servlet-class>
|
|
||||||
<load-on-startup>2</load-on-startup>
|
|
||||||
</servlet>
|
|
||||||
|
|
||||||
<servlet>
|
<servlet>
|
||||||
<servlet-name>Logging</servlet-name>
|
<servlet-name>Logging</servlet-name>
|
||||||
<servlet-class>org.apache.solr.servlet.LogLevelSelection</servlet-class>
|
<servlet-class>org.apache.solr.servlet.LogLevelSelection</servlet-class>
|
||||||
</servlet>
|
</servlet>
|
||||||
|
|
||||||
<!-- @Deprecated -->
|
|
||||||
<servlet>
|
|
||||||
<servlet-name>ping</servlet-name>
|
|
||||||
<jsp-file>/admin/ping.jsp</jsp-file>
|
|
||||||
</servlet>
|
|
||||||
|
|
||||||
<servlet-mapping>
|
|
||||||
<servlet-name>SolrServer</servlet-name>
|
|
||||||
<url-pattern>/select/*</url-pattern>
|
|
||||||
</servlet-mapping>
|
|
||||||
|
|
||||||
<servlet-mapping>
|
|
||||||
<servlet-name>SolrUpdate</servlet-name>
|
|
||||||
<url-pattern>/update/*</url-pattern>
|
|
||||||
</servlet-mapping>
|
|
||||||
|
|
||||||
<servlet-mapping>
|
<servlet-mapping>
|
||||||
<servlet-name>Logging</servlet-name>
|
<servlet-name>Logging</servlet-name>
|
||||||
<url-pattern>/admin/logging</url-pattern>
|
<url-pattern>/admin/logging</url-pattern>
|
||||||
</servlet-mapping>
|
</servlet-mapping>
|
||||||
|
|
||||||
<!-- @Deprecated -->
|
|
||||||
<servlet-mapping>
|
|
||||||
<servlet-name>ping</servlet-name>
|
|
||||||
<url-pattern>/admin/ping</url-pattern>
|
|
||||||
</servlet-mapping>
|
|
||||||
|
|
||||||
<!-- @Deprecated -->
|
|
||||||
<servlet-mapping>
|
|
||||||
<servlet-name>Logging</servlet-name>
|
|
||||||
<url-pattern>/admin/logging.jsp</url-pattern>
|
|
||||||
</servlet-mapping>
|
|
||||||
|
|
||||||
<mime-mapping>
|
<mime-mapping>
|
||||||
<extension>.xsl</extension>
|
<extension>.xsl</extension>
|
||||||
<!-- per http://www.w3.org/TR/2006/PR-xslt20-20061121/ -->
|
<!-- per http://www.w3.org/TR/2006/PR-xslt20-20061121/ -->
|
||||||
|
|
|
@ -16,7 +16,6 @@
|
||||||
limitations under the License.
|
limitations under the License.
|
||||||
--%>
|
--%>
|
||||||
<%@ page import="org.apache.solr.core.SolrInfoMBean,
|
<%@ page import="org.apache.solr.core.SolrInfoMBean,
|
||||||
org.apache.solr.core.SolrInfoRegistry,
|
|
||||||
java.net.URL,
|
java.net.URL,
|
||||||
java.util.Date,
|
java.util.Date,
|
||||||
java.util.Map"%>
|
java.util.Map"%>
|
||||||
|
|
|
@ -16,7 +16,6 @@
|
||||||
limitations under the License.
|
limitations under the License.
|
||||||
--%>
|
--%>
|
||||||
<%@ page import="org.apache.solr.core.SolrInfoMBean,
|
<%@ page import="org.apache.solr.core.SolrInfoMBean,
|
||||||
org.apache.solr.core.SolrInfoRegistry,
|
|
||||||
org.apache.solr.common.util.NamedList,
|
org.apache.solr.common.util.NamedList,
|
||||||
java.util.Date,
|
java.util.Date,
|
||||||
java.util.Map"%>
|
java.util.Map"%>
|
||||||
|
|
Loading…
Reference in New Issue