SOLR-2127: Fixed serialization of default core and indentation of solr.xml when serializing.

git-svn-id: https://svn.apache.org/repos/asf/lucene/dev/trunk@1062319 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
Mark Robert Miller 2011-01-23 03:58:30 +00:00
parent 741882bcb1
commit 22f0fe9718
2 changed files with 12 additions and 10 deletions

View File

@ -158,6 +158,8 @@ Bug Fixes
dealing with SolrDocumentList objects -- ie: sharded queries.
(Antonio Verni via hossman)
* SOLR-2127: Fixed serialization of default core and indentation of solr.xml when serializing.
(Ephraim Ofir, Mark Miller)
Other Changes
----------------------

View File

@ -879,7 +879,7 @@ public class CoreContainer
/** Write the cores configuration through a writer.*/
void persist(Writer w) throws IOException {
w.write("<?xml version='1.0' encoding='UTF-8'?>");
w.write("<?xml version=\"1.0\" encoding=\"UTF-8\" ?>\n");
w.write("<solr");
if (this.libDir != null) {
writeAttribute(w,"sharedLib",libDir);
@ -888,9 +888,9 @@ public class CoreContainer
w.write(">\n");
if (containerProperties != null && !containerProperties.isEmpty()) {
writeProperties(w, containerProperties);
writeProperties(w, containerProperties, " ");
}
w.write("<cores");
w.write(" <cores");
writeAttribute(w, "adminPath",adminPath);
if(adminHandler != null) writeAttribute(w, "adminHandler",adminHandler);
if(shareSchema) writeAttribute(w, "shareSchema","true");
@ -903,7 +903,7 @@ public class CoreContainer
}
}
w.write("</cores>\n");
w.write(" </cores>\n");
w.write("</solr>\n");
}
@ -918,8 +918,8 @@ public class CoreContainer
/** Writes the cores configuration node for a given core. */
void persist(Writer w, CoreDescriptor dcore) throws IOException {
w.write(" <core");
writeAttribute(w,"name",dcore.name);
w.write(" <core");
writeAttribute(w,"name",dcore.name.equals("") ? defaultCoreName : dcore.name);
writeAttribute(w,"instanceDir",dcore.getInstanceDir());
//write config (if not default)
String opt = dcore.getConfigName();
@ -953,14 +953,14 @@ public class CoreContainer
w.write("/>\n"); // core
else {
w.write(">\n");
writeProperties(w, dcore.getCoreProperties());
w.write("</core>");
writeProperties(w, dcore.getCoreProperties(), " ");
w.write(" </core>\n");
}
}
private void writeProperties(Writer w, Properties props) throws IOException {
private void writeProperties(Writer w, Properties props, String indent) throws IOException {
for (Map.Entry<Object, Object> entry : props.entrySet()) {
w.write("<property");
w.write(indent + "<property");
writeAttribute(w,"name",entry.getKey());
writeAttribute(w,"value",entry.getValue());
w.write("/>\n");