mirror of https://github.com/apache/lucene.git
SOLR-493 -- fix /admin/file links for old config formats
git-svn-id: https://svn.apache.org/repos/asf/lucene/solr/trunk@684172 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
parent
aa525ba32a
commit
9354c58c15
|
@ -29,6 +29,7 @@ import org.apache.solr.common.params.SolrParams;
|
|||
import org.apache.solr.common.util.DOMUtil;
|
||||
import org.apache.solr.common.util.NamedList;
|
||||
import org.apache.solr.common.util.SimpleOrderedMap;
|
||||
import org.apache.solr.handler.admin.ShowFileRequestHandler;
|
||||
import org.apache.solr.handler.component.*;
|
||||
import org.apache.solr.highlight.DefaultSolrHighlighter;
|
||||
import org.apache.solr.highlight.SolrHighlighter;
|
||||
|
@ -431,6 +432,9 @@ public final class SolrCore {
|
|||
);
|
||||
highlighter.initalize( solrConfig );
|
||||
|
||||
// Handle things that should eventually go away
|
||||
initDeprecatedSupport();
|
||||
|
||||
final CountDownLatch latch = new CountDownLatch(1);
|
||||
|
||||
try {
|
||||
|
@ -1320,6 +1324,46 @@ public final class SolrCore {
|
|||
return valueSourceParsers.get(parserName);
|
||||
}
|
||||
|
||||
/**
|
||||
* Manage anything that should be taken care of in case configs change
|
||||
*/
|
||||
private void initDeprecatedSupport()
|
||||
{
|
||||
// TODO -- this should be removed in deprecation release...
|
||||
String gettable = solrConfig.get("admin/gettableFiles", null );
|
||||
if( gettable != null ) {
|
||||
log.warning(
|
||||
"solrconfig.xml uses deprecated <admin/gettableFiles>, Please "+
|
||||
"update your config to use the ShowFileRequestHandler." );
|
||||
if( getRequestHandler( "admin/file" ) == null ) {
|
||||
NamedList<String> invariants = new NamedList<String>();
|
||||
|
||||
// Hide everything...
|
||||
Set<String> hide = new HashSet<String>();
|
||||
File configdir = new File( solrConfig.getResourceLoader().getConfigDir() );
|
||||
for( String file : configdir.list() ) {
|
||||
hide.add( file.toUpperCase() );
|
||||
}
|
||||
|
||||
// except the "gettable" list
|
||||
StringTokenizer st = new StringTokenizer( gettable );
|
||||
while( st.hasMoreTokens() ) {
|
||||
hide.remove( st.nextToken().toUpperCase() );
|
||||
}
|
||||
for( String s : hide ) {
|
||||
invariants.add( ShowFileRequestHandler.HIDDEN, s );
|
||||
}
|
||||
|
||||
NamedList<Object> args = new NamedList<Object>();
|
||||
args.add( "invariants", invariants );
|
||||
ShowFileRequestHandler handler = new ShowFileRequestHandler();
|
||||
handler.init( args );
|
||||
reqHandlers.register("admin/file", handler);
|
||||
|
||||
log.warning( "adding ShowFileRequestHandler with hidden files: "+hide );
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public CoreDescriptor getCoreDescriptor() {
|
||||
return coreDescriptor;
|
||||
|
|
|
@ -111,6 +111,11 @@ public class ShowFileRequestHandler extends RequestHandlerBase
|
|||
}
|
||||
}
|
||||
|
||||
public Set<String> getHiddenFiles()
|
||||
{
|
||||
return hiddenFiles;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void handleRequestBody(SolrQueryRequest req, SolrQueryResponse rsp) throws IOException
|
||||
{
|
||||
|
|
|
@ -17,6 +17,7 @@
|
|||
|
||||
package org.apache.solr.core;
|
||||
|
||||
import org.apache.solr.handler.admin.ShowFileRequestHandler;
|
||||
import org.apache.solr.util.AbstractSolrTestCase;
|
||||
import org.apache.solr.update.SolrIndexConfig;
|
||||
import org.w3c.dom.Node;
|
||||
|
@ -62,4 +63,17 @@ public class TestConfig extends AbstractSolrTestCase {
|
|||
boolean luceneAutoCommit = solrConfig.getBool("indexDefaults/luceneAutoCommit");
|
||||
assertTrue(luceneAutoCommit + " does not equal: " + false, luceneAutoCommit == false);
|
||||
}
|
||||
|
||||
// sometime if the config referes to old things, it must be replaced with new stuff
|
||||
public void testAutomaticDeprecationSupport()
|
||||
{
|
||||
// make sure the "admin/file" handler is registered
|
||||
ShowFileRequestHandler handler = (ShowFileRequestHandler) h.getCore().getRequestHandler( "admin/file" );
|
||||
assertTrue( "file handler should have been automatically registered", handler!=null );
|
||||
|
||||
//System.out.println( handler.getHiddenFiles() );
|
||||
// should not contain: <gettableFiles>solrconfig.xml scheam.xml admin-extra.html</gettableFiles>
|
||||
assertFalse( handler.getHiddenFiles().contains( "scheam.xml".toUpperCase() ) );
|
||||
assertTrue( handler.getHiddenFiles().contains( "PROTWORDS.TXT" ) );
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue