Remove The legacy inventory and asset servers. Bump interface version to 6
parent
88294d9ebf
commit
6779abf7f5
|
@ -1,205 +0,0 @@
|
||||||
/*
|
|
||||||
* Copyright (c) Contributors, http://opensimulator.org/
|
|
||||||
* See CONTRIBUTORS.TXT for a full list of copyright holders.
|
|
||||||
*
|
|
||||||
* Redistribution and use in source and binary forms, with or without
|
|
||||||
* modification, are permitted provided that the following conditions are met:
|
|
||||||
* * Redistributions of source code must retain the above copyright
|
|
||||||
* notice, this list of conditions and the following disclaimer.
|
|
||||||
* * 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 System.IO;
|
|
||||||
using System.Net;
|
|
||||||
using System.Reflection;
|
|
||||||
using System.Text;
|
|
||||||
using System.Text.RegularExpressions;
|
|
||||||
using System.Xml;
|
|
||||||
using System.Xml.Serialization;
|
|
||||||
using log4net;
|
|
||||||
using OpenMetaverse;
|
|
||||||
using OpenSim.Framework.Servers.HttpServer;
|
|
||||||
using OpenSim.Framework.Statistics;
|
|
||||||
|
|
||||||
namespace OpenSim.Framework.Servers
|
|
||||||
{
|
|
||||||
public abstract class BaseGetAssetStreamHandler : BaseStreamHandler
|
|
||||||
{
|
|
||||||
private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType);
|
|
||||||
|
|
||||||
protected BaseGetAssetStreamHandler(string httpMethod, string path) : base(httpMethod, path)
|
|
||||||
{
|
|
||||||
}
|
|
||||||
|
|
||||||
protected abstract AssetBase GetAsset(UUID assetID);
|
|
||||||
|
|
||||||
public override byte[] Handle(string path, Stream request,
|
|
||||||
OSHttpRequest httpRequest, OSHttpResponse httpResponse)
|
|
||||||
{
|
|
||||||
byte[] result = new byte[] { };
|
|
||||||
|
|
||||||
string[] p = SplitParams(path);
|
|
||||||
|
|
||||||
if (p.Length > 0)
|
|
||||||
{
|
|
||||||
UUID assetID;
|
|
||||||
|
|
||||||
if (!UUID.TryParse(p[0], out assetID))
|
|
||||||
{
|
|
||||||
m_log.DebugFormat(
|
|
||||||
"[REST]: GET:/asset ignoring request with malformed UUID {0}", p[0]);
|
|
||||||
return result;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (StatsManager.AssetStats != null)
|
|
||||||
{
|
|
||||||
StatsManager.AssetStats.AddRequest();
|
|
||||||
}
|
|
||||||
|
|
||||||
AssetBase asset = GetAsset(assetID);
|
|
||||||
|
|
||||||
if (asset != null)
|
|
||||||
{
|
|
||||||
if (p.Length > 1 && p[1] == "data")
|
|
||||||
{
|
|
||||||
httpResponse.StatusCode = (int)HttpStatusCode.OK;
|
|
||||||
httpResponse.ContentType = SLAssetTypeToContentType(asset.Type);
|
|
||||||
result = asset.Data;
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
result = GetXml(asset);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
m_log.DebugFormat("[REST]: GET:/asset failed to find {0}", assetID);
|
|
||||||
|
|
||||||
httpResponse.StatusCode = (int)HttpStatusCode.NotFound;
|
|
||||||
|
|
||||||
if (StatsManager.AssetStats != null)
|
|
||||||
{
|
|
||||||
StatsManager.AssetStats.AddNotFoundRequest();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
return result;
|
|
||||||
}
|
|
||||||
|
|
||||||
public static byte[] GetXml(AssetBase asset)
|
|
||||||
{
|
|
||||||
byte[] result;
|
|
||||||
XmlSerializer xs = new XmlSerializer(typeof(AssetBase));
|
|
||||||
MemoryStream ms = new MemoryStream();
|
|
||||||
XmlTextWriter xw = new XmlTextWriter(ms, Encoding.UTF8);
|
|
||||||
xw.Formatting = Formatting.Indented;
|
|
||||||
xs.Serialize(xw, asset);
|
|
||||||
xw.Flush();
|
|
||||||
|
|
||||||
ms.Seek(0, SeekOrigin.Begin);
|
|
||||||
//StreamReader sr = new StreamReader(ms);
|
|
||||||
|
|
||||||
result = ms.GetBuffer();
|
|
||||||
|
|
||||||
Array.Resize<byte>(ref result, (int)ms.Length);
|
|
||||||
return result;
|
|
||||||
}
|
|
||||||
|
|
||||||
public string ProcessAssetDataString(string data)
|
|
||||||
{
|
|
||||||
Regex regex = new Regex("(creator_id|owner_id)\\s+(\\S+)");
|
|
||||||
|
|
||||||
// IUserService userService = null;
|
|
||||||
|
|
||||||
data = regex.Replace(data, delegate(Match m)
|
|
||||||
{
|
|
||||||
string result = String.Empty;
|
|
||||||
|
|
||||||
// string key = m.Groups[1].Captures[0].Value;
|
|
||||||
//
|
|
||||||
// string value = m.Groups[2].Captures[0].Value;
|
|
||||||
//
|
|
||||||
// Guid userUri;
|
|
||||||
//
|
|
||||||
// switch (key)
|
|
||||||
// {
|
|
||||||
// case "creator_id":
|
|
||||||
// userUri = new Guid(value);
|
|
||||||
// // result = "creator_url " + userService(userService, userUri);
|
|
||||||
// break;
|
|
||||||
//
|
|
||||||
// case "owner_id":
|
|
||||||
// userUri = new Guid(value);
|
|
||||||
// // result = "owner_url " + ResolveUserUri(userService, userUri);
|
|
||||||
// break;
|
|
||||||
// }
|
|
||||||
|
|
||||||
return result;
|
|
||||||
});
|
|
||||||
|
|
||||||
return data;
|
|
||||||
}
|
|
||||||
|
|
||||||
private string SLAssetTypeToContentType(int assetType)
|
|
||||||
{
|
|
||||||
switch (assetType)
|
|
||||||
{
|
|
||||||
case 0:
|
|
||||||
return "image/jp2";
|
|
||||||
case 1:
|
|
||||||
return "application/ogg";
|
|
||||||
case 2:
|
|
||||||
return "application/x-metaverse-callingcard";
|
|
||||||
case 3:
|
|
||||||
return "application/x-metaverse-landmark";
|
|
||||||
case 5:
|
|
||||||
return "application/x-metaverse-clothing";
|
|
||||||
case 6:
|
|
||||||
return "application/x-metaverse-primitive";
|
|
||||||
case 7:
|
|
||||||
return "application/x-metaverse-notecard";
|
|
||||||
case 8:
|
|
||||||
return "application/x-metaverse-folder";
|
|
||||||
case 10:
|
|
||||||
return "application/x-metaverse-lsl";
|
|
||||||
case 11:
|
|
||||||
return "application/x-metaverse-lso";
|
|
||||||
case 12:
|
|
||||||
return "image/tga";
|
|
||||||
case 13:
|
|
||||||
return "application/x-metaverse-bodypart";
|
|
||||||
case 17:
|
|
||||||
return "audio/x-wav";
|
|
||||||
case 19:
|
|
||||||
return "image/jpeg";
|
|
||||||
case 20:
|
|
||||||
return "application/x-metaverse-animation";
|
|
||||||
case 21:
|
|
||||||
return "application/x-metaverse-gesture";
|
|
||||||
case 22:
|
|
||||||
return "application/x-metaverse-simstate";
|
|
||||||
default:
|
|
||||||
return "application/octet-stream";
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -1,63 +0,0 @@
|
||||||
/*
|
|
||||||
* Copyright (c) Contributors, http://opensimulator.org/
|
|
||||||
* See CONTRIBUTORS.TXT for a full list of copyright holders.
|
|
||||||
*
|
|
||||||
* Redistribution and use in source and binary forms, with or without
|
|
||||||
* modification, are permitted provided that the following conditions are met:
|
|
||||||
* * Redistributions of source code must retain the above copyright
|
|
||||||
* notice, this list of conditions and the following disclaimer.
|
|
||||||
* * 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.IO;
|
|
||||||
using System.Reflection;
|
|
||||||
using System.Text;
|
|
||||||
using System.Text.RegularExpressions;
|
|
||||||
using System.Xml;
|
|
||||||
using System.Xml.Serialization;
|
|
||||||
using log4net;
|
|
||||||
using OpenMetaverse;
|
|
||||||
using OpenSim.Data;
|
|
||||||
using OpenSim.Framework;
|
|
||||||
using OpenSim.Framework.Servers;
|
|
||||||
using OpenSim.Framework.Servers.HttpServer;
|
|
||||||
using OpenSim.Framework.Statistics;
|
|
||||||
using System.Net;
|
|
||||||
|
|
||||||
namespace OpenSim.Framework.Servers
|
|
||||||
{
|
|
||||||
public class GetAssetStreamHandler : BaseGetAssetStreamHandler
|
|
||||||
{
|
|
||||||
// private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType);
|
|
||||||
|
|
||||||
private readonly IAssetDataPlugin m_assetProvider;
|
|
||||||
|
|
||||||
public GetAssetStreamHandler(IAssetDataPlugin assetProvider)
|
|
||||||
: base("GET", "/assets")
|
|
||||||
{
|
|
||||||
m_assetProvider = assetProvider;
|
|
||||||
}
|
|
||||||
|
|
||||||
protected override AssetBase GetAsset(UUID assetID)
|
|
||||||
{
|
|
||||||
return m_assetProvider.GetAsset(assetID);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -1,72 +0,0 @@
|
||||||
/*
|
|
||||||
* Copyright (c) Contributors, http://opensimulator.org/
|
|
||||||
* See CONTRIBUTORS.TXT for a full list of copyright holders.
|
|
||||||
*
|
|
||||||
* Redistribution and use in source and binary forms, with or without
|
|
||||||
* modification, are permitted provided that the following conditions are met:
|
|
||||||
* * Redistributions of source code must retain the above copyright
|
|
||||||
* notice, this list of conditions and the following disclaimer.
|
|
||||||
* * 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.IO;
|
|
||||||
using System.Reflection;
|
|
||||||
using System.Xml.Serialization;
|
|
||||||
using log4net;
|
|
||||||
using OpenMetaverse;
|
|
||||||
using OpenSim.Data;
|
|
||||||
using OpenSim.Framework;
|
|
||||||
using OpenSim.Framework.Servers.HttpServer;
|
|
||||||
|
|
||||||
namespace OpenSim.Framework.Servers
|
|
||||||
{
|
|
||||||
public class PostAssetStreamHandler : BaseStreamHandler
|
|
||||||
{
|
|
||||||
private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType);
|
|
||||||
|
|
||||||
// private OpenAsset_Main m_assetManager;
|
|
||||||
private IAssetDataPlugin m_assetProvider;
|
|
||||||
|
|
||||||
public override byte[] Handle(string path, Stream request,
|
|
||||||
OSHttpRequest httpRequest, OSHttpResponse httpResponse)
|
|
||||||
{
|
|
||||||
string param = GetParam(path);
|
|
||||||
|
|
||||||
UUID assetId;
|
|
||||||
if (param.Length > 0)
|
|
||||||
UUID.TryParse(param, out assetId);
|
|
||||||
// byte[] txBuffer = new byte[4096];
|
|
||||||
|
|
||||||
XmlSerializer xs = new XmlSerializer(typeof (AssetBase));
|
|
||||||
AssetBase asset = (AssetBase) xs.Deserialize(request);
|
|
||||||
|
|
||||||
m_log.InfoFormat("[REST]: Creating asset {0}", asset.FullID);
|
|
||||||
m_assetProvider.StoreAsset(asset);
|
|
||||||
|
|
||||||
return new byte[] {};
|
|
||||||
}
|
|
||||||
|
|
||||||
public PostAssetStreamHandler(IAssetDataPlugin assetProvider)
|
|
||||||
: base("POST", "/assets")
|
|
||||||
{
|
|
||||||
// m_assetManager = assetManager;
|
|
||||||
m_assetProvider = assetProvider;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -69,6 +69,6 @@ namespace OpenSim
|
||||||
/// of the code that is too old.
|
/// of the code that is too old.
|
||||||
///
|
///
|
||||||
/// </value>
|
/// </value>
|
||||||
public readonly static int MajorInterfaceVersion = 5;
|
public readonly static int MajorInterfaceVersion = 6;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,146 +0,0 @@
|
||||||
/*
|
|
||||||
* Copyright (c) Contributors, http://opensimulator.org/
|
|
||||||
* See CONTRIBUTORS.TXT for a full list of copyright holders.
|
|
||||||
*
|
|
||||||
* Redistribution and use in source and binary forms, with or without
|
|
||||||
* modification, are permitted provided that the following conditions are met:
|
|
||||||
* * Redistributions of source code must retain the above copyright
|
|
||||||
* notice, this list of conditions and the following disclaimer.
|
|
||||||
* * 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.IO;
|
|
||||||
using System.Reflection;
|
|
||||||
using log4net;
|
|
||||||
using log4net.Config;
|
|
||||||
using OpenMetaverse;
|
|
||||||
using OpenSim.Data;
|
|
||||||
using OpenSim.Framework;
|
|
||||||
using OpenSim.Framework.AssetLoader.Filesystem;
|
|
||||||
using OpenSim.Framework.Console;
|
|
||||||
using OpenSim.Framework.Servers;
|
|
||||||
using OpenSim.Framework.Servers.HttpServer;
|
|
||||||
using OpenSim.Framework.Statistics;
|
|
||||||
|
|
||||||
namespace OpenSim.Grid.AssetServer
|
|
||||||
{
|
|
||||||
/// <summary>
|
|
||||||
/// An asset server
|
|
||||||
/// </summary>
|
|
||||||
public class OpenAsset_Main : BaseOpenSimServer
|
|
||||||
{
|
|
||||||
private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType);
|
|
||||||
|
|
||||||
public static OpenAsset_Main assetserver;
|
|
||||||
|
|
||||||
// Temporarily hardcoded - should be a plugin
|
|
||||||
protected IAssetLoader assetLoader = new AssetLoaderFileSystem();
|
|
||||||
|
|
||||||
private IAssetDataPlugin m_assetProvider;
|
|
||||||
|
|
||||||
public static void Main(string[] args)
|
|
||||||
{
|
|
||||||
XmlConfigurator.Configure();
|
|
||||||
|
|
||||||
assetserver = new OpenAsset_Main();
|
|
||||||
assetserver.Startup();
|
|
||||||
|
|
||||||
assetserver.Work();
|
|
||||||
}
|
|
||||||
|
|
||||||
private void Work()
|
|
||||||
{
|
|
||||||
m_console.Output("Enter help for a list of commands");
|
|
||||||
|
|
||||||
while (true)
|
|
||||||
{
|
|
||||||
m_console.Prompt();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public OpenAsset_Main()
|
|
||||||
{
|
|
||||||
m_console = new LocalConsole("Asset");
|
|
||||||
|
|
||||||
MainConsole.Instance = m_console;
|
|
||||||
}
|
|
||||||
|
|
||||||
protected override void StartupSpecific()
|
|
||||||
{
|
|
||||||
AssetConfig config = new AssetConfig("ASSET SERVER", (Path.Combine(Util.configDir(), "AssetServer_Config.xml")));
|
|
||||||
|
|
||||||
m_log.Info("[ASSET]: Setting up asset DB");
|
|
||||||
setupDB(config);
|
|
||||||
|
|
||||||
m_log.Info("[ASSET]: Loading default asset set from '" + config.AssetSetsLocation + "'");
|
|
||||||
LoadDefaultAssets(config.AssetSetsLocation);
|
|
||||||
|
|
||||||
m_log.Info("[ASSET]: Starting HTTP process");
|
|
||||||
m_httpServer = new BaseHttpServer(config.HttpPort);
|
|
||||||
|
|
||||||
m_stats = StatsManager.StartCollectingAssetStats();
|
|
||||||
|
|
||||||
AddHttpHandlers();
|
|
||||||
|
|
||||||
m_httpServer.Start();
|
|
||||||
|
|
||||||
base.StartupSpecific();
|
|
||||||
}
|
|
||||||
|
|
||||||
protected void AddHttpHandlers()
|
|
||||||
{
|
|
||||||
m_httpServer.AddStreamHandler(new GetAssetStreamHandler(m_assetProvider));
|
|
||||||
m_httpServer.AddStreamHandler(new PostAssetStreamHandler(m_assetProvider));
|
|
||||||
}
|
|
||||||
|
|
||||||
public byte[] GetAssetData(UUID assetID, bool isTexture)
|
|
||||||
{
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setupDB(AssetConfig config)
|
|
||||||
{
|
|
||||||
try
|
|
||||||
{
|
|
||||||
m_assetProvider = DataPluginFactory.LoadDataPlugin<IAssetDataPlugin>(config.DatabaseProvider, config.DatabaseConnect);
|
|
||||||
if (m_assetProvider == null)
|
|
||||||
{
|
|
||||||
m_log.Error("[ASSET]: Failed to load a database plugin, server halting");
|
|
||||||
Environment.Exit(-1);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
catch (Exception e)
|
|
||||||
{
|
|
||||||
m_log.Warn("[ASSET]: setupDB() - Exception occured");
|
|
||||||
m_log.Warn("[ASSET]: " + e.ToString());
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public void LoadDefaultAssets(string pAssetSetsLocation)
|
|
||||||
{
|
|
||||||
assetLoader.ForEachDefaultXmlAsset(pAssetSetsLocation, StoreAsset);
|
|
||||||
}
|
|
||||||
|
|
||||||
protected void StoreAsset(AssetBase asset)
|
|
||||||
{
|
|
||||||
m_assetProvider.StoreAsset(asset);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -1,63 +0,0 @@
|
||||||
/*
|
|
||||||
* Copyright (c) Contributors, http://opensimulator.org/
|
|
||||||
* See CONTRIBUTORS.TXT for a full list of copyright holders.
|
|
||||||
*
|
|
||||||
* Redistribution and use in source and binary forms, with or without
|
|
||||||
* modification, are permitted provided that the following conditions are met:
|
|
||||||
* * Redistributions of source code must retain the above copyright
|
|
||||||
* notice, this list of conditions and the following disclaimer.
|
|
||||||
* * 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.Reflection;
|
|
||||||
using System.Runtime.InteropServices;
|
|
||||||
|
|
||||||
// General information about an assembly is controlled through the following
|
|
||||||
// set of attributes. Change these attribute values to modify the information
|
|
||||||
// associated with an assembly.
|
|
||||||
|
|
||||||
[assembly : AssemblyTitle("OGS-AssetServer")]
|
|
||||||
[assembly : AssemblyDescription("")]
|
|
||||||
[assembly : AssemblyConfiguration("")]
|
|
||||||
[assembly : AssemblyCompany("http://opensimulator.org")]
|
|
||||||
[assembly : AssemblyProduct("OGS-AssetServer")]
|
|
||||||
[assembly : AssemblyCopyright("Copyright (c) OpenSimulator.org Developers 2007-2009")]
|
|
||||||
[assembly : AssemblyTrademark("")]
|
|
||||||
[assembly : AssemblyCulture("")]
|
|
||||||
|
|
||||||
// Setting ComVisible to false makes the types in this assembly not visible
|
|
||||||
// to COM components. If you need to access a type in this assembly from
|
|
||||||
// COM, set the ComVisible attribute to true on that type.
|
|
||||||
|
|
||||||
[assembly : ComVisible(false)]
|
|
||||||
|
|
||||||
// The following GUID is for the ID of the typelib if this project is exposed to COM
|
|
||||||
|
|
||||||
[assembly : Guid("b541b244-3d1d-4625-9003-bc2a3a6a39a4")]
|
|
||||||
|
|
||||||
// Version information for an assembly consists of the following four values:
|
|
||||||
//
|
|
||||||
// Major Version
|
|
||||||
// Minor Version
|
|
||||||
// Build Number
|
|
||||||
// Revision
|
|
||||||
//
|
|
||||||
|
|
||||||
[assembly : AssemblyVersion("0.6.5.*")]
|
|
||||||
[assembly : AssemblyFileVersion("0.6.5.0")]
|
|
|
@ -1,133 +0,0 @@
|
||||||
/*
|
|
||||||
* Copyright (c) Contributors, http://opensimulator.org/
|
|
||||||
* See CONTRIBUTORS.TXT for a full list of copyright holders.
|
|
||||||
*
|
|
||||||
* Redistribution and use in source and binary forms, with or without
|
|
||||||
* modification, are permitted provided that the following conditions are met:
|
|
||||||
* * Redistributions of source code must retain the above copyright
|
|
||||||
* notice, this list of conditions and the following disclaimer.
|
|
||||||
* * 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;
|
|
||||||
|
|
||||||
namespace OpenSim.Grid.InventoryServer
|
|
||||||
{
|
|
||||||
public class AuthedSessionCache
|
|
||||||
{
|
|
||||||
public class CacheData
|
|
||||||
{
|
|
||||||
private static readonly DateTime UNIX_EPOCH = new DateTime(1970, 1, 1);
|
|
||||||
private string m_session_id;
|
|
||||||
private string m_agent_id;
|
|
||||||
private int m_expire;
|
|
||||||
|
|
||||||
private int get_current_unix_time()
|
|
||||||
{
|
|
||||||
return (int)(DateTime.UtcNow - UNIX_EPOCH).TotalSeconds;
|
|
||||||
}
|
|
||||||
|
|
||||||
public CacheData(string sid, string aid)
|
|
||||||
{
|
|
||||||
m_session_id = sid;
|
|
||||||
m_agent_id = aid;
|
|
||||||
m_expire = get_current_unix_time() + DEFAULT_LIFETIME;
|
|
||||||
}
|
|
||||||
|
|
||||||
public CacheData(string sid, string aid, int time_now)
|
|
||||||
{
|
|
||||||
m_session_id = sid;
|
|
||||||
m_agent_id = aid;
|
|
||||||
m_expire = time_now + DEFAULT_LIFETIME;
|
|
||||||
}
|
|
||||||
|
|
||||||
public string SessionID
|
|
||||||
{
|
|
||||||
get { return m_session_id; }
|
|
||||||
set { m_session_id = value; }
|
|
||||||
}
|
|
||||||
|
|
||||||
public string AgentID
|
|
||||||
{
|
|
||||||
get { return m_agent_id; }
|
|
||||||
set { m_agent_id = value; }
|
|
||||||
}
|
|
||||||
|
|
||||||
public bool isExpired
|
|
||||||
{
|
|
||||||
get { return m_expire < get_current_unix_time(); }
|
|
||||||
}
|
|
||||||
|
|
||||||
public void Renew()
|
|
||||||
{
|
|
||||||
m_expire = get_current_unix_time() + DEFAULT_LIFETIME;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
private static readonly int DEFAULT_LIFETIME = 30;
|
|
||||||
private Dictionary<string, CacheData> m_authed_sessions = new Dictionary<string,CacheData>();
|
|
||||||
// private int m_session_lifetime = DEFAULT_LIFETIME;
|
|
||||||
|
|
||||||
public AuthedSessionCache()
|
|
||||||
{
|
|
||||||
// m_session_lifetime = DEFAULT_LIFETIME;
|
|
||||||
}
|
|
||||||
|
|
||||||
public AuthedSessionCache(int timeout)
|
|
||||||
{
|
|
||||||
// m_session_lifetime = timeout;
|
|
||||||
}
|
|
||||||
|
|
||||||
public CacheData getCachedSession(string session_id, string agent_id)
|
|
||||||
{
|
|
||||||
CacheData ret = null;
|
|
||||||
lock (m_authed_sessions)
|
|
||||||
{
|
|
||||||
if (m_authed_sessions.ContainsKey(session_id))
|
|
||||||
{
|
|
||||||
CacheData cached_session = m_authed_sessions[session_id];
|
|
||||||
if (!cached_session.isExpired && cached_session.AgentID == agent_id)
|
|
||||||
{
|
|
||||||
ret = m_authed_sessions[session_id];
|
|
||||||
// auto renew
|
|
||||||
m_authed_sessions[session_id].Renew();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return ret;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void Add(string session_id, string agent_id)
|
|
||||||
{
|
|
||||||
CacheData data = new CacheData(session_id, agent_id);
|
|
||||||
lock (m_authed_sessions)
|
|
||||||
{
|
|
||||||
if (m_authed_sessions.ContainsKey(session_id))
|
|
||||||
{
|
|
||||||
m_authed_sessions[session_id] = data;
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
m_authed_sessions.Add(session_id, data);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -1,256 +0,0 @@
|
||||||
/*
|
|
||||||
* Copyright (c) Contributors, http://opensimulator.org/
|
|
||||||
* See CONTRIBUTORS.TXT for a full list of copyright holders.
|
|
||||||
*
|
|
||||||
* Redistribution and use in source and binary forms, with or without
|
|
||||||
* modification, are permitted provided that the following conditions are met:
|
|
||||||
* * Redistributions of source code must retain the above copyright
|
|
||||||
* notice, this list of conditions and the following disclaimer.
|
|
||||||
* * 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;
|
|
||||||
using System.Collections.Generic;
|
|
||||||
using System.Net;
|
|
||||||
using System.Reflection;
|
|
||||||
using log4net;
|
|
||||||
using Nwc.XmlRpc;
|
|
||||||
using OpenMetaverse;
|
|
||||||
using OpenSim.Framework;
|
|
||||||
using OpenSim.Framework.Communications;
|
|
||||||
using OpenSim.Framework.Communications.Cache;
|
|
||||||
|
|
||||||
namespace OpenSim.Grid.InventoryServer
|
|
||||||
{
|
|
||||||
/// <summary>
|
|
||||||
/// Used on a grid server to satisfy external inventory requests
|
|
||||||
/// </summary>
|
|
||||||
public class GridInventoryService : InventoryServiceBase
|
|
||||||
{
|
|
||||||
private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType);
|
|
||||||
|
|
||||||
private bool m_doLookup = false;
|
|
||||||
|
|
||||||
public bool DoLookup
|
|
||||||
{
|
|
||||||
get { return m_doLookup; }
|
|
||||||
set { m_doLookup = value; }
|
|
||||||
}
|
|
||||||
|
|
||||||
private static readonly int INVENTORY_DEFAULT_SESSION_TIME = 30; // secs
|
|
||||||
|
|
||||||
private string m_userserver_url;
|
|
||||||
private AuthedSessionCache m_session_cache = new AuthedSessionCache(INVENTORY_DEFAULT_SESSION_TIME);
|
|
||||||
|
|
||||||
public GridInventoryService(string userserver_url)
|
|
||||||
{
|
|
||||||
m_userserver_url = userserver_url;
|
|
||||||
}
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Check that the source of an inventory request is one that we trust.
|
|
||||||
/// </summary>
|
|
||||||
/// <param name="peer"></param>
|
|
||||||
/// <returns></returns>
|
|
||||||
public bool CheckTrustSource(IPEndPoint peer)
|
|
||||||
{
|
|
||||||
if (m_doLookup)
|
|
||||||
{
|
|
||||||
m_log.InfoFormat("[GRID AGENT INVENTORY]: Checking trusted source {0}", peer);
|
|
||||||
UriBuilder ub = new UriBuilder(m_userserver_url);
|
|
||||||
IPAddress[] uaddrs = Dns.GetHostAddresses(ub.Host);
|
|
||||||
foreach (IPAddress uaddr in uaddrs)
|
|
||||||
{
|
|
||||||
if (uaddr.Equals(peer.Address))
|
|
||||||
{
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
m_log.WarnFormat(
|
|
||||||
"[GRID AGENT INVENTORY]: Rejecting request since source {0} was not in the list of trusted sources",
|
|
||||||
peer);
|
|
||||||
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Check that the source of an inventory request for a particular agent is a current session belonging to
|
|
||||||
/// that agent.
|
|
||||||
/// </summary>
|
|
||||||
/// <param name="session_id"></param>
|
|
||||||
/// <param name="avatar_id"></param>
|
|
||||||
/// <returns></returns>
|
|
||||||
public bool CheckAuthSession(string session_id, string avatar_id)
|
|
||||||
{
|
|
||||||
if (m_doLookup)
|
|
||||||
{
|
|
||||||
m_log.InfoFormat("[GRID AGENT INVENTORY]: checking authed session {0} {1}", session_id, avatar_id);
|
|
||||||
|
|
||||||
if (m_session_cache.getCachedSession(session_id, avatar_id) == null)
|
|
||||||
{
|
|
||||||
// cache miss, ask userserver
|
|
||||||
Hashtable requestData = new Hashtable();
|
|
||||||
requestData["avatar_uuid"] = avatar_id;
|
|
||||||
requestData["session_id"] = session_id;
|
|
||||||
ArrayList SendParams = new ArrayList();
|
|
||||||
SendParams.Add(requestData);
|
|
||||||
XmlRpcRequest UserReq = new XmlRpcRequest("check_auth_session", SendParams);
|
|
||||||
XmlRpcResponse UserResp = UserReq.Send(m_userserver_url, 3000);
|
|
||||||
|
|
||||||
Hashtable responseData = (Hashtable)UserResp.Value;
|
|
||||||
if (responseData.ContainsKey("auth_session") && responseData["auth_session"].ToString() == "TRUE")
|
|
||||||
{
|
|
||||||
m_log.Info("[GRID AGENT INVENTORY]: got authed session from userserver");
|
|
||||||
// add to cache; the session time will be automatically renewed
|
|
||||||
m_session_cache.Add(session_id, avatar_id);
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
// cache hits
|
|
||||||
m_log.Info("[GRID AGENT INVENTORY]: got authed session from cache");
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
m_log.Warn("[GRID AGENT INVENTORY]: unknown session_id, request rejected");
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Return a user's entire inventory
|
|
||||||
/// </summary>
|
|
||||||
/// <param name="rawUserID"></param>
|
|
||||||
/// <returns>The user's inventory. If an inventory cannot be found then an empty collection is returned.</returns>
|
|
||||||
public InventoryCollection GetUserInventory(Guid rawUserID)
|
|
||||||
{
|
|
||||||
UUID userID = new UUID(rawUserID);
|
|
||||||
|
|
||||||
m_log.InfoFormat("[GRID AGENT INVENTORY]: Processing request for inventory of {0}", userID);
|
|
||||||
|
|
||||||
// Uncomment me to simulate a slow responding inventory server
|
|
||||||
//Thread.Sleep(16000);
|
|
||||||
|
|
||||||
InventoryCollection invCollection = new InventoryCollection();
|
|
||||||
|
|
||||||
List<InventoryFolderBase> allFolders = GetInventorySkeleton(userID);
|
|
||||||
|
|
||||||
if (null == allFolders)
|
|
||||||
{
|
|
||||||
m_log.WarnFormat("[GRID AGENT INVENTORY]: No inventory found for user {0}", rawUserID);
|
|
||||||
|
|
||||||
return invCollection;
|
|
||||||
}
|
|
||||||
|
|
||||||
List<InventoryItemBase> allItems = new List<InventoryItemBase>();
|
|
||||||
|
|
||||||
foreach (InventoryFolderBase folder in allFolders)
|
|
||||||
{
|
|
||||||
List<InventoryItemBase> items = RequestFolderItems(folder.ID);
|
|
||||||
|
|
||||||
if (items != null)
|
|
||||||
{
|
|
||||||
allItems.InsertRange(0, items);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
invCollection.UserID = userID;
|
|
||||||
invCollection.Folders = allFolders;
|
|
||||||
invCollection.Items = allItems;
|
|
||||||
|
|
||||||
// foreach (InventoryFolderBase folder in invCollection.Folders)
|
|
||||||
// {
|
|
||||||
// m_log.DebugFormat("[GRID AGENT INVENTORY]: Sending back folder {0} {1}", folder.Name, folder.ID);
|
|
||||||
// }
|
|
||||||
//
|
|
||||||
// foreach (InventoryItemBase item in invCollection.Items)
|
|
||||||
// {
|
|
||||||
// m_log.DebugFormat("[GRID AGENT INVENTORY]: Sending back item {0} {1}, folder {2}", item.Name, item.ID, item.Folder);
|
|
||||||
// }
|
|
||||||
|
|
||||||
m_log.InfoFormat(
|
|
||||||
"[GRID AGENT INVENTORY]: Sending back inventory response to user {0} containing {1} folders and {2} items",
|
|
||||||
invCollection.UserID, invCollection.Folders.Count, invCollection.Items.Count);
|
|
||||||
|
|
||||||
return invCollection;
|
|
||||||
}
|
|
||||||
|
|
||||||
public List<InventoryItemBase> GetFolderItems(Guid folderID)
|
|
||||||
{
|
|
||||||
List<InventoryItemBase> allItems = new List<InventoryItemBase>();
|
|
||||||
|
|
||||||
|
|
||||||
List<InventoryItemBase> items = RequestFolderItems(new UUID(folderID));
|
|
||||||
|
|
||||||
if (items != null)
|
|
||||||
{
|
|
||||||
allItems.InsertRange(0, items);
|
|
||||||
}
|
|
||||||
m_log.InfoFormat(
|
|
||||||
"[GRID AGENT INVENTORY]: Sending back inventory response containing {0} items", allItems.Count.ToString());
|
|
||||||
return allItems;
|
|
||||||
}
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Guid to UUID wrapper for same name IInventoryServices method
|
|
||||||
/// </summary>
|
|
||||||
/// <param name="rawUserID"></param>
|
|
||||||
/// <returns></returns>
|
|
||||||
public List<InventoryFolderBase> GetInventorySkeleton(Guid rawUserID)
|
|
||||||
{
|
|
||||||
UUID userID = new UUID(rawUserID);
|
|
||||||
return GetInventorySkeleton(userID);
|
|
||||||
}
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Create an inventory for the given user.
|
|
||||||
/// </summary>
|
|
||||||
/// <param name="rawUserID"></param>
|
|
||||||
/// <returns></returns>
|
|
||||||
public bool CreateUsersInventory(Guid rawUserID)
|
|
||||||
{
|
|
||||||
UUID userID = new UUID(rawUserID);
|
|
||||||
|
|
||||||
m_log.InfoFormat("[GRID AGENT INVENTORY]: Creating new set of inventory folders for user {0}", userID);
|
|
||||||
|
|
||||||
return CreateNewUserInventory(userID);
|
|
||||||
}
|
|
||||||
|
|
||||||
public List<InventoryItemBase> GetActiveGestures(Guid rawUserID)
|
|
||||||
{
|
|
||||||
UUID userID = new UUID(rawUserID);
|
|
||||||
|
|
||||||
m_log.InfoFormat("[GRID AGENT INVENTORY]: fetching active gestures for user {0}", userID);
|
|
||||||
|
|
||||||
return GetActiveGestures(userID);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -1,519 +0,0 @@
|
||||||
/*
|
|
||||||
* Copyright (c) Contributors, http://opensimulator.org/
|
|
||||||
* See CONTRIBUTORS.TXT for a full list of copyright holders.
|
|
||||||
*
|
|
||||||
* Redistribution and use in source and binary forms, with or without
|
|
||||||
* modification, are permitted provided that the following conditions are met:
|
|
||||||
* * Redistributions of source code must retain the above copyright
|
|
||||||
* notice, this list of conditions and the following disclaimer.
|
|
||||||
* * 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.Collections.Generic;
|
|
||||||
using System.Reflection;
|
|
||||||
using log4net;
|
|
||||||
using OpenMetaverse;
|
|
||||||
using OpenSim.Data;
|
|
||||||
using OpenSim.Framework;
|
|
||||||
using OpenSim.Framework.Communications;
|
|
||||||
|
|
||||||
namespace OpenSim.Grid.InventoryServer
|
|
||||||
{
|
|
||||||
/// <summary>
|
|
||||||
/// Abstract base class used by local and grid implementations of an inventory service.
|
|
||||||
/// </summary>
|
|
||||||
public abstract class InventoryServiceBase : IInterServiceInventoryServices
|
|
||||||
{
|
|
||||||
|
|
||||||
private static readonly ILog m_log
|
|
||||||
= LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType);
|
|
||||||
|
|
||||||
protected List<IInventoryDataPlugin> m_plugins = new List<IInventoryDataPlugin>();
|
|
||||||
|
|
||||||
#region Plugin methods
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Add a new inventory data plugin - plugins will be requested in the order they were added.
|
|
||||||
/// </summary>
|
|
||||||
/// <param name="plugin">The plugin that will provide data</param>
|
|
||||||
public void AddPlugin(IInventoryDataPlugin plugin)
|
|
||||||
{
|
|
||||||
m_plugins.Add(plugin);
|
|
||||||
}
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Adds a list of inventory data plugins, as described by `provider'
|
|
||||||
/// and `connect', to `m_plugins'.
|
|
||||||
/// </summary>
|
|
||||||
/// <param name="provider">
|
|
||||||
/// The filename of the inventory server plugin DLL.
|
|
||||||
/// </param>
|
|
||||||
/// <param name="connect">
|
|
||||||
/// The connection string for the storage backend.
|
|
||||||
/// </param>
|
|
||||||
public void AddPlugin(string provider, string connect)
|
|
||||||
{
|
|
||||||
m_plugins.AddRange(DataPluginFactory.LoadDataPlugins<IInventoryDataPlugin>(provider, connect));
|
|
||||||
}
|
|
||||||
|
|
||||||
#endregion
|
|
||||||
|
|
||||||
#region IInventoryServices methods
|
|
||||||
|
|
||||||
public string Host
|
|
||||||
{
|
|
||||||
get { return "default"; }
|
|
||||||
}
|
|
||||||
|
|
||||||
public List<InventoryFolderBase> GetInventorySkeleton(UUID userId)
|
|
||||||
{
|
|
||||||
// m_log.DebugFormat("[AGENT INVENTORY]: Getting inventory skeleton for {0}", userId);
|
|
||||||
|
|
||||||
InventoryFolderBase rootFolder = RequestRootFolder(userId);
|
|
||||||
|
|
||||||
// Agent has no inventory structure yet.
|
|
||||||
if (null == rootFolder)
|
|
||||||
{
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
|
|
||||||
List<InventoryFolderBase> userFolders = new List<InventoryFolderBase>();
|
|
||||||
|
|
||||||
userFolders.Add(rootFolder);
|
|
||||||
|
|
||||||
foreach (IInventoryDataPlugin plugin in m_plugins)
|
|
||||||
{
|
|
||||||
IList<InventoryFolderBase> folders = plugin.getFolderHierarchy(rootFolder.ID);
|
|
||||||
userFolders.AddRange(folders);
|
|
||||||
}
|
|
||||||
|
|
||||||
// foreach (InventoryFolderBase folder in userFolders)
|
|
||||||
// {
|
|
||||||
// m_log.DebugFormat("[AGENT INVENTORY]: Got folder {0} {1}", folder.name, folder.folderID);
|
|
||||||
// }
|
|
||||||
|
|
||||||
return userFolders;
|
|
||||||
}
|
|
||||||
|
|
||||||
// See IInventoryServices
|
|
||||||
public virtual bool HasInventoryForUser(UUID userID)
|
|
||||||
{
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
// See IInventoryServices
|
|
||||||
public virtual InventoryFolderBase RequestRootFolder(UUID userID)
|
|
||||||
{
|
|
||||||
// Retrieve the first root folder we get from the list of plugins.
|
|
||||||
foreach (IInventoryDataPlugin plugin in m_plugins)
|
|
||||||
{
|
|
||||||
InventoryFolderBase rootFolder = plugin.getUserRootFolder(userID);
|
|
||||||
if (rootFolder != null)
|
|
||||||
return rootFolder;
|
|
||||||
}
|
|
||||||
|
|
||||||
// Return nothing if no plugin was able to supply a root folder
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
|
|
||||||
// See IInventoryServices
|
|
||||||
public bool CreateNewUserInventory(UUID user)
|
|
||||||
{
|
|
||||||
InventoryFolderBase existingRootFolder = RequestRootFolder(user);
|
|
||||||
|
|
||||||
if (null != existingRootFolder)
|
|
||||||
{
|
|
||||||
m_log.WarnFormat(
|
|
||||||
"[AGENT INVENTORY]: Did not create a new inventory for user {0} since they already have "
|
|
||||||
+ "a root inventory folder with id {1}",
|
|
||||||
user, existingRootFolder.ID);
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
UsersInventory inven = new UsersInventory();
|
|
||||||
inven.CreateNewInventorySet(user);
|
|
||||||
AddNewInventorySet(inven);
|
|
||||||
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
public List<InventoryItemBase> GetActiveGestures(UUID userId)
|
|
||||||
{
|
|
||||||
List<InventoryItemBase> activeGestures = new List<InventoryItemBase>();
|
|
||||||
foreach (IInventoryDataPlugin plugin in m_plugins)
|
|
||||||
{
|
|
||||||
activeGestures.AddRange(plugin.fetchActiveGestures(userId));
|
|
||||||
}
|
|
||||||
|
|
||||||
return activeGestures;
|
|
||||||
}
|
|
||||||
|
|
||||||
#endregion
|
|
||||||
|
|
||||||
#region Methods used by GridInventoryService
|
|
||||||
|
|
||||||
public List<InventoryFolderBase> RequestSubFolders(UUID parentFolderID)
|
|
||||||
{
|
|
||||||
List<InventoryFolderBase> inventoryList = new List<InventoryFolderBase>();
|
|
||||||
|
|
||||||
foreach (IInventoryDataPlugin plugin in m_plugins)
|
|
||||||
{
|
|
||||||
inventoryList.AddRange(plugin.getInventoryFolders(parentFolderID));
|
|
||||||
}
|
|
||||||
|
|
||||||
return inventoryList;
|
|
||||||
}
|
|
||||||
|
|
||||||
public List<InventoryItemBase> RequestFolderItems(UUID folderID)
|
|
||||||
{
|
|
||||||
List<InventoryItemBase> itemsList = new List<InventoryItemBase>();
|
|
||||||
|
|
||||||
foreach (IInventoryDataPlugin plugin in m_plugins)
|
|
||||||
{
|
|
||||||
itemsList.AddRange(plugin.getInventoryInFolder(folderID));
|
|
||||||
}
|
|
||||||
|
|
||||||
return itemsList;
|
|
||||||
}
|
|
||||||
|
|
||||||
#endregion
|
|
||||||
|
|
||||||
// See IInventoryServices
|
|
||||||
public virtual bool AddFolder(InventoryFolderBase folder)
|
|
||||||
{
|
|
||||||
m_log.DebugFormat(
|
|
||||||
"[AGENT INVENTORY]: Adding folder {0} {1} to folder {2}", folder.Name, folder.ID, folder.ParentID);
|
|
||||||
|
|
||||||
foreach (IInventoryDataPlugin plugin in m_plugins)
|
|
||||||
{
|
|
||||||
plugin.addInventoryFolder(folder);
|
|
||||||
}
|
|
||||||
|
|
||||||
// FIXME: Should return false on failure
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
// See IInventoryServices
|
|
||||||
public virtual bool UpdateFolder(InventoryFolderBase folder)
|
|
||||||
{
|
|
||||||
m_log.DebugFormat(
|
|
||||||
"[AGENT INVENTORY]: Updating folder {0} {1} to folder {2}", folder.Name, folder.ID, folder.ParentID);
|
|
||||||
|
|
||||||
foreach (IInventoryDataPlugin plugin in m_plugins)
|
|
||||||
{
|
|
||||||
plugin.updateInventoryFolder(folder);
|
|
||||||
}
|
|
||||||
|
|
||||||
// FIXME: Should return false on failure
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
// See IInventoryServices
|
|
||||||
public virtual bool MoveFolder(InventoryFolderBase folder)
|
|
||||||
{
|
|
||||||
m_log.DebugFormat(
|
|
||||||
"[AGENT INVENTORY]: Moving folder {0} {1} to folder {2}", folder.Name, folder.ID, folder.ParentID);
|
|
||||||
|
|
||||||
foreach (IInventoryDataPlugin plugin in m_plugins)
|
|
||||||
{
|
|
||||||
plugin.moveInventoryFolder(folder);
|
|
||||||
}
|
|
||||||
|
|
||||||
// FIXME: Should return false on failure
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
// See IInventoryServices
|
|
||||||
public virtual bool AddItem(InventoryItemBase item)
|
|
||||||
{
|
|
||||||
m_log.DebugFormat(
|
|
||||||
"[AGENT INVENTORY]: Adding item {0} {1} to folder {2}", item.Name, item.ID, item.Folder);
|
|
||||||
|
|
||||||
foreach (IInventoryDataPlugin plugin in m_plugins)
|
|
||||||
{
|
|
||||||
plugin.addInventoryItem(item);
|
|
||||||
}
|
|
||||||
|
|
||||||
// FIXME: Should return false on failure
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
// See IInventoryServices
|
|
||||||
public virtual bool UpdateItem(InventoryItemBase item)
|
|
||||||
{
|
|
||||||
m_log.InfoFormat(
|
|
||||||
"[AGENT INVENTORY]: Updating item {0} {1} in folder {2}", item.Name, item.ID, item.Folder);
|
|
||||||
|
|
||||||
foreach (IInventoryDataPlugin plugin in m_plugins)
|
|
||||||
{
|
|
||||||
plugin.updateInventoryItem(item);
|
|
||||||
}
|
|
||||||
|
|
||||||
// FIXME: Should return false on failure
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
// See IInventoryServices
|
|
||||||
public virtual bool DeleteItem(InventoryItemBase item)
|
|
||||||
{
|
|
||||||
m_log.InfoFormat(
|
|
||||||
"[AGENT INVENTORY]: Deleting item {0} {1} from folder {2}", item.Name, item.ID, item.Folder);
|
|
||||||
|
|
||||||
foreach (IInventoryDataPlugin plugin in m_plugins)
|
|
||||||
{
|
|
||||||
plugin.deleteInventoryItem(item.ID);
|
|
||||||
}
|
|
||||||
|
|
||||||
// FIXME: Should return false on failure
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
public virtual InventoryItemBase QueryItem(InventoryItemBase item)
|
|
||||||
{
|
|
||||||
foreach (IInventoryDataPlugin plugin in m_plugins)
|
|
||||||
{
|
|
||||||
InventoryItemBase result = plugin.queryInventoryItem(item.ID);
|
|
||||||
if (result != null)
|
|
||||||
return result;
|
|
||||||
}
|
|
||||||
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
|
|
||||||
public virtual InventoryFolderBase QueryFolder(InventoryFolderBase item)
|
|
||||||
{
|
|
||||||
foreach (IInventoryDataPlugin plugin in m_plugins)
|
|
||||||
{
|
|
||||||
InventoryFolderBase result = plugin.queryInventoryFolder(item.ID);
|
|
||||||
if (result != null)
|
|
||||||
return result;
|
|
||||||
}
|
|
||||||
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Purge a folder of all items items and subfolders.
|
|
||||||
///
|
|
||||||
/// FIXME: Really nasty in a sense, because we have to query the database to get information we may
|
|
||||||
/// already know... Needs heavy refactoring.
|
|
||||||
/// </summary>
|
|
||||||
/// <param name="folder"></param>
|
|
||||||
public virtual bool PurgeFolder(InventoryFolderBase folder)
|
|
||||||
{
|
|
||||||
m_log.DebugFormat(
|
|
||||||
"[AGENT INVENTORY]: Purging folder {0} {1} of its contents", folder.Name, folder.ID);
|
|
||||||
|
|
||||||
List<InventoryFolderBase> subFolders = RequestSubFolders(folder.ID);
|
|
||||||
|
|
||||||
foreach (InventoryFolderBase subFolder in subFolders)
|
|
||||||
{
|
|
||||||
// m_log.DebugFormat("[AGENT INVENTORY]: Deleting folder {0} {1}", subFolder.Name, subFolder.ID);
|
|
||||||
|
|
||||||
foreach (IInventoryDataPlugin plugin in m_plugins)
|
|
||||||
{
|
|
||||||
plugin.deleteInventoryFolder(subFolder.ID);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
List<InventoryItemBase> items = RequestFolderItems(folder.ID);
|
|
||||||
|
|
||||||
foreach (InventoryItemBase item in items)
|
|
||||||
{
|
|
||||||
DeleteItem(item);
|
|
||||||
}
|
|
||||||
|
|
||||||
// FIXME: Should return false on failure
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
private void AddNewInventorySet(UsersInventory inventory)
|
|
||||||
{
|
|
||||||
foreach (InventoryFolderBase folder in inventory.Folders.Values)
|
|
||||||
{
|
|
||||||
AddFolder(folder);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public InventoryItemBase GetInventoryItem(UUID itemID)
|
|
||||||
{
|
|
||||||
foreach (IInventoryDataPlugin plugin in m_plugins)
|
|
||||||
{
|
|
||||||
InventoryItemBase item = plugin.getInventoryItem(itemID);
|
|
||||||
if (item != null)
|
|
||||||
return item;
|
|
||||||
}
|
|
||||||
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Used to create a new user inventory.
|
|
||||||
/// </summary>
|
|
||||||
private class UsersInventory
|
|
||||||
{
|
|
||||||
public Dictionary<UUID, InventoryFolderBase> Folders = new Dictionary<UUID, InventoryFolderBase>();
|
|
||||||
public Dictionary<UUID, InventoryItemBase> Items = new Dictionary<UUID, InventoryItemBase>();
|
|
||||||
|
|
||||||
public virtual void CreateNewInventorySet(UUID user)
|
|
||||||
{
|
|
||||||
InventoryFolderBase folder = new InventoryFolderBase();
|
|
||||||
|
|
||||||
folder.ParentID = UUID.Zero;
|
|
||||||
folder.Owner = user;
|
|
||||||
folder.ID = UUID.Random();
|
|
||||||
folder.Name = "My Inventory";
|
|
||||||
folder.Type = (short)AssetType.Folder;
|
|
||||||
folder.Version = 1;
|
|
||||||
Folders.Add(folder.ID, folder);
|
|
||||||
|
|
||||||
UUID rootFolder = folder.ID;
|
|
||||||
|
|
||||||
folder = new InventoryFolderBase();
|
|
||||||
folder.ParentID = rootFolder;
|
|
||||||
folder.Owner = user;
|
|
||||||
folder.ID = UUID.Random();
|
|
||||||
folder.Name = "Animations";
|
|
||||||
folder.Type = (short)AssetType.Animation;
|
|
||||||
folder.Version = 1;
|
|
||||||
Folders.Add(folder.ID, folder);
|
|
||||||
|
|
||||||
folder = new InventoryFolderBase();
|
|
||||||
folder.ParentID = rootFolder;
|
|
||||||
folder.Owner = user;
|
|
||||||
folder.ID = UUID.Random();
|
|
||||||
folder.Name = "Body Parts";
|
|
||||||
folder.Type = (short)AssetType.Bodypart;
|
|
||||||
folder.Version = 1;
|
|
||||||
Folders.Add(folder.ID, folder);
|
|
||||||
|
|
||||||
folder = new InventoryFolderBase();
|
|
||||||
folder.ParentID = rootFolder;
|
|
||||||
folder.Owner = user;
|
|
||||||
folder.ID = UUID.Random();
|
|
||||||
folder.Name = "Calling Cards";
|
|
||||||
folder.Type = (short)AssetType.CallingCard;
|
|
||||||
folder.Version = 1;
|
|
||||||
Folders.Add(folder.ID, folder);
|
|
||||||
|
|
||||||
folder = new InventoryFolderBase();
|
|
||||||
folder.ParentID = rootFolder;
|
|
||||||
folder.Owner = user;
|
|
||||||
folder.ID = UUID.Random();
|
|
||||||
folder.Name = "Clothing";
|
|
||||||
folder.Type = (short)AssetType.Clothing;
|
|
||||||
folder.Version = 1;
|
|
||||||
Folders.Add(folder.ID, folder);
|
|
||||||
|
|
||||||
folder = new InventoryFolderBase();
|
|
||||||
folder.ParentID = rootFolder;
|
|
||||||
folder.Owner = user;
|
|
||||||
folder.ID = UUID.Random();
|
|
||||||
folder.Name = "Gestures";
|
|
||||||
folder.Type = (short)AssetType.Gesture;
|
|
||||||
folder.Version = 1;
|
|
||||||
Folders.Add(folder.ID, folder);
|
|
||||||
|
|
||||||
folder = new InventoryFolderBase();
|
|
||||||
folder.ParentID = rootFolder;
|
|
||||||
folder.Owner = user;
|
|
||||||
folder.ID = UUID.Random();
|
|
||||||
folder.Name = "Landmarks";
|
|
||||||
folder.Type = (short)AssetType.Landmark;
|
|
||||||
folder.Version = 1;
|
|
||||||
Folders.Add(folder.ID, folder);
|
|
||||||
|
|
||||||
folder = new InventoryFolderBase();
|
|
||||||
folder.ParentID = rootFolder;
|
|
||||||
folder.Owner = user;
|
|
||||||
folder.ID = UUID.Random();
|
|
||||||
folder.Name = "Lost And Found";
|
|
||||||
folder.Type = (short)AssetType.LostAndFoundFolder;
|
|
||||||
folder.Version = 1;
|
|
||||||
Folders.Add(folder.ID, folder);
|
|
||||||
|
|
||||||
folder = new InventoryFolderBase();
|
|
||||||
folder.ParentID = rootFolder;
|
|
||||||
folder.Owner = user;
|
|
||||||
folder.ID = UUID.Random();
|
|
||||||
folder.Name = "Notecards";
|
|
||||||
folder.Type = (short)AssetType.Notecard;
|
|
||||||
folder.Version = 1;
|
|
||||||
Folders.Add(folder.ID, folder);
|
|
||||||
|
|
||||||
folder = new InventoryFolderBase();
|
|
||||||
folder.ParentID = rootFolder;
|
|
||||||
folder.Owner = user;
|
|
||||||
folder.ID = UUID.Random();
|
|
||||||
folder.Name = "Objects";
|
|
||||||
folder.Type = (short)AssetType.Object;
|
|
||||||
folder.Version = 1;
|
|
||||||
Folders.Add(folder.ID, folder);
|
|
||||||
|
|
||||||
folder = new InventoryFolderBase();
|
|
||||||
folder.ParentID = rootFolder;
|
|
||||||
folder.Owner = user;
|
|
||||||
folder.ID = UUID.Random();
|
|
||||||
folder.Name = "Photo Album";
|
|
||||||
folder.Type = (short)AssetType.SnapshotFolder;
|
|
||||||
folder.Version = 1;
|
|
||||||
Folders.Add(folder.ID, folder);
|
|
||||||
|
|
||||||
folder = new InventoryFolderBase();
|
|
||||||
folder.ParentID = rootFolder;
|
|
||||||
folder.Owner = user;
|
|
||||||
folder.ID = UUID.Random();
|
|
||||||
folder.Name = "Scripts";
|
|
||||||
folder.Type = (short)AssetType.LSLText;
|
|
||||||
folder.Version = 1;
|
|
||||||
Folders.Add(folder.ID, folder);
|
|
||||||
|
|
||||||
folder = new InventoryFolderBase();
|
|
||||||
folder.ParentID = rootFolder;
|
|
||||||
folder.Owner = user;
|
|
||||||
folder.ID = UUID.Random();
|
|
||||||
folder.Name = "Sounds";
|
|
||||||
folder.Type = (short)AssetType.Sound;
|
|
||||||
folder.Version = 1;
|
|
||||||
Folders.Add(folder.ID, folder);
|
|
||||||
|
|
||||||
folder = new InventoryFolderBase();
|
|
||||||
folder.ParentID = rootFolder;
|
|
||||||
folder.Owner = user;
|
|
||||||
folder.ID = UUID.Random();
|
|
||||||
folder.Name = "Textures";
|
|
||||||
folder.Type = (short)AssetType.Texture;
|
|
||||||
folder.Version = 1;
|
|
||||||
Folders.Add(folder.ID, folder);
|
|
||||||
|
|
||||||
folder = new InventoryFolderBase();
|
|
||||||
folder.ParentID = rootFolder;
|
|
||||||
folder.Owner = user;
|
|
||||||
folder.ID = UUID.Random();
|
|
||||||
folder.Name = "Trash";
|
|
||||||
folder.Type = (short)AssetType.TrashFolder;
|
|
||||||
folder.Version = 1;
|
|
||||||
Folders.Add(folder.ID, folder);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -1,182 +0,0 @@
|
||||||
/*
|
|
||||||
* Copyright (c) Contributors, http://opensimulator.org/
|
|
||||||
* See CONTRIBUTORS.TXT for a full list of copyright holders.
|
|
||||||
*
|
|
||||||
* Redistribution and use in source and binary forms, with or without
|
|
||||||
* modification, are permitted provided that the following conditions are met:
|
|
||||||
* * Redistributions of source code must retain the above copyright
|
|
||||||
* notice, this list of conditions and the following disclaimer.
|
|
||||||
* * 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 System.IO;
|
|
||||||
using System.Reflection;
|
|
||||||
using log4net;
|
|
||||||
using log4net.Config;
|
|
||||||
using OpenMetaverse;
|
|
||||||
using OpenSim.Framework;
|
|
||||||
using OpenSim.Framework.Communications.Services;
|
|
||||||
using OpenSim.Framework.Console;
|
|
||||||
using OpenSim.Framework.Servers;
|
|
||||||
using OpenSim.Framework.Servers.HttpServer;
|
|
||||||
|
|
||||||
namespace OpenSim.Grid.InventoryServer
|
|
||||||
{
|
|
||||||
public class OpenInventory_Main : BaseOpenSimServer
|
|
||||||
{
|
|
||||||
private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType);
|
|
||||||
|
|
||||||
private GridInventoryService m_inventoryService;
|
|
||||||
//private HGInventoryService m_directInventoryService;
|
|
||||||
|
|
||||||
public const string LogName = "INVENTORY";
|
|
||||||
|
|
||||||
public static void Main(string[] args)
|
|
||||||
{
|
|
||||||
XmlConfigurator.Configure();
|
|
||||||
|
|
||||||
OpenInventory_Main theServer = new OpenInventory_Main();
|
|
||||||
theServer.Startup();
|
|
||||||
|
|
||||||
theServer.Work();
|
|
||||||
}
|
|
||||||
|
|
||||||
public OpenInventory_Main()
|
|
||||||
{
|
|
||||||
m_console = new LocalConsole("Inventory");
|
|
||||||
MainConsole.Instance = m_console;
|
|
||||||
}
|
|
||||||
|
|
||||||
protected override void StartupSpecific()
|
|
||||||
{
|
|
||||||
InventoryConfig config = new InventoryConfig(LogName, (Path.Combine(Util.configDir(), "InventoryServer_Config.xml")));
|
|
||||||
|
|
||||||
m_inventoryService = new GridInventoryService(config.UserServerURL);
|
|
||||||
m_inventoryService.DoLookup = config.SessionLookUp;
|
|
||||||
m_inventoryService.AddPlugin(config.DatabaseProvider, config.DatabaseConnect);
|
|
||||||
|
|
||||||
|
|
||||||
m_log.Info("[" + LogName + "]: Starting HTTP server ...");
|
|
||||||
|
|
||||||
m_httpServer = new BaseHttpServer(config.HttpPort);
|
|
||||||
|
|
||||||
AddHttpHandlers(config.RegionAccessToAgentsInventory);
|
|
||||||
|
|
||||||
m_httpServer.Start();
|
|
||||||
|
|
||||||
m_log.Info("[" + LogName + "]: Started HTTP server");
|
|
||||||
|
|
||||||
base.StartupSpecific();
|
|
||||||
|
|
||||||
m_console.Commands.AddCommand("inventoryserver", false, "add user",
|
|
||||||
"add user",
|
|
||||||
"Add a random user inventory", HandleAddUser);
|
|
||||||
}
|
|
||||||
|
|
||||||
protected void AddHttpHandlers(bool regionAccess)
|
|
||||||
{
|
|
||||||
if (regionAccess)
|
|
||||||
{
|
|
||||||
m_httpServer.AddStreamHandler(
|
|
||||||
new RestDeserialiseSecureHandler<Guid, InventoryCollection>(
|
|
||||||
"POST", "/GetInventory/", m_inventoryService.GetUserInventory, m_inventoryService.CheckAuthSession));
|
|
||||||
|
|
||||||
m_httpServer.AddStreamHandler(
|
|
||||||
new RestDeserialiseSecureHandler<InventoryFolderBase, bool>(
|
|
||||||
"POST", "/UpdateFolder/", m_inventoryService.UpdateFolder, m_inventoryService.CheckAuthSession));
|
|
||||||
|
|
||||||
m_httpServer.AddStreamHandler(
|
|
||||||
new RestDeserialiseSecureHandler<InventoryFolderBase, bool>(
|
|
||||||
"POST", "/MoveFolder/", m_inventoryService.MoveFolder, m_inventoryService.CheckAuthSession));
|
|
||||||
|
|
||||||
m_httpServer.AddStreamHandler(
|
|
||||||
new RestDeserialiseSecureHandler<InventoryFolderBase, bool>(
|
|
||||||
"POST", "/PurgeFolder/", m_inventoryService.PurgeFolder, m_inventoryService.CheckAuthSession));
|
|
||||||
|
|
||||||
m_httpServer.AddStreamHandler(
|
|
||||||
new RestDeserialiseSecureHandler<InventoryItemBase, bool>(
|
|
||||||
"POST", "/DeleteItem/", m_inventoryService.DeleteItem, m_inventoryService.CheckAuthSession));
|
|
||||||
|
|
||||||
m_httpServer.AddStreamHandler(
|
|
||||||
new RestDeserialiseSecureHandler<InventoryItemBase, InventoryItemBase>(
|
|
||||||
"POST", "/QueryItem/", m_inventoryService.QueryItem, m_inventoryService.CheckAuthSession));
|
|
||||||
|
|
||||||
m_httpServer.AddStreamHandler(
|
|
||||||
new RestDeserialiseSecureHandler<InventoryFolderBase, InventoryFolderBase>(
|
|
||||||
"POST", "/QueryFolder/", m_inventoryService.QueryFolder, m_inventoryService.CheckAuthSession));
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
m_httpServer.AddStreamHandler(
|
|
||||||
new RestDeserialiseTrustedHandler<Guid, bool>(
|
|
||||||
"POST", "/CreateInventory/", m_inventoryService.CreateUsersInventory, m_inventoryService.CheckTrustSource));
|
|
||||||
|
|
||||||
m_httpServer.AddStreamHandler(
|
|
||||||
new RestDeserialiseSecureHandler<InventoryFolderBase, bool>(
|
|
||||||
"POST", "/NewFolder/", m_inventoryService.AddFolder, m_inventoryService.CheckAuthSession));
|
|
||||||
|
|
||||||
m_httpServer.AddStreamHandler(
|
|
||||||
new RestDeserialiseTrustedHandler<InventoryFolderBase, bool>(
|
|
||||||
"POST", "/CreateFolder/", m_inventoryService.AddFolder, m_inventoryService.CheckTrustSource));
|
|
||||||
|
|
||||||
m_httpServer.AddStreamHandler(
|
|
||||||
new RestDeserialiseSecureHandler<InventoryItemBase, bool>(
|
|
||||||
"POST", "/NewItem/", m_inventoryService.AddItem, m_inventoryService.CheckAuthSession));
|
|
||||||
|
|
||||||
m_httpServer.AddStreamHandler(
|
|
||||||
new RestDeserialiseTrustedHandler<InventoryItemBase, bool>(
|
|
||||||
"POST", "/AddNewItem/", m_inventoryService.AddItem, m_inventoryService.CheckTrustSource));
|
|
||||||
|
|
||||||
m_httpServer.AddStreamHandler(
|
|
||||||
new RestDeserialiseTrustedHandler<Guid, List<InventoryItemBase>>(
|
|
||||||
"POST", "/GetItems/", m_inventoryService.GetFolderItems, m_inventoryService.CheckTrustSource));
|
|
||||||
|
|
||||||
// for persistent active gestures
|
|
||||||
m_httpServer.AddStreamHandler(
|
|
||||||
new RestDeserialiseTrustedHandler<Guid, List<InventoryItemBase>>
|
|
||||||
("POST", "/ActiveGestures/", m_inventoryService.GetActiveGestures, m_inventoryService.CheckTrustSource));
|
|
||||||
|
|
||||||
// WARNING: Root folders no longer just delivers the root and immediate child folders (e.g
|
|
||||||
// system folders such as Objects, Textures), but it now returns the entire inventory skeleton.
|
|
||||||
// It would have been better to rename this request, but complexities in the BaseHttpServer
|
|
||||||
// (e.g. any http request not found is automatically treated as an xmlrpc request) make it easier
|
|
||||||
// to do this for now.
|
|
||||||
m_httpServer.AddStreamHandler(
|
|
||||||
new RestDeserialiseTrustedHandler<Guid, List<InventoryFolderBase>>
|
|
||||||
("POST", "/RootFolders/", m_inventoryService.GetInventorySkeleton, m_inventoryService.CheckTrustSource));
|
|
||||||
}
|
|
||||||
|
|
||||||
private void Work()
|
|
||||||
{
|
|
||||||
m_console.Output("Enter help for a list of commands\n");
|
|
||||||
|
|
||||||
while (true)
|
|
||||||
{
|
|
||||||
m_console.Prompt();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
private void HandleAddUser(string module, string[] args)
|
|
||||||
{
|
|
||||||
m_inventoryService.CreateUsersInventory(UUID.Random().Guid);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
64
prebuild.xml
64
prebuild.xml
|
@ -956,38 +956,6 @@
|
||||||
</Project>
|
</Project>
|
||||||
|
|
||||||
|
|
||||||
<Project frameworkVersion="v3_5" name="OpenSim.Grid.AssetServer" path="OpenSim/Grid/AssetServer" type="Exe">
|
|
||||||
<Configuration name="Debug">
|
|
||||||
<Options>
|
|
||||||
<OutputPath>../../../bin/</OutputPath>
|
|
||||||
</Options>
|
|
||||||
</Configuration>
|
|
||||||
<Configuration name="Release">
|
|
||||||
<Options>
|
|
||||||
<OutputPath>../../../bin/</OutputPath>
|
|
||||||
</Options>
|
|
||||||
</Configuration>
|
|
||||||
|
|
||||||
<ReferencePath>../../../bin/</ReferencePath>
|
|
||||||
<Reference name="System"/>
|
|
||||||
<Reference name="System.Data"/>
|
|
||||||
<Reference name="System.Xml"/>
|
|
||||||
<Reference name="OpenSim.Framework"/>
|
|
||||||
<Reference name="OpenSim.Framework.AssetLoader.Filesystem"/>
|
|
||||||
<Reference name="OpenSim.Framework.Console"/>
|
|
||||||
<Reference name="OpenSim.Framework.Servers"/>
|
|
||||||
<Reference name="OpenSim.Framework.Servers.HttpServer"/>
|
|
||||||
<Reference name="OpenSim.Framework.Communications"/>
|
|
||||||
<Reference name="OpenSim.Framework.Statistics"/>
|
|
||||||
<Reference name="OpenSim.Data"/>
|
|
||||||
<Reference name="OpenMetaverseTypes.dll"/>
|
|
||||||
<Reference name="log4net.dll"/>
|
|
||||||
|
|
||||||
<Files>
|
|
||||||
<Match pattern="*.cs" recurse="true"/>
|
|
||||||
</Files>
|
|
||||||
</Project>
|
|
||||||
|
|
||||||
<Project frameworkVersion="v3_5" name="OpenSim.Grid.UserServer.Modules" path="OpenSim/Grid/UserServer.Modules" type="Library">
|
<Project frameworkVersion="v3_5" name="OpenSim.Grid.UserServer.Modules" path="OpenSim/Grid/UserServer.Modules" type="Library">
|
||||||
<Configuration name="Debug">
|
<Configuration name="Debug">
|
||||||
<Options>
|
<Options>
|
||||||
|
@ -1068,38 +1036,6 @@
|
||||||
</Files>
|
</Files>
|
||||||
</Project>
|
</Project>
|
||||||
|
|
||||||
<Project frameworkVersion="v3_5" name="OpenSim.Grid.InventoryServer" path="OpenSim/Grid/InventoryServer" type="Exe">
|
|
||||||
<Configuration name="Debug">
|
|
||||||
<Options>
|
|
||||||
<OutputPath>../../../bin/</OutputPath>
|
|
||||||
</Options>
|
|
||||||
</Configuration>
|
|
||||||
<Configuration name="Release">
|
|
||||||
<Options>
|
|
||||||
<OutputPath>../../../bin/</OutputPath>
|
|
||||||
</Options>
|
|
||||||
</Configuration>
|
|
||||||
|
|
||||||
<ReferencePath>../../../bin/</ReferencePath>
|
|
||||||
<Reference name="System"/>
|
|
||||||
<Reference name="System.Data"/>
|
|
||||||
<Reference name="System.Xml"/>
|
|
||||||
<Reference name="OpenSim.Framework"/>
|
|
||||||
<Reference name="OpenSim.Framework.Console"/>
|
|
||||||
<Reference name="OpenSim.Framework.Communications"/>
|
|
||||||
<Reference name="OpenSim.Data"/>
|
|
||||||
<Reference name="OpenSim.Framework.Servers"/>
|
|
||||||
<Reference name="OpenSim.Framework.Servers.HttpServer"/>
|
|
||||||
<Reference name="OpenSim.Services.Interfaces"/>
|
|
||||||
<Reference name="OpenMetaverseTypes.dll"/>
|
|
||||||
<Reference name="log4net.dll"/>
|
|
||||||
<Reference name="XMLRPC.dll"/>
|
|
||||||
|
|
||||||
<Files>
|
|
||||||
<Match pattern="*.cs" recurse="true"/>
|
|
||||||
</Files>
|
|
||||||
</Project>
|
|
||||||
|
|
||||||
<Project frameworkVersion="v3_5" name="OpenSim.Grid.MessagingServer.Modules" path="OpenSim/Grid/MessagingServer.Modules" type="Library">
|
<Project frameworkVersion="v3_5" name="OpenSim.Grid.MessagingServer.Modules" path="OpenSim/Grid/MessagingServer.Modules" type="Library">
|
||||||
<Configuration name="Debug">
|
<Configuration name="Debug">
|
||||||
<Options>
|
<Options>
|
||||||
|
|
Loading…
Reference in New Issue