aboutsummaryrefslogtreecommitdiffstatshomepage
diff options
context:
space:
mode:
authorDiva Canto2010-08-03 18:20:08 -0700
committerDiva Canto2010-08-03 18:20:08 -0700
commit9ee712459b286892bf2b69e763a302a2f1aae88b (patch)
tree5796e124fecb4a6ec83d18e07b75ea700c68ca6f
parentFurther bug fixing, still related to the issue earlier. (diff)
parentRevert "remove long unused OpenSim/Framework/Configuration/* projects" (diff)
downloadopensim-SC_OLD-9ee712459b286892bf2b69e763a302a2f1aae88b.zip
opensim-SC_OLD-9ee712459b286892bf2b69e763a302a2f1aae88b.tar.gz
opensim-SC_OLD-9ee712459b286892bf2b69e763a302a2f1aae88b.tar.bz2
opensim-SC_OLD-9ee712459b286892bf2b69e763a302a2f1aae88b.tar.xz
Merge branch 'master' of ssh://diva@opensimulator.org/var/git/opensim
Diffstat (limited to '')
-rw-r--r--OpenSim/Framework/Configuration/HTTP/HTTPConfiguration.cs119
-rw-r--r--OpenSim/Framework/Configuration/HTTP/RemoteConfigSettings.cs63
-rw-r--r--OpenSim/Framework/Configuration/XML/XmlConfiguration.cs141
-rw-r--r--OpenSim/Services/GridService/GridService.cs3
-rw-r--r--prebuild.xml52
5 files changed, 377 insertions, 1 deletions
diff --git a/OpenSim/Framework/Configuration/HTTP/HTTPConfiguration.cs b/OpenSim/Framework/Configuration/HTTP/HTTPConfiguration.cs
new file mode 100644
index 0000000..3dce578
--- /dev/null
+++ b/OpenSim/Framework/Configuration/HTTP/HTTPConfiguration.cs
@@ -0,0 +1,119 @@
1/*
2 * Copyright (c) Contributors, http://opensimulator.org/
3 * See CONTRIBUTORS.TXT for a full list of copyright holders.
4 *
5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions are met:
7 * * Redistributions of source code must retain the above copyright
8 * notice, this list of conditions and the following disclaimer.
9 * * Redistributions in binary form must reproduce the above copyright
10 * notice, this list of conditions and the following disclaimer in the
11 * documentation and/or other materials provided with the distribution.
12 * * Neither the name of the OpenSimulator Project nor the
13 * names of its contributors may be used to endorse or promote products
14 * derived from this software without specific prior written permission.
15 *
16 * THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS'' AND ANY
17 * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
18 * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
19 * DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY
20 * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
21 * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
22 * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
23 * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
24 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
25 * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
26 */
27
28using System;
29using System.IO;
30using System.Net;
31using System.Reflection;
32using System.Text;
33using log4net;
34using OpenSim.Framework.Configuration.XML;
35
36namespace OpenSim.Framework.Configuration.HTTP
37{
38 public class HTTPConfiguration : IGenericConfig
39 {
40 private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType);
41
42 private RemoteConfigSettings remoteConfigSettings;
43
44 private XmlConfiguration xmlConfig;
45
46 private string configFileName = String.Empty;
47
48 public HTTPConfiguration()
49 {
50 remoteConfigSettings = new RemoteConfigSettings("remoteconfig.xml");
51 xmlConfig = new XmlConfiguration();
52 }
53
54 public void SetFileName(string fileName)
55 {
56 configFileName = fileName;
57 }
58
59 public void LoadData()
60 {
61 try
62 {
63 StringBuilder sb = new StringBuilder();
64
65 byte[] buf = new byte[8192];
66 HttpWebRequest request =
67 (HttpWebRequest) WebRequest.Create(remoteConfigSettings.baseConfigURL + configFileName);
68 HttpWebResponse response = (HttpWebResponse) request.GetResponse();
69
70 Stream resStream = response.GetResponseStream();
71
72 string tempString = null;
73 int count = 0;
74
75 do
76 {
77 count = resStream.Read(buf, 0, buf.Length);
78 if (count != 0)
79 {
80 tempString = Util.UTF8.GetString(buf, 0, count);
81 sb.Append(tempString);
82 }
83 } while (count > 0);
84 LoadDataFromString(sb.ToString());
85 }
86 catch (WebException)
87 {
88 m_log.Warn("Unable to connect to remote configuration file (" +
89 remoteConfigSettings.baseConfigURL + configFileName +
90 "). Creating local file instead.");
91 xmlConfig.SetFileName(configFileName);
92 xmlConfig.LoadData();
93 }
94 }
95
96 public void LoadDataFromString(string data)
97 {
98 xmlConfig.LoadDataFromString(data);
99 }
100
101 public string GetAttribute(string attributeName)
102 {
103 return xmlConfig.GetAttribute(attributeName);
104 }
105
106 public bool SetAttribute(string attributeName, string attributeValue)
107 {
108 return true;
109 }
110
111 public void Commit()
112 {
113 }
114
115 public void Close()
116 {
117 }
118 }
119}
diff --git a/OpenSim/Framework/Configuration/HTTP/RemoteConfigSettings.cs b/OpenSim/Framework/Configuration/HTTP/RemoteConfigSettings.cs
new file mode 100644
index 0000000..10bc88a
--- /dev/null
+++ b/OpenSim/Framework/Configuration/HTTP/RemoteConfigSettings.cs
@@ -0,0 +1,63 @@
1/*
2 * Copyright (c) Contributors, http://opensimulator.org/
3 * See CONTRIBUTORS.TXT for a full list of copyright holders.
4 *
5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions are met:
7 * * Redistributions of source code must retain the above copyright
8 * notice, this list of conditions and the following disclaimer.
9 * * Redistributions in binary form must reproduce the above copyright
10 * notice, this list of conditions and the following disclaimer in the
11 * documentation and/or other materials provided with the distribution.
12 * * Neither the name of the OpenSimulator Project nor the
13 * names of its contributors may be used to endorse or promote products
14 * derived from this software without specific prior written permission.
15 *
16 * THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS'' AND ANY
17 * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
18 * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
19 * DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY
20 * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
21 * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
22 * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
23 * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
24 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
25 * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
26 */
27
28using System;
29
30namespace OpenSim.Framework.Configuration.HTTP
31{
32 public class RemoteConfigSettings
33 {
34 private ConfigurationMember configMember;
35
36 public string baseConfigURL = String.Empty;
37
38 public RemoteConfigSettings(string filename)
39 {
40 configMember =
41 new ConfigurationMember(filename, "REMOTE CONFIG SETTINGS", loadConfigurationOptions,
42 handleIncomingConfiguration,true);
43 configMember.forceConfigurationPluginLibrary("OpenSim.Framework.Configuration.XML.dll");
44 configMember.performConfigurationRetrieve();
45 }
46
47 public void loadConfigurationOptions()
48 {
49 configMember.addConfigurationOption("base_config_url",
50 ConfigurationOption.ConfigurationTypes.TYPE_STRING_NOT_EMPTY,
51 "URL Containing Configuration Files", "http://localhost/", false);
52 }
53
54 public bool handleIncomingConfiguration(string configuration_key, object configuration_result)
55 {
56 if (configuration_key == "base_config_url")
57 {
58 baseConfigURL = (string) configuration_result;
59 }
60 return true;
61 }
62 }
63}
diff --git a/OpenSim/Framework/Configuration/XML/XmlConfiguration.cs b/OpenSim/Framework/Configuration/XML/XmlConfiguration.cs
new file mode 100644
index 0000000..43162fc
--- /dev/null
+++ b/OpenSim/Framework/Configuration/XML/XmlConfiguration.cs
@@ -0,0 +1,141 @@
1/*
2 * Copyright (c) Contributors, http://opensimulator.org/
3 * See CONTRIBUTORS.TXT for a full list of copyright holders.
4 *
5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions are met:
7 * * Redistributions of source code must retain the above copyright
8 * notice, this list of conditions and the following disclaimer.
9 * * Redistributions in binary form must reproduce the above copyright
10 * notice, this list of conditions and the following disclaimer in the
11 * documentation and/or other materials provided with the distribution.
12 * * Neither the name of the OpenSimulator Project nor the
13 * names of its contributors may be used to endorse or promote products
14 * derived from this software without specific prior written permission.
15 *
16 * THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS'' AND ANY
17 * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
18 * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
19 * DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY
20 * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
21 * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
22 * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
23 * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
24 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
25 * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
26 */
27
28using System;
29using System.IO;
30using System.Xml;
31
32namespace OpenSim.Framework.Configuration.XML
33{
34 public class XmlConfiguration : IGenericConfig
35 {
36 private XmlDocument doc;
37 private XmlNode rootNode;
38 private XmlNode configNode;
39 private string fileName;
40 private bool createdFile = false;
41
42 public void SetFileName(string file)
43 {
44 fileName = file;
45 }
46
47 private void LoadDataToClass()
48 {
49 rootNode = doc.SelectSingleNode("Root");
50 if (null == rootNode)
51 throw new Exception("Error: Invalid .xml File. Missing <Root>");
52
53 configNode = rootNode.SelectSingleNode("Config");
54 if (null == configNode)
55 throw new Exception("Error: Invalid .xml File. <Root> should contain a <Config>");
56 }
57
58 public void LoadData()
59 {
60 lock (this)
61 {
62 doc = new XmlDocument();
63 if (File.Exists(fileName))
64 {
65 XmlTextReader reader = new XmlTextReader(fileName);
66 reader.WhitespaceHandling = WhitespaceHandling.None;
67 doc.Load(reader);
68 reader.Close();
69 }
70 else
71 {
72 createdFile = true;
73 rootNode = doc.CreateNode(XmlNodeType.Element, "Root", String.Empty);
74 doc.AppendChild(rootNode);
75 configNode = doc.CreateNode(XmlNodeType.Element, "Config", String.Empty);
76 rootNode.AppendChild(configNode);
77 }
78
79 LoadDataToClass();
80
81 if (createdFile)
82 {
83 Commit();
84 }
85 }
86 }
87
88 public void LoadDataFromString(string data)
89 {
90 doc = new XmlDocument();
91 doc.LoadXml(data);
92
93 LoadDataToClass();
94 }
95
96 public string GetAttribute(string attributeName)
97 {
98 string result = null;
99 if (configNode.Attributes[attributeName] != null)
100 {
101 result = ((XmlAttribute) configNode.Attributes.GetNamedItem(attributeName)).Value;
102 }
103 return result;
104 }
105
106 public bool SetAttribute(string attributeName, string attributeValue)
107 {
108 if (configNode.Attributes[attributeName] != null)
109 {
110 ((XmlAttribute) configNode.Attributes.GetNamedItem(attributeName)).Value = attributeValue;
111 }
112 else
113 {
114 XmlAttribute attri;
115 attri = doc.CreateAttribute(attributeName);
116 attri.Value = attributeValue;
117 configNode.Attributes.Append(attri);
118 }
119 return true;
120 }
121
122 public void Commit()
123 {
124 if (fileName == null || fileName == String.Empty)
125 return;
126
127 if (!Directory.Exists(Util.configDir()))
128 {
129 Directory.CreateDirectory(Util.configDir());
130 }
131 doc.Save(fileName);
132 }
133
134 public void Close()
135 {
136 configNode = null;
137 rootNode = null;
138 doc = null;
139 }
140 }
141}
diff --git a/OpenSim/Services/GridService/GridService.cs b/OpenSim/Services/GridService/GridService.cs
index f49d86d..ebaed42 100644
--- a/OpenSim/Services/GridService/GridService.cs
+++ b/OpenSim/Services/GridService/GridService.cs
@@ -124,7 +124,7 @@ namespace OpenSim.Services.GridService
124 { 124 {
125 // Regions reserved for the null key cannot be taken. 125 // Regions reserved for the null key cannot be taken.
126 if ((string)region.Data["PrincipalID"] == UUID.Zero.ToString()) 126 if ((string)region.Data["PrincipalID"] == UUID.Zero.ToString())
127 return "Region location us reserved"; 127 return "Region location is reserved";
128 128
129 // Treat it as an auth request 129 // Treat it as an auth request
130 // 130 //
@@ -210,6 +210,7 @@ namespace OpenSim.Services.GridService
210 { 210 {
211 int newFlags = 0; 211 int newFlags = 0;
212 string regionName = rdata.RegionName.Trim().Replace(' ', '_'); 212 string regionName = rdata.RegionName.Trim().Replace(' ', '_');
213 newFlags = ParseFlags(newFlags, gridConfig.GetString("DefaultRegionFlags", String.Empty));
213 newFlags = ParseFlags(newFlags, gridConfig.GetString("Region_" + regionName, String.Empty)); 214 newFlags = ParseFlags(newFlags, gridConfig.GetString("Region_" + regionName, String.Empty));
214 newFlags = ParseFlags(newFlags, gridConfig.GetString("Region_" + rdata.RegionID.ToString(), String.Empty)); 215 newFlags = ParseFlags(newFlags, gridConfig.GetString("Region_" + rdata.RegionID.ToString(), String.Empty));
215 rdata.Data["flags"] = newFlags.ToString(); 216 rdata.Data["flags"] = newFlags.ToString();
diff --git a/prebuild.xml b/prebuild.xml
index 5f55461..8a6d3a1 100644
--- a/prebuild.xml
+++ b/prebuild.xml
@@ -255,6 +255,58 @@
255 </Files> 255 </Files>
256 </Project> 256 </Project>
257 257
258 <Project frameworkVersion="v3_5" name="OpenSim.Framework.Configuration.XML" path="OpenSim/Framework/Configuration/XML" type="Library">
259 <Configuration name="Debug">
260 <Options>
261 <OutputPath>../../../../bin/</OutputPath>
262 </Options>
263 </Configuration>
264 <Configuration name="Release">
265 <Options>
266 <OutputPath>../../../../bin/</OutputPath>
267 </Options>
268 </Configuration>
269
270 <ReferencePath>../../../../bin/</ReferencePath>
271 <Reference name="System"/>
272 <Reference name="System.Xml"/>
273 <Reference name="OpenMetaverseTypes.dll"/>
274 <Reference name="XMLRPC.dll"/>
275 <Reference name="OpenSim.Framework"/>
276 <Reference name="OpenSim.Framework.Console"/>
277 <Reference name="OpenSim.Data"/>
278 <Files>
279 <Match pattern="*.cs" recurse="true"/>
280 </Files>
281 </Project>
282
283 <Project frameworkVersion="v3_5" name="OpenSim.Framework.Configuration.HTTP" path="OpenSim/Framework/Configuration/HTTP" type="Library">
284 <Configuration name="Debug">
285 <Options>
286 <OutputPath>../../../../bin/</OutputPath>
287 </Options>
288 </Configuration>
289 <Configuration name="Release">
290 <Options>
291 <OutputPath>../../../../bin/</OutputPath>
292 </Options>
293 </Configuration>
294
295 <ReferencePath>../../../../bin/</ReferencePath>
296 <Reference name="System"/>
297 <Reference name="System.Xml"/>
298 <Reference name="OpenMetaverseTypes.dll"/>
299 <Reference name="XMLRPC.dll"/>
300 <Reference name="OpenSim.Framework"/>
301 <Reference name="OpenSim.Framework.Console"/>
302 <Reference name="OpenSim.Framework.Configuration.XML"/>
303 <Reference name="OpenSim.Data"/>
304 <Reference name="log4net.dll"/>
305 <Files>
306 <Match pattern="*.cs" recurse="true"/>
307 </Files>
308 </Project>
309
258 <Project frameworkVersion="v3_5" name="OpenSim.Framework.AssetLoader.Filesystem" path="OpenSim/Framework/AssetLoader/Filesystem" type="Library"> 310 <Project frameworkVersion="v3_5" name="OpenSim.Framework.AssetLoader.Filesystem" path="OpenSim/Framework/AssetLoader/Filesystem" type="Library">
259 <Configuration name="Debug"> 311 <Configuration name="Debug">
260 <Options> 312 <Options>