You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@lucene.apache.org by ma...@apache.org on 2011/01/23 04:58:30 UTC

svn commit: r1062319 - in /lucene/dev/trunk/solr: CHANGES.txt src/java/org/apache/solr/core/CoreContainer.java

Author: markrmiller
Date: Sun Jan 23 03:58:30 2011
New Revision: 1062319

URL: http://svn.apache.org/viewvc?rev=1062319&view=rev
Log:
SOLR-2127: Fixed serialization of default core and indentation of solr.xml when serializing.

Modified:
    lucene/dev/trunk/solr/CHANGES.txt
    lucene/dev/trunk/solr/src/java/org/apache/solr/core/CoreContainer.java

Modified: lucene/dev/trunk/solr/CHANGES.txt
URL: http://svn.apache.org/viewvc/lucene/dev/trunk/solr/CHANGES.txt?rev=1062319&r1=1062318&r2=1062319&view=diff
==============================================================================
--- lucene/dev/trunk/solr/CHANGES.txt (original)
+++ lucene/dev/trunk/solr/CHANGES.txt Sun Jan 23 03:58:30 2011
@@ -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
 ----------------------

Modified: lucene/dev/trunk/solr/src/java/org/apache/solr/core/CoreContainer.java
URL: http://svn.apache.org/viewvc/lucene/dev/trunk/solr/src/java/org/apache/solr/core/CoreContainer.java?rev=1062319&r1=1062318&r2=1062319&view=diff
==============================================================================
--- lucene/dev/trunk/solr/src/java/org/apache/solr/core/CoreContainer.java (original)
+++ lucene/dev/trunk/solr/src/java/org/apache/solr/core/CoreContainer.java Sun Jan 23 03:58:30 2011
@@ -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");