Update svn properties, add copyright headers, minor formatting cleanup.
parent
52b2d8732a
commit
551bebdc84
|
@ -1,284 +1,284 @@
|
||||||
/*
|
/*
|
||||||
* Copyright (c) Contributors, http://opensimulator.org/
|
* Copyright (c) Contributors, http://opensimulator.org/
|
||||||
* See CONTRIBUTORS.TXT for a full list of copyright holders.
|
* See CONTRIBUTORS.TXT for a full list of copyright holders.
|
||||||
*
|
*
|
||||||
* Redistribution and use in source and binary forms, with or without
|
* Redistribution and use in source and binary forms, with or without
|
||||||
* modification, are permitted provided that the following conditions are met:
|
* modification, are permitted provided that the following conditions are met:
|
||||||
* * Redistributions of source code must retain the above copyright
|
* * Redistributions of source code must retain the above copyright
|
||||||
* notice, this list of conditions and the following disclaimer.
|
* notice, this list of conditions and the following disclaimer.
|
||||||
* * Redistributions in binary form must reproduce the above copyright
|
* * Redistributions in binary form must reproduce the above copyright
|
||||||
* notice, this list of conditions and the following disclaimer in the
|
* notice, this list of conditions and the following disclaimer in the
|
||||||
* documentation and/or other materials provided with the distribution.
|
* documentation and/or other materials provided with the distribution.
|
||||||
* * Neither the name of the OpenSim Project nor the
|
* * Neither the name of the OpenSim Project nor the
|
||||||
* names of its contributors may be used to endorse or promote products
|
* names of its contributors may be used to endorse or promote products
|
||||||
* derived from this software without specific prior written permission.
|
* derived from this software without specific prior written permission.
|
||||||
*
|
*
|
||||||
* THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS'' AND ANY
|
* THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS'' AND ANY
|
||||||
* EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
|
* EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
|
||||||
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
||||||
* DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY
|
* DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY
|
||||||
* DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
|
* DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
|
||||||
* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
|
* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
|
||||||
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
|
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
|
||||||
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||||
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
|
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
|
||||||
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
using System;
|
using System;
|
||||||
using System.Collections;
|
using System.Collections;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using System.IO;
|
using System.IO;
|
||||||
using System.Reflection;
|
using System.Reflection;
|
||||||
using System.Xml;
|
using System.Xml;
|
||||||
using log4net;
|
using log4net;
|
||||||
using Nwc.XmlRpc;
|
using Nwc.XmlRpc;
|
||||||
using OpenMetaverse;
|
using OpenMetaverse;
|
||||||
using OpenSim.Data;
|
using OpenSim.Data;
|
||||||
using OpenSim.Framework;
|
using OpenSim.Framework;
|
||||||
using OpenSim.Framework.Communications;
|
using OpenSim.Framework.Communications;
|
||||||
using OpenSim.Framework.Servers;
|
using OpenSim.Framework.Servers;
|
||||||
|
|
||||||
|
|
||||||
namespace OpenSim.Grid.GridServer
|
namespace OpenSim.Grid.GridServer
|
||||||
{
|
{
|
||||||
public class GridDBService
|
public class GridDBService
|
||||||
{
|
{
|
||||||
private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType);
|
private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType);
|
||||||
|
|
||||||
private List<IGridDataPlugin> _plugins = new List<IGridDataPlugin>();
|
private List<IGridDataPlugin> _plugins = new List<IGridDataPlugin>();
|
||||||
private List<ILogDataPlugin> _logplugins = new List<ILogDataPlugin>();
|
private List<ILogDataPlugin> _logplugins = new List<ILogDataPlugin>();
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Adds a list of grid and log data plugins, as described by
|
/// Adds a list of grid and log data plugins, as described by
|
||||||
/// `provider' and `connect', to `_plugins' and `_logplugins',
|
/// `provider' and `connect', to `_plugins' and `_logplugins',
|
||||||
/// respectively.
|
/// respectively.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <param name="provider">
|
/// <param name="provider">
|
||||||
/// The filename of the inventory server plugin DLL.
|
/// The filename of the inventory server plugin DLL.
|
||||||
/// </param>
|
/// </param>
|
||||||
/// <param name="connect">
|
/// <param name="connect">
|
||||||
/// The connection string for the storage backend.
|
/// The connection string for the storage backend.
|
||||||
/// </param>
|
/// </param>
|
||||||
public void AddPlugin(string provider, string connect)
|
public void AddPlugin(string provider, string connect)
|
||||||
{
|
{
|
||||||
_plugins = DataPluginFactory.LoadDataPlugins<IGridDataPlugin>(provider, connect);
|
_plugins = DataPluginFactory.LoadDataPlugins<IGridDataPlugin>(provider, connect);
|
||||||
_logplugins = DataPluginFactory.LoadDataPlugins<ILogDataPlugin>(provider, connect);
|
_logplugins = DataPluginFactory.LoadDataPlugins<ILogDataPlugin>(provider, connect);
|
||||||
}
|
}
|
||||||
|
|
||||||
public int GetNumberOfPlugins()
|
public int GetNumberOfPlugins()
|
||||||
{
|
{
|
||||||
return _plugins.Count;
|
return _plugins.Count;
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Logs a piece of information to the database
|
/// Logs a piece of information to the database
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <param name="target">What you were operating on (in grid server, this will likely be the region UUIDs)</param>
|
/// <param name="target">What you were operating on (in grid server, this will likely be the region UUIDs)</param>
|
||||||
/// <param name="method">Which method is being called?</param>
|
/// <param name="method">Which method is being called?</param>
|
||||||
/// <param name="args">What arguments are being passed?</param>
|
/// <param name="args">What arguments are being passed?</param>
|
||||||
/// <param name="priority">How high priority is this? 1 = Max, 6 = Verbose</param>
|
/// <param name="priority">How high priority is this? 1 = Max, 6 = Verbose</param>
|
||||||
/// <param name="message">The message to log</param>
|
/// <param name="message">The message to log</param>
|
||||||
private void logToDB(string target, string method, string args, int priority, string message)
|
private void logToDB(string target, string method, string args, int priority, string message)
|
||||||
{
|
{
|
||||||
foreach (ILogDataPlugin plugin in _logplugins)
|
foreach (ILogDataPlugin plugin in _logplugins)
|
||||||
{
|
{
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
plugin.saveLog("Gridserver", target, method, args, priority, message);
|
plugin.saveLog("Gridserver", target, method, args, priority, message);
|
||||||
}
|
}
|
||||||
catch (Exception)
|
catch (Exception)
|
||||||
{
|
{
|
||||||
m_log.Warn("[storage]: Unable to write log via " + plugin.Name);
|
m_log.Warn("[storage]: Unable to write log via " + plugin.Name);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Returns a region by argument
|
/// Returns a region by argument
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <param name="uuid">A UUID key of the region to return</param>
|
/// <param name="uuid">A UUID key of the region to return</param>
|
||||||
/// <returns>A SimProfileData for the region</returns>
|
/// <returns>A SimProfileData for the region</returns>
|
||||||
public RegionProfileData GetRegion(UUID uuid)
|
public RegionProfileData GetRegion(UUID uuid)
|
||||||
{
|
{
|
||||||
foreach (IGridDataPlugin plugin in _plugins)
|
foreach (IGridDataPlugin plugin in _plugins)
|
||||||
{
|
{
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
return plugin.GetProfileByUUID(uuid);
|
return plugin.GetProfileByUUID(uuid);
|
||||||
}
|
}
|
||||||
catch (Exception e)
|
catch (Exception e)
|
||||||
{
|
{
|
||||||
m_log.Warn("[storage]: GetRegion - " + e.Message);
|
m_log.Warn("[storage]: GetRegion - " + e.Message);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Returns a region by argument
|
/// Returns a region by argument
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <param name="uuid">A regionHandle of the region to return</param>
|
/// <param name="uuid">A regionHandle of the region to return</param>
|
||||||
/// <returns>A SimProfileData for the region</returns>
|
/// <returns>A SimProfileData for the region</returns>
|
||||||
public RegionProfileData GetRegion(ulong handle)
|
public RegionProfileData GetRegion(ulong handle)
|
||||||
{
|
{
|
||||||
foreach (IGridDataPlugin plugin in _plugins)
|
foreach (IGridDataPlugin plugin in _plugins)
|
||||||
{
|
{
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
return plugin.GetProfileByHandle(handle);
|
return plugin.GetProfileByHandle(handle);
|
||||||
}
|
}
|
||||||
catch (Exception ex)
|
catch (Exception ex)
|
||||||
{
|
{
|
||||||
m_log.Debug("[storage]: " + ex.Message);
|
m_log.Debug("[storage]: " + ex.Message);
|
||||||
m_log.Warn("[storage]: Unable to find region " + handle.ToString() + " via " + plugin.Name);
|
m_log.Warn("[storage]: Unable to find region " + handle.ToString() + " via " + plugin.Name);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Returns a region by argument
|
/// Returns a region by argument
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <param name="regionName">A partial regionName of the region to return</param>
|
/// <param name="regionName">A partial regionName of the region to return</param>
|
||||||
/// <returns>A SimProfileData for the region</returns>
|
/// <returns>A SimProfileData for the region</returns>
|
||||||
public RegionProfileData GetRegion(string regionName)
|
public RegionProfileData GetRegion(string regionName)
|
||||||
{
|
{
|
||||||
foreach (IGridDataPlugin plugin in _plugins)
|
foreach (IGridDataPlugin plugin in _plugins)
|
||||||
{
|
{
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
return plugin.GetProfileByString(regionName);
|
return plugin.GetProfileByString(regionName);
|
||||||
}
|
}
|
||||||
catch
|
catch
|
||||||
{
|
{
|
||||||
m_log.Warn("[storage]: Unable to find region " + regionName + " via " + plugin.Name);
|
m_log.Warn("[storage]: Unable to find region " + regionName + " via " + plugin.Name);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
public List<RegionProfileData> GetRegions(uint xmin, uint ymin, uint xmax, uint ymax)
|
public List<RegionProfileData> GetRegions(uint xmin, uint ymin, uint xmax, uint ymax)
|
||||||
{
|
{
|
||||||
List<RegionProfileData> regions = new List<RegionProfileData>();
|
List<RegionProfileData> regions = new List<RegionProfileData>();
|
||||||
|
|
||||||
foreach (IGridDataPlugin plugin in _plugins)
|
foreach (IGridDataPlugin plugin in _plugins)
|
||||||
{
|
{
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
regions.AddRange(plugin.GetProfilesInRange(xmin, ymin, xmax, ymax));
|
regions.AddRange(plugin.GetProfilesInRange(xmin, ymin, xmax, ymax));
|
||||||
}
|
}
|
||||||
catch
|
catch
|
||||||
{
|
{
|
||||||
m_log.Warn("[storage]: Unable to query regionblock via " + plugin.Name);
|
m_log.Warn("[storage]: Unable to query regionblock via " + plugin.Name);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return regions;
|
return regions;
|
||||||
}
|
}
|
||||||
|
|
||||||
public List<RegionProfileData> GetRegions(string name, int maxNum)
|
public List<RegionProfileData> GetRegions(string name, int maxNum)
|
||||||
{
|
{
|
||||||
List<RegionProfileData> regions = new List<RegionProfileData>();
|
List<RegionProfileData> regions = new List<RegionProfileData>();
|
||||||
foreach (IGridDataPlugin plugin in _plugins)
|
foreach (IGridDataPlugin plugin in _plugins)
|
||||||
{
|
{
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
int num = maxNum - regions.Count;
|
int num = maxNum - regions.Count;
|
||||||
List<RegionProfileData> profiles = plugin.GetRegionsByName(name, (uint)num);
|
List<RegionProfileData> profiles = plugin.GetRegionsByName(name, (uint)num);
|
||||||
if (profiles != null) regions.AddRange(profiles);
|
if (profiles != null) regions.AddRange(profiles);
|
||||||
}
|
}
|
||||||
catch
|
catch
|
||||||
{
|
{
|
||||||
m_log.Warn("[storage]: Unable to query regionblock via " + plugin.Name);
|
m_log.Warn("[storage]: Unable to query regionblock via " + plugin.Name);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return regions;
|
return regions;
|
||||||
}
|
}
|
||||||
|
|
||||||
public DataResponse AddUpdateRegion(RegionProfileData sim, RegionProfileData existingSim)
|
public DataResponse AddUpdateRegion(RegionProfileData sim, RegionProfileData existingSim)
|
||||||
{
|
{
|
||||||
DataResponse insertResponse = DataResponse.RESPONSE_ERROR;
|
DataResponse insertResponse = DataResponse.RESPONSE_ERROR;
|
||||||
foreach (IGridDataPlugin plugin in _plugins)
|
foreach (IGridDataPlugin plugin in _plugins)
|
||||||
{
|
{
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
if (existingSim == null)
|
if (existingSim == null)
|
||||||
{
|
{
|
||||||
insertResponse = plugin.AddProfile(sim);
|
insertResponse = plugin.AddProfile(sim);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
insertResponse = plugin.UpdateProfile(sim);
|
insertResponse = plugin.UpdateProfile(sim);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
catch (Exception e)
|
catch (Exception e)
|
||||||
{
|
{
|
||||||
m_log.Warn("[LOGIN END]: " +
|
m_log.Warn("[LOGIN END]: " +
|
||||||
"Unable to login region " + sim.ToString() + " via " + plugin.Name);
|
"Unable to login region " + sim.ToString() + " via " + plugin.Name);
|
||||||
m_log.Warn("[LOGIN END]: " + e.ToString());
|
m_log.Warn("[LOGIN END]: " + e.ToString());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return insertResponse;
|
return insertResponse;
|
||||||
}
|
}
|
||||||
|
|
||||||
public DataResponse DeleteRegion(string uuid)
|
public DataResponse DeleteRegion(string uuid)
|
||||||
{
|
{
|
||||||
DataResponse insertResponse = DataResponse.RESPONSE_ERROR;
|
DataResponse insertResponse = DataResponse.RESPONSE_ERROR;
|
||||||
foreach (IGridDataPlugin plugin in _plugins)
|
foreach (IGridDataPlugin plugin in _plugins)
|
||||||
{
|
{
|
||||||
//OpenSim.Data.MySQL.MySQLGridData dbengine = new OpenSim.Data.MySQL.MySQLGridData();
|
//OpenSim.Data.MySQL.MySQLGridData dbengine = new OpenSim.Data.MySQL.MySQLGridData();
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
//Nice are we not using multiple databases?
|
//Nice are we not using multiple databases?
|
||||||
//MySQLGridData mysqldata = (MySQLGridData)(plugin);
|
//MySQLGridData mysqldata = (MySQLGridData)(plugin);
|
||||||
|
|
||||||
//DataResponse insertResponse = mysqldata.DeleteProfile(TheSim);
|
//DataResponse insertResponse = mysqldata.DeleteProfile(TheSim);
|
||||||
insertResponse = plugin.DeleteProfile(uuid);
|
insertResponse = plugin.DeleteProfile(uuid);
|
||||||
}
|
}
|
||||||
catch (Exception)
|
catch (Exception)
|
||||||
{
|
{
|
||||||
m_log.Error("storage Unable to delete region " + uuid + " via " + plugin.Name);
|
m_log.Error("storage Unable to delete region " + uuid + " via " + plugin.Name);
|
||||||
//MainLog.Instance.Warn("storage", e.ToString());
|
//MainLog.Instance.Warn("storage", e.ToString());
|
||||||
insertResponse = DataResponse.RESPONSE_ERROR;
|
insertResponse = DataResponse.RESPONSE_ERROR;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return insertResponse;
|
return insertResponse;
|
||||||
}
|
}
|
||||||
|
|
||||||
public string CheckReservations(RegionProfileData theSim, XmlNode authkeynode)
|
public string CheckReservations(RegionProfileData theSim, XmlNode authkeynode)
|
||||||
{
|
{
|
||||||
foreach (IGridDataPlugin plugin in _plugins)
|
foreach (IGridDataPlugin plugin in _plugins)
|
||||||
{
|
{
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
//Check reservations
|
//Check reservations
|
||||||
ReservationData reserveData =
|
ReservationData reserveData =
|
||||||
plugin.GetReservationAtPoint(theSim.regionLocX, theSim.regionLocY);
|
plugin.GetReservationAtPoint(theSim.regionLocX, theSim.regionLocY);
|
||||||
if ((reserveData != null && reserveData.gridRecvKey == theSim.regionRecvKey) ||
|
if ((reserveData != null && reserveData.gridRecvKey == theSim.regionRecvKey) ||
|
||||||
(reserveData == null && authkeynode.InnerText != theSim.regionRecvKey))
|
(reserveData == null && authkeynode.InnerText != theSim.regionRecvKey))
|
||||||
{
|
{
|
||||||
plugin.AddProfile(theSim);
|
plugin.AddProfile(theSim);
|
||||||
m_log.Info("[grid]: New sim added to grid (" + theSim.regionName + ")");
|
m_log.Info("[grid]: New sim added to grid (" + theSim.regionName + ")");
|
||||||
logToDB(theSim.ToString(), "RestSetSimMethod", String.Empty, 5,
|
logToDB(theSim.ToString(), "RestSetSimMethod", String.Empty, 5,
|
||||||
"Region successfully updated and connected to grid.");
|
"Region successfully updated and connected to grid.");
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
m_log.Warn("[grid]: " +
|
m_log.Warn("[grid]: " +
|
||||||
"Unable to update region (RestSetSimMethod): Incorrect reservation auth key.");
|
"Unable to update region (RestSetSimMethod): Incorrect reservation auth key.");
|
||||||
// Wanted: " + reserveData.gridRecvKey + ", Got: " + theSim.regionRecvKey + ".");
|
// Wanted: " + reserveData.gridRecvKey + ", Got: " + theSim.regionRecvKey + ".");
|
||||||
return "Unable to update region (RestSetSimMethod): Incorrect auth key.";
|
return "Unable to update region (RestSetSimMethod): Incorrect auth key.";
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
catch (Exception e)
|
catch (Exception e)
|
||||||
{
|
{
|
||||||
m_log.Warn("[GRID]: GetRegionPlugin Handle " + plugin.Name + " unable to add new sim: " +
|
m_log.Warn("[GRID]: GetRegionPlugin Handle " + plugin.Name + " unable to add new sim: " +
|
||||||
e.ToString());
|
e.ToString());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return "OK";
|
return "OK";
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,139 +1,139 @@
|
||||||
/*
|
/*
|
||||||
* Copyright (c) Contributors, http://opensimulator.org/
|
* Copyright (c) Contributors, http://opensimulator.org/
|
||||||
* See CONTRIBUTORS.TXT for a full list of copyright holders.
|
* See CONTRIBUTORS.TXT for a full list of copyright holders.
|
||||||
*
|
*
|
||||||
* Redistribution and use in source and binary forms, with or without
|
* Redistribution and use in source and binary forms, with or without
|
||||||
* modification, are permitted provided that the following conditions are met:
|
* modification, are permitted provided that the following conditions are met:
|
||||||
* * Redistributions of source code must retain the above copyright
|
* * Redistributions of source code must retain the above copyright
|
||||||
* notice, this list of conditions and the following disclaimer.
|
* notice, this list of conditions and the following disclaimer.
|
||||||
* * Redistributions in binary form must reproduce the above copyright
|
* * Redistributions in binary form must reproduce the above copyright
|
||||||
* notice, this list of conditions and the following disclaimer in the
|
* notice, this list of conditions and the following disclaimer in the
|
||||||
* documentation and/or other materials provided with the distribution.
|
* documentation and/or other materials provided with the distribution.
|
||||||
* * Neither the name of the OpenSim Project nor the
|
* * Neither the name of the OpenSim Project nor the
|
||||||
* names of its contributors may be used to endorse or promote products
|
* names of its contributors may be used to endorse or promote products
|
||||||
* derived from this software without specific prior written permission.
|
* derived from this software without specific prior written permission.
|
||||||
*
|
*
|
||||||
* THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS'' AND ANY
|
* THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS'' AND ANY
|
||||||
* EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
|
* EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
|
||||||
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
||||||
* DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY
|
* DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY
|
||||||
* DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
|
* DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
|
||||||
* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
|
* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
|
||||||
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
|
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
|
||||||
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||||
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
|
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
|
||||||
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
using System;
|
using System;
|
||||||
using System.Collections;
|
using System.Collections;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using System.Reflection;
|
using System.Reflection;
|
||||||
using System.Text;
|
using System.Text;
|
||||||
using Nwc.XmlRpc;
|
using Nwc.XmlRpc;
|
||||||
using log4net;
|
using log4net;
|
||||||
using OpenSim.Framework.Servers;
|
using OpenSim.Framework.Servers;
|
||||||
using OpenSim.Framework;
|
using OpenSim.Framework;
|
||||||
|
|
||||||
namespace OpenSim.Grid.GridServer
|
namespace OpenSim.Grid.GridServer
|
||||||
{
|
{
|
||||||
public class GridMessagingModule : IGridMessagingModule
|
public class GridMessagingModule : IGridMessagingModule
|
||||||
{
|
{
|
||||||
private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType);
|
private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType);
|
||||||
|
|
||||||
protected GridDBService m_gridDBService;
|
protected GridDBService m_gridDBService;
|
||||||
protected IUGAIMCore m_gridCore;
|
protected IUGAIMCore m_gridCore;
|
||||||
|
|
||||||
protected GridConfig m_config;
|
protected GridConfig m_config;
|
||||||
|
|
||||||
/// <value>
|
/// <value>
|
||||||
/// Used to notify old regions as to which OpenSim version to upgrade to
|
/// Used to notify old regions as to which OpenSim version to upgrade to
|
||||||
/// </value>
|
/// </value>
|
||||||
private string m_opensimVersion;
|
private string m_opensimVersion;
|
||||||
|
|
||||||
protected BaseHttpServer m_httpServer;
|
protected BaseHttpServer m_httpServer;
|
||||||
|
|
||||||
// This is here so that the grid server can hand out MessageServer settings to regions on registration
|
// This is here so that the grid server can hand out MessageServer settings to regions on registration
|
||||||
private List<MessageServerInfo> _MessageServers = new List<MessageServerInfo>();
|
private List<MessageServerInfo> _MessageServers = new List<MessageServerInfo>();
|
||||||
|
|
||||||
public List<MessageServerInfo> MessageServers
|
public List<MessageServerInfo> MessageServers
|
||||||
{
|
{
|
||||||
get { return _MessageServers; }
|
get { return _MessageServers; }
|
||||||
}
|
}
|
||||||
|
|
||||||
public GridMessagingModule()
|
public GridMessagingModule()
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
public void Initialise(string opensimVersion, GridDBService gridDBService, IUGAIMCore gridCore, GridConfig config)
|
public void Initialise(string opensimVersion, GridDBService gridDBService, IUGAIMCore gridCore, GridConfig config)
|
||||||
{
|
{
|
||||||
m_opensimVersion = opensimVersion;
|
m_opensimVersion = opensimVersion;
|
||||||
m_gridDBService = gridDBService;
|
m_gridDBService = gridDBService;
|
||||||
m_gridCore = gridCore;
|
m_gridCore = gridCore;
|
||||||
m_config = config;
|
m_config = config;
|
||||||
RegisterHandlers();
|
RegisterHandlers();
|
||||||
}
|
}
|
||||||
|
|
||||||
public void PostInitialise()
|
public void PostInitialise()
|
||||||
{
|
{
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public void RegisterHandlers()
|
public void RegisterHandlers()
|
||||||
{
|
{
|
||||||
//have these in separate method as some servers restart the http server and reregister all the handlers.
|
//have these in separate method as some servers restart the http server and reregister all the handlers.
|
||||||
m_httpServer = m_gridCore.GetHttpServer();
|
m_httpServer = m_gridCore.GetHttpServer();
|
||||||
|
|
||||||
m_gridCore.RegisterInterface<IGridMessagingModule>(this);
|
m_gridCore.RegisterInterface<IGridMessagingModule>(this);
|
||||||
// Message Server ---> Grid Server
|
// Message Server ---> Grid Server
|
||||||
m_httpServer.AddXmlRPCHandler("register_messageserver", XmlRPCRegisterMessageServer);
|
m_httpServer.AddXmlRPCHandler("register_messageserver", XmlRPCRegisterMessageServer);
|
||||||
m_httpServer.AddXmlRPCHandler("deregister_messageserver", XmlRPCDeRegisterMessageServer);
|
m_httpServer.AddXmlRPCHandler("deregister_messageserver", XmlRPCDeRegisterMessageServer);
|
||||||
}
|
}
|
||||||
|
|
||||||
public XmlRpcResponse XmlRPCRegisterMessageServer(XmlRpcRequest request)
|
public XmlRpcResponse XmlRPCRegisterMessageServer(XmlRpcRequest request)
|
||||||
{
|
{
|
||||||
XmlRpcResponse response = new XmlRpcResponse();
|
XmlRpcResponse response = new XmlRpcResponse();
|
||||||
Hashtable requestData = (Hashtable)request.Params[0];
|
Hashtable requestData = (Hashtable)request.Params[0];
|
||||||
Hashtable responseData = new Hashtable();
|
Hashtable responseData = new Hashtable();
|
||||||
|
|
||||||
if (requestData.Contains("uri"))
|
if (requestData.Contains("uri"))
|
||||||
{
|
{
|
||||||
string URI = (string)requestData["URI"];
|
string URI = (string)requestData["URI"];
|
||||||
string sendkey = (string)requestData["sendkey"];
|
string sendkey = (string)requestData["sendkey"];
|
||||||
string recvkey = (string)requestData["recvkey"];
|
string recvkey = (string)requestData["recvkey"];
|
||||||
MessageServerInfo m = new MessageServerInfo();
|
MessageServerInfo m = new MessageServerInfo();
|
||||||
m.URI = URI;
|
m.URI = URI;
|
||||||
m.sendkey = sendkey;
|
m.sendkey = sendkey;
|
||||||
m.recvkey = recvkey;
|
m.recvkey = recvkey;
|
||||||
if (!_MessageServers.Contains(m))
|
if (!_MessageServers.Contains(m))
|
||||||
_MessageServers.Add(m);
|
_MessageServers.Add(m);
|
||||||
responseData["responsestring"] = "TRUE";
|
responseData["responsestring"] = "TRUE";
|
||||||
response.Value = responseData;
|
response.Value = responseData;
|
||||||
}
|
}
|
||||||
return response;
|
return response;
|
||||||
}
|
}
|
||||||
|
|
||||||
public XmlRpcResponse XmlRPCDeRegisterMessageServer(XmlRpcRequest request)
|
public XmlRpcResponse XmlRPCDeRegisterMessageServer(XmlRpcRequest request)
|
||||||
{
|
{
|
||||||
XmlRpcResponse response = new XmlRpcResponse();
|
XmlRpcResponse response = new XmlRpcResponse();
|
||||||
Hashtable requestData = (Hashtable)request.Params[0];
|
Hashtable requestData = (Hashtable)request.Params[0];
|
||||||
Hashtable responseData = new Hashtable();
|
Hashtable responseData = new Hashtable();
|
||||||
|
|
||||||
if (requestData.Contains("uri"))
|
if (requestData.Contains("uri"))
|
||||||
{
|
{
|
||||||
string URI = (string)requestData["uri"];
|
string URI = (string)requestData["uri"];
|
||||||
string sendkey = (string)requestData["sendkey"];
|
string sendkey = (string)requestData["sendkey"];
|
||||||
string recvkey = (string)requestData["recvkey"];
|
string recvkey = (string)requestData["recvkey"];
|
||||||
MessageServerInfo m = new MessageServerInfo();
|
MessageServerInfo m = new MessageServerInfo();
|
||||||
m.URI = URI;
|
m.URI = URI;
|
||||||
m.sendkey = sendkey;
|
m.sendkey = sendkey;
|
||||||
m.recvkey = recvkey;
|
m.recvkey = recvkey;
|
||||||
if (_MessageServers.Contains(m))
|
if (_MessageServers.Contains(m))
|
||||||
_MessageServers.Remove(m);
|
_MessageServers.Remove(m);
|
||||||
responseData["responsestring"] = "TRUE";
|
responseData["responsestring"] = "TRUE";
|
||||||
response.Value = responseData;
|
response.Value = responseData;
|
||||||
}
|
}
|
||||||
return response;
|
return response;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,281 +1,281 @@
|
||||||
/*
|
/*
|
||||||
* Copyright (c) Contributors, http://opensimulator.org/
|
* Copyright (c) Contributors, http://opensimulator.org/
|
||||||
* See CONTRIBUTORS.TXT for a full list of copyright holders.
|
* See CONTRIBUTORS.TXT for a full list of copyright holders.
|
||||||
*
|
*
|
||||||
* Redistribution and use in source and binary forms, with or without
|
* Redistribution and use in source and binary forms, with or without
|
||||||
* modification, are permitted provided that the following conditions are met:
|
* modification, are permitted provided that the following conditions are met:
|
||||||
* * Redistributions of source code must retain the above copyright
|
* * Redistributions of source code must retain the above copyright
|
||||||
* notice, this list of conditions and the following disclaimer.
|
* notice, this list of conditions and the following disclaimer.
|
||||||
* * Redistributions in binary form must reproduce the above copyright
|
* * Redistributions in binary form must reproduce the above copyright
|
||||||
* notice, this list of conditions and the following disclaimer in the
|
* notice, this list of conditions and the following disclaimer in the
|
||||||
* documentation and/or other materials provided with the distribution.
|
* documentation and/or other materials provided with the distribution.
|
||||||
* * Neither the name of the OpenSim Project nor the
|
* * Neither the name of the OpenSim Project nor the
|
||||||
* names of its contributors may be used to endorse or promote products
|
* names of its contributors may be used to endorse or promote products
|
||||||
* derived from this software without specific prior written permission.
|
* derived from this software without specific prior written permission.
|
||||||
*
|
*
|
||||||
* THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS'' AND ANY
|
* THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS'' AND ANY
|
||||||
* EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
|
* EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
|
||||||
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
||||||
* DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY
|
* DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY
|
||||||
* DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
|
* DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
|
||||||
* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
|
* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
|
||||||
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
|
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
|
||||||
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||||
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
|
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
|
||||||
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
using System;
|
using System;
|
||||||
using System.Collections;
|
using System.Collections;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using System.IO;
|
using System.IO;
|
||||||
using System.Reflection;
|
using System.Reflection;
|
||||||
using System.Xml;
|
using System.Xml;
|
||||||
using log4net;
|
using log4net;
|
||||||
using OpenMetaverse;
|
using OpenMetaverse;
|
||||||
using OpenSim.Data;
|
using OpenSim.Data;
|
||||||
using OpenSim.Framework;
|
using OpenSim.Framework;
|
||||||
using OpenSim.Framework.Communications;
|
using OpenSim.Framework.Communications;
|
||||||
using OpenSim.Framework.Servers;
|
using OpenSim.Framework.Servers;
|
||||||
|
|
||||||
namespace OpenSim.Grid.GridServer
|
namespace OpenSim.Grid.GridServer
|
||||||
{
|
{
|
||||||
public class GridRestModule
|
public class GridRestModule
|
||||||
{
|
{
|
||||||
private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType);
|
private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType);
|
||||||
|
|
||||||
private GridDBService m_gridDBService;
|
private GridDBService m_gridDBService;
|
||||||
private IUGAIMCore m_gridCore;
|
private IUGAIMCore m_gridCore;
|
||||||
|
|
||||||
protected GridConfig m_config;
|
protected GridConfig m_config;
|
||||||
|
|
||||||
/// <value>
|
/// <value>
|
||||||
/// Used to notify old regions as to which OpenSim version to upgrade to
|
/// Used to notify old regions as to which OpenSim version to upgrade to
|
||||||
/// </value>
|
/// </value>
|
||||||
private string m_opensimVersion;
|
private string m_opensimVersion;
|
||||||
|
|
||||||
protected BaseHttpServer m_httpServer;
|
protected BaseHttpServer m_httpServer;
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Constructor
|
/// Constructor
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <param name="opensimVersion">
|
/// <param name="opensimVersion">
|
||||||
/// Used to notify old regions as to which OpenSim version to upgrade to
|
/// Used to notify old regions as to which OpenSim version to upgrade to
|
||||||
/// </param>
|
/// </param>
|
||||||
public GridRestModule()
|
public GridRestModule()
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
public void Initialise(string opensimVersion, GridDBService gridDBService, IUGAIMCore gridCore, GridConfig config)
|
public void Initialise(string opensimVersion, GridDBService gridDBService, IUGAIMCore gridCore, GridConfig config)
|
||||||
{
|
{
|
||||||
m_opensimVersion = opensimVersion;
|
m_opensimVersion = opensimVersion;
|
||||||
m_gridDBService = gridDBService;
|
m_gridDBService = gridDBService;
|
||||||
m_gridCore = gridCore;
|
m_gridCore = gridCore;
|
||||||
m_config = config;
|
m_config = config;
|
||||||
RegisterHandlers();
|
RegisterHandlers();
|
||||||
}
|
}
|
||||||
|
|
||||||
public void PostInitialise()
|
public void PostInitialise()
|
||||||
{
|
{
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public void RegisterHandlers()
|
public void RegisterHandlers()
|
||||||
{
|
{
|
||||||
//have these in separate method as some servers restart the http server and reregister all the handlers.
|
//have these in separate method as some servers restart the http server and reregister all the handlers.
|
||||||
m_httpServer = m_gridCore.GetHttpServer();
|
m_httpServer = m_gridCore.GetHttpServer();
|
||||||
|
|
||||||
m_httpServer.AddStreamHandler(new RestStreamHandler("GET", "/sims/", RestGetSimMethod));
|
m_httpServer.AddStreamHandler(new RestStreamHandler("GET", "/sims/", RestGetSimMethod));
|
||||||
m_httpServer.AddStreamHandler(new RestStreamHandler("POST", "/sims/", RestSetSimMethod));
|
m_httpServer.AddStreamHandler(new RestStreamHandler("POST", "/sims/", RestSetSimMethod));
|
||||||
|
|
||||||
m_httpServer.AddStreamHandler(new RestStreamHandler("GET", "/regions/", RestGetRegionMethod));
|
m_httpServer.AddStreamHandler(new RestStreamHandler("GET", "/regions/", RestGetRegionMethod));
|
||||||
m_httpServer.AddStreamHandler(new RestStreamHandler("POST", "/regions/", RestSetRegionMethod));
|
m_httpServer.AddStreamHandler(new RestStreamHandler("POST", "/regions/", RestSetRegionMethod));
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Performs a REST Get Operation
|
/// Performs a REST Get Operation
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <param name="request"></param>
|
/// <param name="request"></param>
|
||||||
/// <param name="path"></param>
|
/// <param name="path"></param>
|
||||||
/// <param name="param"></param>
|
/// <param name="param"></param>
|
||||||
/// <param name="httpRequest">HTTP request header object</param>
|
/// <param name="httpRequest">HTTP request header object</param>
|
||||||
/// <param name="httpResponse">HTTP response header object</param>
|
/// <param name="httpResponse">HTTP response header object</param>
|
||||||
/// <returns></returns>
|
/// <returns></returns>
|
||||||
public string RestGetRegionMethod(string request, string path, string param,
|
public string RestGetRegionMethod(string request, string path, string param,
|
||||||
OSHttpRequest httpRequest, OSHttpResponse httpResponse)
|
OSHttpRequest httpRequest, OSHttpResponse httpResponse)
|
||||||
{
|
{
|
||||||
return RestGetSimMethod(String.Empty, "/sims/", param, httpRequest, httpResponse);
|
return RestGetSimMethod(String.Empty, "/sims/", param, httpRequest, httpResponse);
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Performs a REST Set Operation
|
/// Performs a REST Set Operation
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <param name="request"></param>
|
/// <param name="request"></param>
|
||||||
/// <param name="path"></param>
|
/// <param name="path"></param>
|
||||||
/// <param name="param"></param>
|
/// <param name="param"></param>
|
||||||
/// <param name="httpRequest">HTTP request header object</param>
|
/// <param name="httpRequest">HTTP request header object</param>
|
||||||
/// <param name="httpResponse">HTTP response header object</param>
|
/// <param name="httpResponse">HTTP response header object</param>
|
||||||
/// <returns></returns>
|
/// <returns></returns>
|
||||||
public string RestSetRegionMethod(string request, string path, string param,
|
public string RestSetRegionMethod(string request, string path, string param,
|
||||||
OSHttpRequest httpRequest, OSHttpResponse httpResponse)
|
OSHttpRequest httpRequest, OSHttpResponse httpResponse)
|
||||||
{
|
{
|
||||||
return RestSetSimMethod(String.Empty, "/sims/", param, httpRequest, httpResponse);
|
return RestSetSimMethod(String.Empty, "/sims/", param, httpRequest, httpResponse);
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Returns information about a sim via a REST Request
|
/// Returns information about a sim via a REST Request
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <param name="request"></param>
|
/// <param name="request"></param>
|
||||||
/// <param name="path"></param>
|
/// <param name="path"></param>
|
||||||
/// <param name="param">A string representing the sim's UUID</param>
|
/// <param name="param">A string representing the sim's UUID</param>
|
||||||
/// <param name="httpRequest">HTTP request header object</param>
|
/// <param name="httpRequest">HTTP request header object</param>
|
||||||
/// <param name="httpResponse">HTTP response header object</param>
|
/// <param name="httpResponse">HTTP response header object</param>
|
||||||
/// <returns>Information about the sim in XML</returns>
|
/// <returns>Information about the sim in XML</returns>
|
||||||
public string RestGetSimMethod(string request, string path, string param,
|
public string RestGetSimMethod(string request, string path, string param,
|
||||||
OSHttpRequest httpRequest, OSHttpResponse httpResponse)
|
OSHttpRequest httpRequest, OSHttpResponse httpResponse)
|
||||||
{
|
{
|
||||||
string respstring = String.Empty;
|
string respstring = String.Empty;
|
||||||
|
|
||||||
RegionProfileData TheSim;
|
RegionProfileData TheSim;
|
||||||
|
|
||||||
UUID UUID;
|
UUID UUID;
|
||||||
if (UUID.TryParse(param, out UUID))
|
if (UUID.TryParse(param, out UUID))
|
||||||
{
|
{
|
||||||
TheSim = m_gridDBService.GetRegion(UUID);
|
TheSim = m_gridDBService.GetRegion(UUID);
|
||||||
|
|
||||||
if (!(TheSim == null))
|
if (!(TheSim == null))
|
||||||
{
|
{
|
||||||
respstring = "<Root>";
|
respstring = "<Root>";
|
||||||
respstring += "<authkey>" + TheSim.regionSendKey + "</authkey>";
|
respstring += "<authkey>" + TheSim.regionSendKey + "</authkey>";
|
||||||
respstring += "<sim>";
|
respstring += "<sim>";
|
||||||
respstring += "<uuid>" + TheSim.UUID.ToString() + "</uuid>";
|
respstring += "<uuid>" + TheSim.UUID.ToString() + "</uuid>";
|
||||||
respstring += "<regionname>" + TheSim.regionName + "</regionname>";
|
respstring += "<regionname>" + TheSim.regionName + "</regionname>";
|
||||||
respstring += "<sim_ip>" + TheSim.serverIP + "</sim_ip>";
|
respstring += "<sim_ip>" + TheSim.serverIP + "</sim_ip>";
|
||||||
respstring += "<sim_port>" + TheSim.serverPort.ToString() + "</sim_port>";
|
respstring += "<sim_port>" + TheSim.serverPort.ToString() + "</sim_port>";
|
||||||
respstring += "<region_locx>" + TheSim.regionLocX.ToString() + "</region_locx>";
|
respstring += "<region_locx>" + TheSim.regionLocX.ToString() + "</region_locx>";
|
||||||
respstring += "<region_locy>" + TheSim.regionLocY.ToString() + "</region_locy>";
|
respstring += "<region_locy>" + TheSim.regionLocY.ToString() + "</region_locy>";
|
||||||
respstring += "<estate_id>1</estate_id>";
|
respstring += "<estate_id>1</estate_id>";
|
||||||
respstring += "</sim>";
|
respstring += "</sim>";
|
||||||
respstring += "</Root>";
|
respstring += "</Root>";
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
respstring = "<Root>";
|
respstring = "<Root>";
|
||||||
respstring += "<error>Param must be a UUID</error>";
|
respstring += "<error>Param must be a UUID</error>";
|
||||||
respstring += "</Root>";
|
respstring += "</Root>";
|
||||||
}
|
}
|
||||||
|
|
||||||
return respstring;
|
return respstring;
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Creates or updates a sim via a REST Method Request
|
/// Creates or updates a sim via a REST Method Request
|
||||||
/// BROKEN with SQL Update
|
/// BROKEN with SQL Update
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <param name="request"></param>
|
/// <param name="request"></param>
|
||||||
/// <param name="path"></param>
|
/// <param name="path"></param>
|
||||||
/// <param name="param"></param>
|
/// <param name="param"></param>
|
||||||
/// <param name="httpRequest">HTTP request header object</param>
|
/// <param name="httpRequest">HTTP request header object</param>
|
||||||
/// <param name="httpResponse">HTTP response header object</param>
|
/// <param name="httpResponse">HTTP response header object</param>
|
||||||
/// <returns>"OK" or an error</returns>
|
/// <returns>"OK" or an error</returns>
|
||||||
public string RestSetSimMethod(string request, string path, string param,
|
public string RestSetSimMethod(string request, string path, string param,
|
||||||
OSHttpRequest httpRequest, OSHttpResponse httpResponse)
|
OSHttpRequest httpRequest, OSHttpResponse httpResponse)
|
||||||
{
|
{
|
||||||
Console.WriteLine("Processing region update via REST method");
|
Console.WriteLine("Processing region update via REST method");
|
||||||
RegionProfileData theSim;
|
RegionProfileData theSim;
|
||||||
theSim = m_gridDBService.GetRegion(new UUID(param));
|
theSim = m_gridDBService.GetRegion(new UUID(param));
|
||||||
if (theSim == null)
|
if (theSim == null)
|
||||||
{
|
{
|
||||||
theSim = new RegionProfileData();
|
theSim = new RegionProfileData();
|
||||||
UUID UUID = new UUID(param);
|
UUID UUID = new UUID(param);
|
||||||
theSim.UUID = UUID;
|
theSim.UUID = UUID;
|
||||||
theSim.regionRecvKey = m_config.SimRecvKey;
|
theSim.regionRecvKey = m_config.SimRecvKey;
|
||||||
}
|
}
|
||||||
|
|
||||||
XmlDocument doc = new XmlDocument();
|
XmlDocument doc = new XmlDocument();
|
||||||
doc.LoadXml(request);
|
doc.LoadXml(request);
|
||||||
XmlNode rootnode = doc.FirstChild;
|
XmlNode rootnode = doc.FirstChild;
|
||||||
XmlNode authkeynode = rootnode.ChildNodes[0];
|
XmlNode authkeynode = rootnode.ChildNodes[0];
|
||||||
if (authkeynode.Name != "authkey")
|
if (authkeynode.Name != "authkey")
|
||||||
{
|
{
|
||||||
return "ERROR! bad XML - expected authkey tag";
|
return "ERROR! bad XML - expected authkey tag";
|
||||||
}
|
}
|
||||||
|
|
||||||
XmlNode simnode = rootnode.ChildNodes[1];
|
XmlNode simnode = rootnode.ChildNodes[1];
|
||||||
if (simnode.Name != "sim")
|
if (simnode.Name != "sim")
|
||||||
{
|
{
|
||||||
return "ERROR! bad XML - expected sim tag";
|
return "ERROR! bad XML - expected sim tag";
|
||||||
}
|
}
|
||||||
|
|
||||||
//theSim.regionSendKey = Cfg;
|
//theSim.regionSendKey = Cfg;
|
||||||
theSim.regionRecvKey = m_config.SimRecvKey;
|
theSim.regionRecvKey = m_config.SimRecvKey;
|
||||||
theSim.regionSendKey = m_config.SimSendKey;
|
theSim.regionSendKey = m_config.SimSendKey;
|
||||||
theSim.regionSecret = m_config.SimRecvKey;
|
theSim.regionSecret = m_config.SimRecvKey;
|
||||||
theSim.regionDataURI = String.Empty;
|
theSim.regionDataURI = String.Empty;
|
||||||
theSim.regionAssetURI = m_config.DefaultAssetServer;
|
theSim.regionAssetURI = m_config.DefaultAssetServer;
|
||||||
theSim.regionAssetRecvKey = m_config.AssetRecvKey;
|
theSim.regionAssetRecvKey = m_config.AssetRecvKey;
|
||||||
theSim.regionAssetSendKey = m_config.AssetSendKey;
|
theSim.regionAssetSendKey = m_config.AssetSendKey;
|
||||||
theSim.regionUserURI = m_config.DefaultUserServer;
|
theSim.regionUserURI = m_config.DefaultUserServer;
|
||||||
theSim.regionUserSendKey = m_config.UserSendKey;
|
theSim.regionUserSendKey = m_config.UserSendKey;
|
||||||
theSim.regionUserRecvKey = m_config.UserRecvKey;
|
theSim.regionUserRecvKey = m_config.UserRecvKey;
|
||||||
|
|
||||||
for (int i = 0; i < simnode.ChildNodes.Count; i++)
|
for (int i = 0; i < simnode.ChildNodes.Count; i++)
|
||||||
{
|
{
|
||||||
switch (simnode.ChildNodes[i].Name)
|
switch (simnode.ChildNodes[i].Name)
|
||||||
{
|
{
|
||||||
case "regionname":
|
case "regionname":
|
||||||
theSim.regionName = simnode.ChildNodes[i].InnerText;
|
theSim.regionName = simnode.ChildNodes[i].InnerText;
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case "sim_ip":
|
case "sim_ip":
|
||||||
theSim.serverIP = simnode.ChildNodes[i].InnerText;
|
theSim.serverIP = simnode.ChildNodes[i].InnerText;
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case "sim_port":
|
case "sim_port":
|
||||||
theSim.serverPort = Convert.ToUInt32(simnode.ChildNodes[i].InnerText);
|
theSim.serverPort = Convert.ToUInt32(simnode.ChildNodes[i].InnerText);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case "region_locx":
|
case "region_locx":
|
||||||
theSim.regionLocX = Convert.ToUInt32((string)simnode.ChildNodes[i].InnerText);
|
theSim.regionLocX = Convert.ToUInt32((string)simnode.ChildNodes[i].InnerText);
|
||||||
theSim.regionHandle = Utils.UIntsToLong((theSim.regionLocX * Constants.RegionSize), (theSim.regionLocY * Constants.RegionSize));
|
theSim.regionHandle = Utils.UIntsToLong((theSim.regionLocX * Constants.RegionSize), (theSim.regionLocY * Constants.RegionSize));
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case "region_locy":
|
case "region_locy":
|
||||||
theSim.regionLocY = Convert.ToUInt32((string)simnode.ChildNodes[i].InnerText);
|
theSim.regionLocY = Convert.ToUInt32((string)simnode.ChildNodes[i].InnerText);
|
||||||
theSim.regionHandle = Utils.UIntsToLong((theSim.regionLocX * Constants.RegionSize), (theSim.regionLocY * Constants.RegionSize));
|
theSim.regionHandle = Utils.UIntsToLong((theSim.regionLocX * Constants.RegionSize), (theSim.regionLocY * Constants.RegionSize));
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
theSim.serverURI = "http://" + theSim.serverIP + ":" + theSim.serverPort + "/";
|
theSim.serverURI = "http://" + theSim.serverIP + ":" + theSim.serverPort + "/";
|
||||||
bool requirePublic = false;
|
bool requirePublic = false;
|
||||||
bool requireValid = true;
|
bool requireValid = true;
|
||||||
|
|
||||||
if (requirePublic &&
|
if (requirePublic &&
|
||||||
(theSim.serverIP.StartsWith("172.16") || theSim.serverIP.StartsWith("192.168") ||
|
(theSim.serverIP.StartsWith("172.16") || theSim.serverIP.StartsWith("192.168") ||
|
||||||
theSim.serverIP.StartsWith("10.") || theSim.serverIP.StartsWith("0.") ||
|
theSim.serverIP.StartsWith("10.") || theSim.serverIP.StartsWith("0.") ||
|
||||||
theSim.serverIP.StartsWith("255.")))
|
theSim.serverIP.StartsWith("255.")))
|
||||||
{
|
{
|
||||||
return "ERROR! Servers must register with public addresses.";
|
return "ERROR! Servers must register with public addresses.";
|
||||||
}
|
}
|
||||||
|
|
||||||
if (requireValid && (theSim.serverIP.StartsWith("0.") || theSim.serverIP.StartsWith("255.")))
|
if (requireValid && (theSim.serverIP.StartsWith("0.") || theSim.serverIP.StartsWith("255.")))
|
||||||
{
|
{
|
||||||
return "ERROR! 0.*.*.* / 255.*.*.* Addresses are invalid, please check your server config and try again";
|
return "ERROR! 0.*.*.* / 255.*.*.* Addresses are invalid, please check your server config and try again";
|
||||||
}
|
}
|
||||||
|
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
m_log.Info("[DATA]: " +
|
m_log.Info("[DATA]: " +
|
||||||
"Updating / adding via " + m_gridDBService.GetNumberOfPlugins() + " storage provider(s) registered.");
|
"Updating / adding via " + m_gridDBService.GetNumberOfPlugins() + " storage provider(s) registered.");
|
||||||
|
|
||||||
return m_gridDBService.CheckReservations(theSim, authkeynode);
|
return m_gridDBService.CheckReservations(theSim, authkeynode);
|
||||||
}
|
}
|
||||||
catch (Exception e)
|
catch (Exception e)
|
||||||
{
|
{
|
||||||
return "ERROR! Could not save to database! (" + e.ToString() + ")";
|
return "ERROR! Could not save to database! (" + e.ToString() + ")";
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
File diff suppressed because it is too large
Load Diff
|
@ -1,11 +1,38 @@
|
||||||
using System;
|
/*
|
||||||
using System.Collections.Generic;
|
* Copyright (c) Contributors, http://opensimulator.org/
|
||||||
using OpenSim.Framework.Servers;
|
* See CONTRIBUTORS.TXT for a full list of copyright holders.
|
||||||
|
*
|
||||||
namespace OpenSim.Grid.GridServer
|
* Redistribution and use in source and binary forms, with or without
|
||||||
{
|
* modification, are permitted provided that the following conditions are met:
|
||||||
public interface IGridMessagingModule
|
* * Redistributions of source code must retain the above copyright
|
||||||
{
|
* notice, this list of conditions and the following disclaimer.
|
||||||
List<MessageServerInfo> MessageServers { get; }
|
* * Redistributions in binary form must reproduce the above copyright
|
||||||
}
|
* notice, this list of conditions and the following disclaimer in the
|
||||||
}
|
* documentation and/or other materials provided with the distribution.
|
||||||
|
* * Neither the name of the OpenSimulator Project nor the
|
||||||
|
* names of its contributors may be used to endorse or promote products
|
||||||
|
* derived from this software without specific prior written permission.
|
||||||
|
*
|
||||||
|
* THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS'' AND ANY
|
||||||
|
* EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
|
||||||
|
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
||||||
|
* DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY
|
||||||
|
* DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
|
||||||
|
* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
|
||||||
|
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
|
||||||
|
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||||
|
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
|
||||||
|
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||||
|
*/
|
||||||
|
|
||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using OpenSim.Framework.Servers;
|
||||||
|
|
||||||
|
namespace OpenSim.Grid.GridServer
|
||||||
|
{
|
||||||
|
public interface IGridMessagingModule
|
||||||
|
{
|
||||||
|
List<MessageServerInfo> MessageServers { get; }
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
|
@ -1,13 +1,40 @@
|
||||||
using System;
|
/*
|
||||||
using OpenSim.Framework.Servers;
|
* Copyright (c) Contributors, http://opensimulator.org/
|
||||||
|
* See CONTRIBUTORS.TXT for a full list of copyright holders.
|
||||||
namespace OpenSim.Grid.GridServer
|
*
|
||||||
{
|
* Redistribution and use in source and binary forms, with or without
|
||||||
public interface IUGAIMCore
|
* modification, are permitted provided that the following conditions are met:
|
||||||
{
|
* * Redistributions of source code must retain the above copyright
|
||||||
T Get<T>();
|
* notice, this list of conditions and the following disclaimer.
|
||||||
void RegisterInterface<T>(T iface);
|
* * Redistributions in binary form must reproduce the above copyright
|
||||||
bool TryGet<T>(out T iface);
|
* notice, this list of conditions and the following disclaimer in the
|
||||||
BaseHttpServer GetHttpServer();
|
* documentation and/or other materials provided with the distribution.
|
||||||
}
|
* * Neither the name of the OpenSimulator Project nor the
|
||||||
}
|
* names of its contributors may be used to endorse or promote products
|
||||||
|
* derived from this software without specific prior written permission.
|
||||||
|
*
|
||||||
|
* THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS'' AND ANY
|
||||||
|
* EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
|
||||||
|
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
||||||
|
* DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY
|
||||||
|
* DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
|
||||||
|
* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
|
||||||
|
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
|
||||||
|
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||||
|
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
|
||||||
|
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||||
|
*/
|
||||||
|
|
||||||
|
using System;
|
||||||
|
using OpenSim.Framework.Servers;
|
||||||
|
|
||||||
|
namespace OpenSim.Grid.GridServer
|
||||||
|
{
|
||||||
|
public interface IUGAIMCore
|
||||||
|
{
|
||||||
|
T Get<T>();
|
||||||
|
void RegisterInterface<T>(T iface);
|
||||||
|
bool TryGet<T>(out T iface);
|
||||||
|
BaseHttpServer GetHttpServer();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
|
@ -404,11 +404,11 @@ namespace OpenSim
|
||||||
// Allow absolute and relative specifiers
|
// Allow absolute and relative specifiers
|
||||||
if (cmd[3].StartsWith("/") || cmd[3].StartsWith("\\") || cmd[3].StartsWith("..") || cmd[3].EndsWith(".xml"))
|
if (cmd[3].StartsWith("/") || cmd[3].StartsWith("\\") || cmd[3].StartsWith("..") || cmd[3].EndsWith(".xml"))
|
||||||
regionFile = cmd[3];
|
regionFile = cmd[3];
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
m_console.Error("Usage: create region <region name> <region_file.xml>");
|
m_console.Error("Usage: create region <region name> <region_file.xml>");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
CreateRegion(new RegionInfo(cmd[2], regionFile, false, ConfigSource.Source), true);
|
CreateRegion(new RegionInfo(cmd[2], regionFile, false, ConfigSource.Source), true);
|
||||||
}
|
}
|
||||||
|
|
|
@ -229,10 +229,10 @@ namespace OpenSim.Region.CoreModules.Scripting.VectorRender
|
||||||
alpha = temp;
|
alpha = temp;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
// Allow a bitmap w/o the alpha component to be created
|
// Allow a bitmap w/o the alpha component to be created
|
||||||
else if (value.ToLower() == "false") {
|
else if (value.ToLower() == "false") {
|
||||||
alpha = 256;
|
alpha = 256;
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case "bgcolour":
|
case "bgcolour":
|
||||||
int hex = 0;
|
int hex = 0;
|
||||||
|
@ -276,16 +276,16 @@ namespace OpenSim.Region.CoreModules.Scripting.VectorRender
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
Bitmap bitmap;
|
Bitmap bitmap;
|
||||||
|
|
||||||
if ( alpha == 256 )
|
if (alpha == 256)
|
||||||
{
|
{
|
||||||
bitmap = new Bitmap(width, height, PixelFormat.Format32bppRgb);
|
bitmap = new Bitmap(width, height, PixelFormat.Format32bppRgb);
|
||||||
}
|
}
|
||||||
else {
|
else
|
||||||
|
{
|
||||||
bitmap = new Bitmap(width, height, PixelFormat.Format32bppArgb);
|
bitmap = new Bitmap(width, height, PixelFormat.Format32bppArgb);
|
||||||
}
|
}
|
||||||
|
|
||||||
Graphics graph = Graphics.FromImage(bitmap);
|
Graphics graph = Graphics.FromImage(bitmap);
|
||||||
|
|
||||||
|
@ -298,13 +298,13 @@ namespace OpenSim.Region.CoreModules.Scripting.VectorRender
|
||||||
|
|
||||||
for (int w = 0; w < bitmap.Width; w++)
|
for (int w = 0; w < bitmap.Width; w++)
|
||||||
{
|
{
|
||||||
if (alpha <= 255)
|
if (alpha <= 255)
|
||||||
{
|
{
|
||||||
for (int h = 0; h < bitmap.Height; h++)
|
for (int h = 0; h < bitmap.Height; h++)
|
||||||
{
|
{
|
||||||
bitmap.SetPixel(w, h, Color.FromArgb(alpha, bitmap.GetPixel(w, h)));
|
bitmap.SetPixel(w, h, Color.FromArgb(alpha, bitmap.GetPixel(w, h)));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
GDIDraw(data, graph);
|
GDIDraw(data, graph);
|
||||||
|
|
Loading…
Reference in New Issue