mirror of https://github.com/apache/lucene.git
SOLR-718 -- Support persisting solr.xml through SolrJ
git-svn-id: https://svn.apache.org/repos/asf/lucene/solr/trunk@688188 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
parent
c9d64b5a26
commit
f24252c1bd
|
@ -45,6 +45,8 @@ Changes in runtime behavior
|
|||
|
||||
6. SOLR-430: Added support for reading SpellCheckComponent's responses. (shalin)
|
||||
|
||||
7. SOLR-718: Support persisting solr.xml through SolrJ (Henri Biestro via shalin)
|
||||
|
||||
Bug Fixes
|
||||
|
||||
Other Changes
|
||||
|
|
|
@ -77,6 +77,33 @@ public class CoreAdminRequest extends SolrRequest
|
|||
return params;
|
||||
}
|
||||
}
|
||||
//a persist core request
|
||||
public static class Persist extends CoreAdminRequest {
|
||||
protected String fileName = null;
|
||||
|
||||
public Persist() {
|
||||
action = CoreAdminAction.PERSIST;
|
||||
}
|
||||
|
||||
public void setFileName(String name) {
|
||||
fileName = name;
|
||||
}
|
||||
public String getFileName() {
|
||||
return fileName;
|
||||
}
|
||||
@Override
|
||||
public SolrParams getParams() {
|
||||
if( action == null ) {
|
||||
throw new RuntimeException( "no action specified!" );
|
||||
}
|
||||
ModifiableSolrParams params = new ModifiableSolrParams();
|
||||
params.set( CoreAdminParams.ACTION, action.toString() );
|
||||
if (fileName != null) {
|
||||
params.set( CoreAdminParams.FILE, fileName);
|
||||
}
|
||||
return params;
|
||||
}
|
||||
}
|
||||
|
||||
public CoreAdminRequest()
|
||||
{
|
||||
|
@ -198,5 +225,12 @@ public class CoreAdminRequest extends SolrRequest
|
|||
req.setInstanceDir(instanceDir);
|
||||
return req.process( server );
|
||||
}
|
||||
|
||||
public static CoreAdminResponse persist(String fileName, SolrServer server) throws SolrServerException, IOException
|
||||
{
|
||||
CoreAdminRequest.Persist req = new CoreAdminRequest.Persist();
|
||||
req.setFileName(fileName);
|
||||
return req.process(server);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -46,6 +46,9 @@ public interface CoreAdminParams
|
|||
|
||||
/** Specifies a core instance dir. */
|
||||
public final static String INSTANCE_DIR = "instanceDir";
|
||||
|
||||
/** If you specify a file, what is its name **/
|
||||
public final static String FILE = "file";
|
||||
|
||||
public enum CoreAdminAction {
|
||||
STATUS,
|
||||
|
|
|
@ -34,6 +34,7 @@ import org.apache.solr.request.SolrQueryRequest;
|
|||
import org.apache.solr.request.SolrQueryResponse;
|
||||
import org.apache.solr.search.SolrIndexSearcher;
|
||||
import org.apache.solr.util.RefCounted;
|
||||
import org.apache.solr.common.util.StrUtils;
|
||||
|
||||
/**
|
||||
* @version $Id$
|
||||
|
@ -160,7 +161,18 @@ public abstract class CoreAdminHandler extends RequestHandlerBase
|
|||
}
|
||||
|
||||
case PERSIST: {
|
||||
do_persist = true;
|
||||
String fileName = params.get( CoreAdminParams.FILE );
|
||||
if (fileName != null) {
|
||||
java.io.File file = new java.io.File(fileName);
|
||||
cores.persistFile(file);
|
||||
rsp.add("saved", file.getAbsolutePath());
|
||||
do_persist = false;
|
||||
}
|
||||
else if (!cores.isPersistent()) {
|
||||
throw new SolrException (SolrException.ErrorCode.FORBIDDEN, "Persistence is not enabled");
|
||||
}
|
||||
else
|
||||
do_persist = true;
|
||||
break;
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue