aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/OpenSim
diff options
context:
space:
mode:
authorJeff Ames2007-11-17 05:53:12 +0000
committerJeff Ames2007-11-17 05:53:12 +0000
commit946db5461c8262d3b957e42ed7a90feb447c618b (patch)
tree7ba5a76429f19881d684a9c317210f39e4cc70b1 /OpenSim
parentfixed svn:ignore on POSPlugin (diff)
downloadopensim-SC-946db5461c8262d3b957e42ed7a90feb447c618b.zip
opensim-SC-946db5461c8262d3b957e42ed7a90feb447c618b.tar.gz
opensim-SC-946db5461c8262d3b957e42ed7a90feb447c618b.tar.bz2
opensim-SC-946db5461c8262d3b957e42ed7a90feb447c618b.tar.xz
catch exceptions when loading malformed xml files
Diffstat (limited to 'OpenSim')
-rw-r--r--OpenSim/Framework/Communications/Cache/AssetServerBase.cs38
-rw-r--r--OpenSim/Framework/Communications/Cache/LibraryRootFolder.cs13
-rw-r--r--OpenSim/Framework/ConfigurationMember.cs17
3 files changed, 44 insertions, 24 deletions
diff --git a/OpenSim/Framework/Communications/Cache/AssetServerBase.cs b/OpenSim/Framework/Communications/Cache/AssetServerBase.cs
index 7692057..1a20cee 100644
--- a/OpenSim/Framework/Communications/Cache/AssetServerBase.cs
+++ b/OpenSim/Framework/Communications/Cache/AssetServerBase.cs
@@ -2,6 +2,7 @@ using System;
2using System.Collections.Generic; 2using System.Collections.Generic;
3using System.IO; 3using System.IO;
4using System.Threading; 4using System.Threading;
5using System.Xml;
5using libsecondlife; 6using libsecondlife;
6using Nini.Config; 7using Nini.Config;
7using OpenSim.Framework.Console; 8using OpenSim.Framework.Console;
@@ -148,22 +149,29 @@ namespace OpenSim.Framework.Communications.Cache
148 string filePath = Path.Combine(Util.configDir(), "OpenSimAssetSet.xml"); 149 string filePath = Path.Combine(Util.configDir(), "OpenSimAssetSet.xml");
149 if (File.Exists(filePath)) 150 if (File.Exists(filePath))
150 { 151 {
151 XmlConfigSource source = new XmlConfigSource(filePath); 152 try
152 153 {
153 for (int i = 0; i < source.Configs.Count; i++) 154 XmlConfigSource source = new XmlConfigSource(filePath);
155
156 for (int i = 0; i < source.Configs.Count; i++)
157 {
158 // System.Console.WriteLine("loading asset into database");
159 string assetIdStr = source.Configs[i].GetString("assetID", LLUUID.Random().ToStringHyphenated());
160 string name = source.Configs[i].GetString("name", "");
161 sbyte type = (sbyte) source.Configs[i].GetInt("assetType", 0);
162 sbyte invType = (sbyte) source.Configs[i].GetInt("inventoryType", 0);
163 string fileName = source.Configs[i].GetString("fileName", "");
164
165 AssetBase newAsset = CreateAsset(assetIdStr, name, fileName, false);
166
167 newAsset.Type = type;
168 newAsset.InvType = invType;
169 assets.Add(newAsset);
170 }
171 }
172 catch (XmlException e)
154 { 173 {
155 // System.Console.WriteLine("loading asset into database"); 174 MainLog.Instance.Error("ASSETS", "Error loading " + filePath + ": " + e.ToString());
156 string assetIdStr = source.Configs[i].GetString("assetID", LLUUID.Random().ToStringHyphenated());
157 string name = source.Configs[i].GetString("name", "");
158 sbyte type = (sbyte) source.Configs[i].GetInt("assetType", 0);
159 sbyte invType = (sbyte) source.Configs[i].GetInt("inventoryType", 0);
160 string fileName = source.Configs[i].GetString("fileName", "");
161
162 AssetBase newAsset = CreateAsset(assetIdStr, name, fileName, false);
163
164 newAsset.Type = type;
165 newAsset.InvType = invType;
166 assets.Add(newAsset);
167 } 175 }
168 } 176 }
169 assets.ForEach(action); 177 assets.ForEach(action);
diff --git a/OpenSim/Framework/Communications/Cache/LibraryRootFolder.cs b/OpenSim/Framework/Communications/Cache/LibraryRootFolder.cs
index 765c42e..05caa84 100644
--- a/OpenSim/Framework/Communications/Cache/LibraryRootFolder.cs
+++ b/OpenSim/Framework/Communications/Cache/LibraryRootFolder.cs
@@ -27,8 +27,10 @@
27*/ 27*/
28 28
29using System.IO; 29using System.IO;
30using System.Xml;
30using libsecondlife; 31using libsecondlife;
31using Nini.Config; 32using Nini.Config;
33using OpenSim.Framework.Console;
32 34
33namespace OpenSim.Framework.Communications.Cache 35namespace OpenSim.Framework.Communications.Cache
34{ 36{
@@ -65,8 +67,15 @@ namespace OpenSim.Framework.Communications.Cache
65 string filePath = Path.Combine(Util.configDir(), "OpenSimLibrary.xml"); 67 string filePath = Path.Combine(Util.configDir(), "OpenSimLibrary.xml");
66 if (File.Exists(filePath)) 68 if (File.Exists(filePath))
67 { 69 {
68 XmlConfigSource source = new XmlConfigSource(filePath); 70 try
69 ReadItemsFromFile(source); 71 {
72 XmlConfigSource source = new XmlConfigSource(filePath);
73 ReadItemsFromFile(source);
74 }
75 catch (XmlException e)
76 {
77 MainLog.Instance.Error("INVENTORY", "Error loading " + filePath + ": " + e.ToString());
78 }
70 } 79 }
71 } 80 }
72 81
diff --git a/OpenSim/Framework/ConfigurationMember.cs b/OpenSim/Framework/ConfigurationMember.cs
index e4cd9d8..8e46a04 100644
--- a/OpenSim/Framework/ConfigurationMember.cs
+++ b/OpenSim/Framework/ConfigurationMember.cs
@@ -166,8 +166,16 @@ namespace OpenSim.Framework
166 if (configurationFilename.Trim() != "") 166 if (configurationFilename.Trim() != "")
167 { 167 {
168 configurationPlugin.SetFileName(configurationFilename); 168 configurationPlugin.SetFileName(configurationFilename);
169 configurationPlugin.LoadData(); 169 try
170 useFile = true; 170 {
171 configurationPlugin.LoadData();
172 useFile = true;
173 }
174 catch (XmlException e)
175 {
176 MainLog.Instance.Error("Error loading " + configurationFilename + ": " + e.ToString());
177 useFile = false;
178 }
171 } 179 }
172 else 180 else
173 { 181 {
@@ -189,7 +197,6 @@ namespace OpenSim.Framework
189 bool ignoreNextFromConfig = false; 197 bool ignoreNextFromConfig = false;
190 while (convertSuccess == false) 198 while (convertSuccess == false)
191 { 199 {
192
193 string console_result = ""; 200 string console_result = "";
194 string attribute = null; 201 string attribute = null;
195 if (useFile || (!useFile && configurationFromXMLNode != null)) 202 if (useFile || (!useFile && configurationFromXMLNode != null))
@@ -228,7 +235,6 @@ namespace OpenSim.Framework
228 //Dont Ask! Just use default 235 //Dont Ask! Just use default
229 console_result = configOption.configurationDefault; 236 console_result = configOption.configurationDefault;
230 } 237 }
231
232 } 238 }
233 } 239 }
234 else 240 else
@@ -292,7 +298,6 @@ namespace OpenSim.Framework
292 { 298 {
293 convertSuccess = true; 299 convertSuccess = true;
294 return_result = intResult; 300 return_result = intResult;
295
296 } 301 }
297 errorMessage = "a signed 32 bit integer (int)"; 302 errorMessage = "a signed 32 bit integer (int)";
298 break; 303 break;
@@ -347,7 +352,6 @@ namespace OpenSim.Framework
347 { 352 {
348 convertSuccess = true; 353 convertSuccess = true;
349 return_result = uintResult; 354 return_result = uintResult;
350
351 } 355 }
352 errorMessage = "an unsigned 32 bit integer (uint)"; 356 errorMessage = "an unsigned 32 bit integer (uint)";
353 break; 357 break;
@@ -387,7 +391,6 @@ namespace OpenSim.Framework
387 configurationPlugin.SetAttribute(configOption.configurationKey, console_result); 391 configurationPlugin.SetAttribute(configOption.configurationKey, console_result);
388 } 392 }
389 393
390
391 if (!this.resultFunction(configOption.configurationKey, return_result)) 394 if (!this.resultFunction(configOption.configurationKey, return_result))
392 { 395 {
393 Console.MainLog.Instance.Notice("The handler for the last configuration option denied that input, please try again."); 396 Console.MainLog.Instance.Notice("The handler for the last configuration option denied that input, please try again.");