diff options
author | Melanie | 2009-09-17 23:39:58 +0100 |
---|---|---|
committer | Melanie | 2009-09-17 23:39:58 +0100 |
commit | 6779abf7f59e518b0cd18e52dd91a500049dfda6 (patch) | |
tree | 16b33fae811359c5e80f1c2630fba4deb3066006 | |
parent | While running a test case I had written to pursue problems with (diff) | |
download | opensim-SC-6779abf7f59e518b0cd18e52dd91a500049dfda6.zip opensim-SC-6779abf7f59e518b0cd18e52dd91a500049dfda6.tar.gz opensim-SC-6779abf7f59e518b0cd18e52dd91a500049dfda6.tar.bz2 opensim-SC-6779abf7f59e518b0cd18e52dd91a500049dfda6.tar.xz |
Remove The legacy inventory and asset servers. Bump interface version to 6
Diffstat (limited to '')
-rw-r--r-- | OpenSim/Framework/Servers/BaseGetAssetStreamHandler.cs | 205 | ||||
-rw-r--r-- | OpenSim/Framework/Servers/GetAssetStreamHandler.cs | 63 | ||||
-rw-r--r-- | OpenSim/Framework/Servers/PostAssetStreamHandler.cs | 72 | ||||
-rw-r--r-- | OpenSim/Framework/Servers/VersionInfo.cs | 2 | ||||
-rw-r--r-- | OpenSim/Grid/AssetServer/Main.cs | 146 | ||||
-rw-r--r-- | OpenSim/Grid/AssetServer/Properties/AssemblyInfo.cs | 63 | ||||
-rw-r--r-- | OpenSim/Grid/InventoryServer/AuthedSessionCache.cs | 133 | ||||
-rw-r--r-- | OpenSim/Grid/InventoryServer/GridInventoryService.cs | 256 | ||||
-rw-r--r-- | OpenSim/Grid/InventoryServer/InventoryServiceBase.cs | 519 | ||||
-rw-r--r-- | OpenSim/Grid/InventoryServer/Main.cs | 182 | ||||
-rw-r--r-- | prebuild.xml | 64 |
11 files changed, 1 insertions, 1704 deletions
diff --git a/OpenSim/Framework/Servers/BaseGetAssetStreamHandler.cs b/OpenSim/Framework/Servers/BaseGetAssetStreamHandler.cs deleted file mode 100644 index 8372ae7..0000000 --- a/OpenSim/Framework/Servers/BaseGetAssetStreamHandler.cs +++ /dev/null | |||
@@ -1,205 +0,0 @@ | |||
1 | /* | ||
2 | * Copyright (c) Contributors, http://opensimulator.org/ | ||
3 | * See CONTRIBUTORS.TXT for a full list of copyright holders. | ||
4 | * | ||
5 | * Redistribution and use in source and binary forms, with or without | ||
6 | * modification, are permitted provided that the following conditions are met: | ||
7 | * * Redistributions of source code must retain the above copyright | ||
8 | * notice, this list of conditions and the following disclaimer. | ||
9 | * * Redistributions in binary form must reproduce the above copyright | ||
10 | * notice, this list of conditions and the following disclaimer in the | ||
11 | * documentation and/or other materials provided with the distribution. | ||
12 | * * Neither the name of the OpenSimulator Project nor the | ||
13 | * names of its contributors may be used to endorse or promote products | ||
14 | * derived from this software without specific prior written permission. | ||
15 | * | ||
16 | * THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS'' AND ANY | ||
17 | * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED | ||
18 | * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE | ||
19 | * DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY | ||
20 | * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES | ||
21 | * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; | ||
22 | * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND | ||
23 | * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT | ||
24 | * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS | ||
25 | * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | ||
26 | */ | ||
27 | |||
28 | using System; | ||
29 | using System.Collections.Generic; | ||
30 | using System.IO; | ||
31 | using System.Net; | ||
32 | using System.Reflection; | ||
33 | using System.Text; | ||
34 | using System.Text.RegularExpressions; | ||
35 | using System.Xml; | ||
36 | using System.Xml.Serialization; | ||
37 | using log4net; | ||
38 | using OpenMetaverse; | ||
39 | using OpenSim.Framework.Servers.HttpServer; | ||
40 | using OpenSim.Framework.Statistics; | ||
41 | |||
42 | namespace OpenSim.Framework.Servers | ||
43 | { | ||
44 | public abstract class BaseGetAssetStreamHandler : BaseStreamHandler | ||
45 | { | ||
46 | private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); | ||
47 | |||
48 | protected BaseGetAssetStreamHandler(string httpMethod, string path) : base(httpMethod, path) | ||
49 | { | ||
50 | } | ||
51 | |||
52 | protected abstract AssetBase GetAsset(UUID assetID); | ||
53 | |||
54 | public override byte[] Handle(string path, Stream request, | ||
55 | OSHttpRequest httpRequest, OSHttpResponse httpResponse) | ||
56 | { | ||
57 | byte[] result = new byte[] { }; | ||
58 | |||
59 | string[] p = SplitParams(path); | ||
60 | |||
61 | if (p.Length > 0) | ||
62 | { | ||
63 | UUID assetID; | ||
64 | |||
65 | if (!UUID.TryParse(p[0], out assetID)) | ||
66 | { | ||
67 | m_log.DebugFormat( | ||
68 | "[REST]: GET:/asset ignoring request with malformed UUID {0}", p[0]); | ||
69 | return result; | ||
70 | } | ||
71 | |||
72 | if (StatsManager.AssetStats != null) | ||
73 | { | ||
74 | StatsManager.AssetStats.AddRequest(); | ||
75 | } | ||
76 | |||
77 | AssetBase asset = GetAsset(assetID); | ||
78 | |||
79 | if (asset != null) | ||
80 | { | ||
81 | if (p.Length > 1 && p[1] == "data") | ||
82 | { | ||
83 | httpResponse.StatusCode = (int)HttpStatusCode.OK; | ||
84 | httpResponse.ContentType = SLAssetTypeToContentType(asset.Type); | ||
85 | result = asset.Data; | ||
86 | } | ||
87 | else | ||
88 | { | ||
89 | result = GetXml(asset); | ||
90 | } | ||
91 | } | ||
92 | else | ||
93 | { | ||
94 | m_log.DebugFormat("[REST]: GET:/asset failed to find {0}", assetID); | ||
95 | |||
96 | httpResponse.StatusCode = (int)HttpStatusCode.NotFound; | ||
97 | |||
98 | if (StatsManager.AssetStats != null) | ||
99 | { | ||
100 | StatsManager.AssetStats.AddNotFoundRequest(); | ||
101 | } | ||
102 | } | ||
103 | } | ||
104 | |||
105 | return result; | ||
106 | } | ||
107 | |||
108 | public static byte[] GetXml(AssetBase asset) | ||
109 | { | ||
110 | byte[] result; | ||
111 | XmlSerializer xs = new XmlSerializer(typeof(AssetBase)); | ||
112 | MemoryStream ms = new MemoryStream(); | ||
113 | XmlTextWriter xw = new XmlTextWriter(ms, Encoding.UTF8); | ||
114 | xw.Formatting = Formatting.Indented; | ||
115 | xs.Serialize(xw, asset); | ||
116 | xw.Flush(); | ||
117 | |||
118 | ms.Seek(0, SeekOrigin.Begin); | ||
119 | //StreamReader sr = new StreamReader(ms); | ||
120 | |||
121 | result = ms.GetBuffer(); | ||
122 | |||
123 | Array.Resize<byte>(ref result, (int)ms.Length); | ||
124 | return result; | ||
125 | } | ||
126 | |||
127 | public string ProcessAssetDataString(string data) | ||
128 | { | ||
129 | Regex regex = new Regex("(creator_id|owner_id)\\s+(\\S+)"); | ||
130 | |||
131 | // IUserService userService = null; | ||
132 | |||
133 | data = regex.Replace(data, delegate(Match m) | ||
134 | { | ||
135 | string result = String.Empty; | ||
136 | |||
137 | // string key = m.Groups[1].Captures[0].Value; | ||
138 | // | ||
139 | // string value = m.Groups[2].Captures[0].Value; | ||
140 | // | ||
141 | // Guid userUri; | ||
142 | // | ||
143 | // switch (key) | ||
144 | // { | ||
145 | // case "creator_id": | ||
146 | // userUri = new Guid(value); | ||
147 | // // result = "creator_url " + userService(userService, userUri); | ||
148 | // break; | ||
149 | // | ||
150 | // case "owner_id": | ||
151 | // userUri = new Guid(value); | ||
152 | // // result = "owner_url " + ResolveUserUri(userService, userUri); | ||
153 | // break; | ||
154 | // } | ||
155 | |||
156 | return result; | ||
157 | }); | ||
158 | |||
159 | return data; | ||
160 | } | ||
161 | |||
162 | private string SLAssetTypeToContentType(int assetType) | ||
163 | { | ||
164 | switch (assetType) | ||
165 | { | ||
166 | case 0: | ||
167 | return "image/jp2"; | ||
168 | case 1: | ||
169 | return "application/ogg"; | ||
170 | case 2: | ||
171 | return "application/x-metaverse-callingcard"; | ||
172 | case 3: | ||
173 | return "application/x-metaverse-landmark"; | ||
174 | case 5: | ||
175 | return "application/x-metaverse-clothing"; | ||
176 | case 6: | ||
177 | return "application/x-metaverse-primitive"; | ||
178 | case 7: | ||
179 | return "application/x-metaverse-notecard"; | ||
180 | case 8: | ||
181 | return "application/x-metaverse-folder"; | ||
182 | case 10: | ||
183 | return "application/x-metaverse-lsl"; | ||
184 | case 11: | ||
185 | return "application/x-metaverse-lso"; | ||
186 | case 12: | ||
187 | return "image/tga"; | ||
188 | case 13: | ||
189 | return "application/x-metaverse-bodypart"; | ||
190 | case 17: | ||
191 | return "audio/x-wav"; | ||
192 | case 19: | ||
193 | return "image/jpeg"; | ||
194 | case 20: | ||
195 | return "application/x-metaverse-animation"; | ||
196 | case 21: | ||
197 | return "application/x-metaverse-gesture"; | ||
198 | case 22: | ||
199 | return "application/x-metaverse-simstate"; | ||
200 | default: | ||
201 | return "application/octet-stream"; | ||
202 | } | ||
203 | } | ||
204 | } | ||
205 | } | ||
diff --git a/OpenSim/Framework/Servers/GetAssetStreamHandler.cs b/OpenSim/Framework/Servers/GetAssetStreamHandler.cs deleted file mode 100644 index c6958de..0000000 --- a/OpenSim/Framework/Servers/GetAssetStreamHandler.cs +++ /dev/null | |||
@@ -1,63 +0,0 @@ | |||
1 | /* | ||
2 | * Copyright (c) Contributors, http://opensimulator.org/ | ||
3 | * See CONTRIBUTORS.TXT for a full list of copyright holders. | ||
4 | * | ||
5 | * Redistribution and use in source and binary forms, with or without | ||
6 | * modification, are permitted provided that the following conditions are met: | ||
7 | * * Redistributions of source code must retain the above copyright | ||
8 | * notice, this list of conditions and the following disclaimer. | ||
9 | * * Redistributions in binary form must reproduce the above copyright | ||
10 | * notice, this list of conditions and the following disclaimer in the | ||
11 | * documentation and/or other materials provided with the distribution. | ||
12 | * * Neither the name of the OpenSimulator Project nor the | ||
13 | * names of its contributors may be used to endorse or promote products | ||
14 | * derived from this software without specific prior written permission. | ||
15 | * | ||
16 | * THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS'' AND ANY | ||
17 | * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED | ||
18 | * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE | ||
19 | * DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY | ||
20 | * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES | ||
21 | * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; | ||
22 | * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND | ||
23 | * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT | ||
24 | * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS | ||
25 | * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | ||
26 | */ | ||
27 | |||
28 | using System; | ||
29 | using System.IO; | ||
30 | using System.Reflection; | ||
31 | using System.Text; | ||
32 | using System.Text.RegularExpressions; | ||
33 | using System.Xml; | ||
34 | using System.Xml.Serialization; | ||
35 | using log4net; | ||
36 | using OpenMetaverse; | ||
37 | using OpenSim.Data; | ||
38 | using OpenSim.Framework; | ||
39 | using OpenSim.Framework.Servers; | ||
40 | using OpenSim.Framework.Servers.HttpServer; | ||
41 | using OpenSim.Framework.Statistics; | ||
42 | using System.Net; | ||
43 | |||
44 | namespace OpenSim.Framework.Servers | ||
45 | { | ||
46 | public class GetAssetStreamHandler : BaseGetAssetStreamHandler | ||
47 | { | ||
48 | // private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); | ||
49 | |||
50 | private readonly IAssetDataPlugin m_assetProvider; | ||
51 | |||
52 | public GetAssetStreamHandler(IAssetDataPlugin assetProvider) | ||
53 | : base("GET", "/assets") | ||
54 | { | ||
55 | m_assetProvider = assetProvider; | ||
56 | } | ||
57 | |||
58 | protected override AssetBase GetAsset(UUID assetID) | ||
59 | { | ||
60 | return m_assetProvider.GetAsset(assetID); | ||
61 | } | ||
62 | } | ||
63 | } | ||
diff --git a/OpenSim/Framework/Servers/PostAssetStreamHandler.cs b/OpenSim/Framework/Servers/PostAssetStreamHandler.cs deleted file mode 100644 index 8bf406c..0000000 --- a/OpenSim/Framework/Servers/PostAssetStreamHandler.cs +++ /dev/null | |||
@@ -1,72 +0,0 @@ | |||
1 | /* | ||
2 | * Copyright (c) Contributors, http://opensimulator.org/ | ||
3 | * See CONTRIBUTORS.TXT for a full list of copyright holders. | ||
4 | * | ||
5 | * Redistribution and use in source and binary forms, with or without | ||
6 | * modification, are permitted provided that the following conditions are met: | ||
7 | * * Redistributions of source code must retain the above copyright | ||
8 | * notice, this list of conditions and the following disclaimer. | ||
9 | * * Redistributions in binary form must reproduce the above copyright | ||
10 | * notice, this list of conditions and the following disclaimer in the | ||
11 | * documentation and/or other materials provided with the distribution. | ||
12 | * * Neither the name of the OpenSimulator Project nor the | ||
13 | * names of its contributors may be used to endorse or promote products | ||
14 | * derived from this software without specific prior written permission. | ||
15 | * | ||
16 | * THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS'' AND ANY | ||
17 | * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED | ||
18 | * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE | ||
19 | * DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY | ||
20 | * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES | ||
21 | * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; | ||
22 | * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND | ||
23 | * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT | ||
24 | * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS | ||
25 | * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | ||
26 | */ | ||
27 | |||
28 | using System.IO; | ||
29 | using System.Reflection; | ||
30 | using System.Xml.Serialization; | ||
31 | using log4net; | ||
32 | using OpenMetaverse; | ||
33 | using OpenSim.Data; | ||
34 | using OpenSim.Framework; | ||
35 | using OpenSim.Framework.Servers.HttpServer; | ||
36 | |||
37 | namespace OpenSim.Framework.Servers | ||
38 | { | ||
39 | public class PostAssetStreamHandler : BaseStreamHandler | ||
40 | { | ||
41 | private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); | ||
42 | |||
43 | // private OpenAsset_Main m_assetManager; | ||
44 | private IAssetDataPlugin m_assetProvider; | ||
45 | |||
46 | public override byte[] Handle(string path, Stream request, | ||
47 | OSHttpRequest httpRequest, OSHttpResponse httpResponse) | ||
48 | { | ||
49 | string param = GetParam(path); | ||
50 | |||
51 | UUID assetId; | ||
52 | if (param.Length > 0) | ||
53 | UUID.TryParse(param, out assetId); | ||
54 | // byte[] txBuffer = new byte[4096]; | ||
55 | |||
56 | XmlSerializer xs = new XmlSerializer(typeof (AssetBase)); | ||
57 | AssetBase asset = (AssetBase) xs.Deserialize(request); | ||
58 | |||
59 | m_log.InfoFormat("[REST]: Creating asset {0}", asset.FullID); | ||
60 | m_assetProvider.StoreAsset(asset); | ||
61 | |||
62 | return new byte[] {}; | ||
63 | } | ||
64 | |||
65 | public PostAssetStreamHandler(IAssetDataPlugin assetProvider) | ||
66 | : base("POST", "/assets") | ||
67 | { | ||
68 | // m_assetManager = assetManager; | ||
69 | m_assetProvider = assetProvider; | ||
70 | } | ||
71 | } | ||
72 | } | ||
diff --git a/OpenSim/Framework/Servers/VersionInfo.cs b/OpenSim/Framework/Servers/VersionInfo.cs index 743ca69..6f9b00c 100644 --- a/OpenSim/Framework/Servers/VersionInfo.cs +++ b/OpenSim/Framework/Servers/VersionInfo.cs | |||
@@ -69,6 +69,6 @@ namespace OpenSim | |||
69 | /// of the code that is too old. | 69 | /// of the code that is too old. |
70 | /// | 70 | /// |
71 | /// </value> | 71 | /// </value> |
72 | public readonly static int MajorInterfaceVersion = 5; | 72 | public readonly static int MajorInterfaceVersion = 6; |
73 | } | 73 | } |
74 | } | 74 | } |
diff --git a/OpenSim/Grid/AssetServer/Main.cs b/OpenSim/Grid/AssetServer/Main.cs deleted file mode 100644 index ac8f888..0000000 --- a/OpenSim/Grid/AssetServer/Main.cs +++ /dev/null | |||
@@ -1,146 +0,0 @@ | |||
1 | /* | ||
2 | * Copyright (c) Contributors, http://opensimulator.org/ | ||
3 | * See CONTRIBUTORS.TXT for a full list of copyright holders. | ||
4 | * | ||
5 | * Redistribution and use in source and binary forms, with or without | ||
6 | * modification, are permitted provided that the following conditions are met: | ||
7 | * * Redistributions of source code must retain the above copyright | ||
8 | * notice, this list of conditions and the following disclaimer. | ||
9 | * * Redistributions in binary form must reproduce the above copyright | ||
10 | * notice, this list of conditions and the following disclaimer in the | ||
11 | * documentation and/or other materials provided with the distribution. | ||
12 | * * Neither the name of the OpenSimulator Project nor the | ||
13 | * names of its contributors may be used to endorse or promote products | ||
14 | * derived from this software without specific prior written permission. | ||
15 | * | ||
16 | * THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS'' AND ANY | ||
17 | * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED | ||
18 | * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE | ||
19 | * DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY | ||
20 | * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES | ||
21 | * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; | ||
22 | * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND | ||
23 | * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT | ||
24 | * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS | ||
25 | * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | ||
26 | */ | ||
27 | |||
28 | using System; | ||
29 | using System.IO; | ||
30 | using System.Reflection; | ||
31 | using log4net; | ||
32 | using log4net.Config; | ||
33 | using OpenMetaverse; | ||
34 | using OpenSim.Data; | ||
35 | using OpenSim.Framework; | ||
36 | using OpenSim.Framework.AssetLoader.Filesystem; | ||
37 | using OpenSim.Framework.Console; | ||
38 | using OpenSim.Framework.Servers; | ||
39 | using OpenSim.Framework.Servers.HttpServer; | ||
40 | using OpenSim.Framework.Statistics; | ||
41 | |||
42 | namespace OpenSim.Grid.AssetServer | ||
43 | { | ||
44 | /// <summary> | ||
45 | /// An asset server | ||
46 | /// </summary> | ||
47 | public class OpenAsset_Main : BaseOpenSimServer | ||
48 | { | ||
49 | private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); | ||
50 | |||
51 | public static OpenAsset_Main assetserver; | ||
52 | |||
53 | // Temporarily hardcoded - should be a plugin | ||
54 | protected IAssetLoader assetLoader = new AssetLoaderFileSystem(); | ||
55 | |||
56 | private IAssetDataPlugin m_assetProvider; | ||
57 | |||
58 | public static void Main(string[] args) | ||
59 | { | ||
60 | XmlConfigurator.Configure(); | ||
61 | |||
62 | assetserver = new OpenAsset_Main(); | ||
63 | assetserver.Startup(); | ||
64 | |||
65 | assetserver.Work(); | ||
66 | } | ||
67 | |||
68 | private void Work() | ||
69 | { | ||
70 | m_console.Output("Enter help for a list of commands"); | ||
71 | |||
72 | while (true) | ||
73 | { | ||
74 | m_console.Prompt(); | ||
75 | } | ||
76 | } | ||
77 | |||
78 | public OpenAsset_Main() | ||
79 | { | ||
80 | m_console = new LocalConsole("Asset"); | ||
81 | |||
82 | MainConsole.Instance = m_console; | ||
83 | } | ||
84 | |||
85 | protected override void StartupSpecific() | ||
86 | { | ||
87 | AssetConfig config = new AssetConfig("ASSET SERVER", (Path.Combine(Util.configDir(), "AssetServer_Config.xml"))); | ||
88 | |||
89 | m_log.Info("[ASSET]: Setting up asset DB"); | ||
90 | setupDB(config); | ||
91 | |||
92 | m_log.Info("[ASSET]: Loading default asset set from '" + config.AssetSetsLocation + "'"); | ||
93 | LoadDefaultAssets(config.AssetSetsLocation); | ||
94 | |||
95 | m_log.Info("[ASSET]: Starting HTTP process"); | ||
96 | m_httpServer = new BaseHttpServer(config.HttpPort); | ||
97 | |||
98 | m_stats = StatsManager.StartCollectingAssetStats(); | ||
99 | |||
100 | AddHttpHandlers(); | ||
101 | |||
102 | m_httpServer.Start(); | ||
103 | |||
104 | base.StartupSpecific(); | ||
105 | } | ||
106 | |||
107 | protected void AddHttpHandlers() | ||
108 | { | ||
109 | m_httpServer.AddStreamHandler(new GetAssetStreamHandler(m_assetProvider)); | ||
110 | m_httpServer.AddStreamHandler(new PostAssetStreamHandler(m_assetProvider)); | ||
111 | } | ||
112 | |||
113 | public byte[] GetAssetData(UUID assetID, bool isTexture) | ||
114 | { | ||
115 | return null; | ||
116 | } | ||
117 | |||
118 | public void setupDB(AssetConfig config) | ||
119 | { | ||
120 | try | ||
121 | { | ||
122 | m_assetProvider = DataPluginFactory.LoadDataPlugin<IAssetDataPlugin>(config.DatabaseProvider, config.DatabaseConnect); | ||
123 | if (m_assetProvider == null) | ||
124 | { | ||
125 | m_log.Error("[ASSET]: Failed to load a database plugin, server halting"); | ||
126 | Environment.Exit(-1); | ||
127 | } | ||
128 | } | ||
129 | catch (Exception e) | ||
130 | { | ||
131 | m_log.Warn("[ASSET]: setupDB() - Exception occured"); | ||
132 | m_log.Warn("[ASSET]: " + e.ToString()); | ||
133 | } | ||
134 | } | ||
135 | |||
136 | public void LoadDefaultAssets(string pAssetSetsLocation) | ||
137 | { | ||
138 | assetLoader.ForEachDefaultXmlAsset(pAssetSetsLocation, StoreAsset); | ||
139 | } | ||
140 | |||
141 | protected void StoreAsset(AssetBase asset) | ||
142 | { | ||
143 | m_assetProvider.StoreAsset(asset); | ||
144 | } | ||
145 | } | ||
146 | } | ||
diff --git a/OpenSim/Grid/AssetServer/Properties/AssemblyInfo.cs b/OpenSim/Grid/AssetServer/Properties/AssemblyInfo.cs deleted file mode 100644 index 5d67e3f..0000000 --- a/OpenSim/Grid/AssetServer/Properties/AssemblyInfo.cs +++ /dev/null | |||
@@ -1,63 +0,0 @@ | |||
1 | /* | ||
2 | * Copyright (c) Contributors, http://opensimulator.org/ | ||
3 | * See CONTRIBUTORS.TXT for a full list of copyright holders. | ||
4 | * | ||
5 | * Redistribution and use in source and binary forms, with or without | ||
6 | * modification, are permitted provided that the following conditions are met: | ||
7 | * * Redistributions of source code must retain the above copyright | ||
8 | * notice, this list of conditions and the following disclaimer. | ||
9 | * * Redistributions in binary form must reproduce the above copyright | ||
10 | * notice, this list of conditions and the following disclaimer in the | ||
11 | * documentation and/or other materials provided with the distribution. | ||
12 | * * Neither the name of the OpenSimulator Project nor the | ||
13 | * names of its contributors may be used to endorse or promote products | ||
14 | * derived from this software without specific prior written permission. | ||
15 | * | ||
16 | * THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS'' AND ANY | ||
17 | * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED | ||
18 | * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE | ||
19 | * DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY | ||
20 | * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES | ||
21 | * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; | ||
22 | * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND | ||
23 | * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT | ||
24 | * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS | ||
25 | * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | ||
26 | */ | ||
27 | |||
28 | using System.Reflection; | ||
29 | using System.Runtime.InteropServices; | ||
30 | |||
31 | // General information about an assembly is controlled through the following | ||
32 | // set of attributes. Change these attribute values to modify the information | ||
33 | // associated with an assembly. | ||
34 | |||
35 | [assembly : AssemblyTitle("OGS-AssetServer")] | ||
36 | [assembly : AssemblyDescription("")] | ||
37 | [assembly : AssemblyConfiguration("")] | ||
38 | [assembly : AssemblyCompany("http://opensimulator.org")] | ||
39 | [assembly : AssemblyProduct("OGS-AssetServer")] | ||
40 | [assembly : AssemblyCopyright("Copyright (c) OpenSimulator.org Developers 2007-2009")] | ||
41 | [assembly : AssemblyTrademark("")] | ||
42 | [assembly : AssemblyCulture("")] | ||
43 | |||
44 | // Setting ComVisible to false makes the types in this assembly not visible | ||
45 | // to COM components. If you need to access a type in this assembly from | ||
46 | // COM, set the ComVisible attribute to true on that type. | ||
47 | |||
48 | [assembly : ComVisible(false)] | ||
49 | |||
50 | // The following GUID is for the ID of the typelib if this project is exposed to COM | ||
51 | |||
52 | [assembly : Guid("b541b244-3d1d-4625-9003-bc2a3a6a39a4")] | ||
53 | |||
54 | // Version information for an assembly consists of the following four values: | ||
55 | // | ||
56 | // Major Version | ||
57 | // Minor Version | ||
58 | // Build Number | ||
59 | // Revision | ||
60 | // | ||
61 | |||
62 | [assembly : AssemblyVersion("0.6.5.*")] | ||
63 | [assembly : AssemblyFileVersion("0.6.5.0")] | ||
diff --git a/OpenSim/Grid/InventoryServer/AuthedSessionCache.cs b/OpenSim/Grid/InventoryServer/AuthedSessionCache.cs deleted file mode 100644 index dadf34a..0000000 --- a/OpenSim/Grid/InventoryServer/AuthedSessionCache.cs +++ /dev/null | |||
@@ -1,133 +0,0 @@ | |||
1 | /* | ||
2 | * Copyright (c) Contributors, http://opensimulator.org/ | ||
3 | * See CONTRIBUTORS.TXT for a full list of copyright holders. | ||
4 | * | ||
5 | * Redistribution and use in source and binary forms, with or without | ||
6 | * modification, are permitted provided that the following conditions are met: | ||
7 | * * Redistributions of source code must retain the above copyright | ||
8 | * notice, this list of conditions and the following disclaimer. | ||
9 | * * Redistributions in binary form must reproduce the above copyright | ||
10 | * notice, this list of conditions and the following disclaimer in the | ||
11 | * documentation and/or other materials provided with the distribution. | ||
12 | * * Neither the name of the OpenSimulator Project nor the | ||
13 | * names of its contributors may be used to endorse or promote products | ||
14 | * derived from this software without specific prior written permission. | ||
15 | * | ||
16 | * THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS'' AND ANY | ||
17 | * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED | ||
18 | * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE | ||
19 | * DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY | ||
20 | * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES | ||
21 | * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; | ||
22 | * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND | ||
23 | * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT | ||
24 | * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS | ||
25 | * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | ||
26 | */ | ||
27 | |||
28 | using System; | ||
29 | using System.Collections.Generic; | ||
30 | |||
31 | namespace OpenSim.Grid.InventoryServer | ||
32 | { | ||
33 | public class AuthedSessionCache | ||
34 | { | ||
35 | public class CacheData | ||
36 | { | ||
37 | private static readonly DateTime UNIX_EPOCH = new DateTime(1970, 1, 1); | ||
38 | private string m_session_id; | ||
39 | private string m_agent_id; | ||
40 | private int m_expire; | ||
41 | |||
42 | private int get_current_unix_time() | ||
43 | { | ||
44 | return (int)(DateTime.UtcNow - UNIX_EPOCH).TotalSeconds; | ||
45 | } | ||
46 | |||
47 | public CacheData(string sid, string aid) | ||
48 | { | ||
49 | m_session_id = sid; | ||
50 | m_agent_id = aid; | ||
51 | m_expire = get_current_unix_time() + DEFAULT_LIFETIME; | ||
52 | } | ||
53 | |||
54 | public CacheData(string sid, string aid, int time_now) | ||
55 | { | ||
56 | m_session_id = sid; | ||
57 | m_agent_id = aid; | ||
58 | m_expire = time_now + DEFAULT_LIFETIME; | ||
59 | } | ||
60 | |||
61 | public string SessionID | ||
62 | { | ||
63 | get { return m_session_id; } | ||
64 | set { m_session_id = value; } | ||
65 | } | ||
66 | |||
67 | public string AgentID | ||
68 | { | ||
69 | get { return m_agent_id; } | ||
70 | set { m_agent_id = value; } | ||
71 | } | ||
72 | |||
73 | public bool isExpired | ||
74 | { | ||
75 | get { return m_expire < get_current_unix_time(); } | ||
76 | } | ||
77 | |||
78 | public void Renew() | ||
79 | { | ||
80 | m_expire = get_current_unix_time() + DEFAULT_LIFETIME; | ||
81 | } | ||
82 | } | ||
83 | |||
84 | private static readonly int DEFAULT_LIFETIME = 30; | ||
85 | private Dictionary<string, CacheData> m_authed_sessions = new Dictionary<string,CacheData>(); | ||
86 | // private int m_session_lifetime = DEFAULT_LIFETIME; | ||
87 | |||
88 | public AuthedSessionCache() | ||
89 | { | ||
90 | // m_session_lifetime = DEFAULT_LIFETIME; | ||
91 | } | ||
92 | |||
93 | public AuthedSessionCache(int timeout) | ||
94 | { | ||
95 | // m_session_lifetime = timeout; | ||
96 | } | ||
97 | |||
98 | public CacheData getCachedSession(string session_id, string agent_id) | ||
99 | { | ||
100 | CacheData ret = null; | ||
101 | lock (m_authed_sessions) | ||
102 | { | ||
103 | if (m_authed_sessions.ContainsKey(session_id)) | ||
104 | { | ||
105 | CacheData cached_session = m_authed_sessions[session_id]; | ||
106 | if (!cached_session.isExpired && cached_session.AgentID == agent_id) | ||
107 | { | ||
108 | ret = m_authed_sessions[session_id]; | ||
109 | // auto renew | ||
110 | m_authed_sessions[session_id].Renew(); | ||
111 | } | ||
112 | } | ||
113 | } | ||
114 | return ret; | ||
115 | } | ||
116 | |||
117 | public void Add(string session_id, string agent_id) | ||
118 | { | ||
119 | CacheData data = new CacheData(session_id, agent_id); | ||
120 | lock (m_authed_sessions) | ||
121 | { | ||
122 | if (m_authed_sessions.ContainsKey(session_id)) | ||
123 | { | ||
124 | m_authed_sessions[session_id] = data; | ||
125 | } | ||
126 | else | ||
127 | { | ||
128 | m_authed_sessions.Add(session_id, data); | ||
129 | } | ||
130 | } | ||
131 | } | ||
132 | } | ||
133 | } | ||
diff --git a/OpenSim/Grid/InventoryServer/GridInventoryService.cs b/OpenSim/Grid/InventoryServer/GridInventoryService.cs deleted file mode 100644 index 0704faa..0000000 --- a/OpenSim/Grid/InventoryServer/GridInventoryService.cs +++ /dev/null | |||
@@ -1,256 +0,0 @@ | |||
1 | /* | ||
2 | * Copyright (c) Contributors, http://opensimulator.org/ | ||
3 | * See CONTRIBUTORS.TXT for a full list of copyright holders. | ||
4 | * | ||
5 | * Redistribution and use in source and binary forms, with or without | ||
6 | * modification, are permitted provided that the following conditions are met: | ||
7 | * * Redistributions of source code must retain the above copyright | ||
8 | * notice, this list of conditions and the following disclaimer. | ||
9 | * * Redistributions in binary form must reproduce the above copyright | ||
10 | * notice, this list of conditions and the following disclaimer in the | ||
11 | * documentation and/or other materials provided with the distribution. | ||
12 | * * Neither the name of the OpenSimulator Project nor the | ||
13 | * names of its contributors may be used to endorse or promote products | ||
14 | * derived from this software without specific prior written permission. | ||
15 | * | ||
16 | * THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS'' AND ANY | ||
17 | * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED | ||
18 | * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE | ||
19 | * DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY | ||
20 | * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES | ||
21 | * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; | ||
22 | * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND | ||
23 | * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT | ||
24 | * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS | ||
25 | * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | ||
26 | */ | ||
27 | |||
28 | using System; | ||
29 | using System.Collections; | ||
30 | using System.Collections.Generic; | ||
31 | using System.Net; | ||
32 | using System.Reflection; | ||
33 | using log4net; | ||
34 | using Nwc.XmlRpc; | ||
35 | using OpenMetaverse; | ||
36 | using OpenSim.Framework; | ||
37 | using OpenSim.Framework.Communications; | ||
38 | using OpenSim.Framework.Communications.Cache; | ||
39 | |||
40 | namespace OpenSim.Grid.InventoryServer | ||
41 | { | ||
42 | /// <summary> | ||
43 | /// Used on a grid server to satisfy external inventory requests | ||
44 | /// </summary> | ||
45 | public class GridInventoryService : InventoryServiceBase | ||
46 | { | ||
47 | private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); | ||
48 | |||
49 | private bool m_doLookup = false; | ||
50 | |||
51 | public bool DoLookup | ||
52 | { | ||
53 | get { return m_doLookup; } | ||
54 | set { m_doLookup = value; } | ||
55 | } | ||
56 | |||
57 | private static readonly int INVENTORY_DEFAULT_SESSION_TIME = 30; // secs | ||
58 | |||
59 | private string m_userserver_url; | ||
60 | private AuthedSessionCache m_session_cache = new AuthedSessionCache(INVENTORY_DEFAULT_SESSION_TIME); | ||
61 | |||
62 | public GridInventoryService(string userserver_url) | ||
63 | { | ||
64 | m_userserver_url = userserver_url; | ||
65 | } | ||
66 | |||
67 | /// <summary> | ||
68 | /// Check that the source of an inventory request is one that we trust. | ||
69 | /// </summary> | ||
70 | /// <param name="peer"></param> | ||
71 | /// <returns></returns> | ||
72 | public bool CheckTrustSource(IPEndPoint peer) | ||
73 | { | ||
74 | if (m_doLookup) | ||
75 | { | ||
76 | m_log.InfoFormat("[GRID AGENT INVENTORY]: Checking trusted source {0}", peer); | ||
77 | UriBuilder ub = new UriBuilder(m_userserver_url); | ||
78 | IPAddress[] uaddrs = Dns.GetHostAddresses(ub.Host); | ||
79 | foreach (IPAddress uaddr in uaddrs) | ||
80 | { | ||
81 | if (uaddr.Equals(peer.Address)) | ||
82 | { | ||
83 | return true; | ||
84 | } | ||
85 | } | ||
86 | |||
87 | m_log.WarnFormat( | ||
88 | "[GRID AGENT INVENTORY]: Rejecting request since source {0} was not in the list of trusted sources", | ||
89 | peer); | ||
90 | |||
91 | return false; | ||
92 | } | ||
93 | else | ||
94 | { | ||
95 | return true; | ||
96 | } | ||
97 | } | ||
98 | |||
99 | /// <summary> | ||
100 | /// Check that the source of an inventory request for a particular agent is a current session belonging to | ||
101 | /// that agent. | ||
102 | /// </summary> | ||
103 | /// <param name="session_id"></param> | ||
104 | /// <param name="avatar_id"></param> | ||
105 | /// <returns></returns> | ||
106 | public bool CheckAuthSession(string session_id, string avatar_id) | ||
107 | { | ||
108 | if (m_doLookup) | ||
109 | { | ||
110 | m_log.InfoFormat("[GRID AGENT INVENTORY]: checking authed session {0} {1}", session_id, avatar_id); | ||
111 | |||
112 | if (m_session_cache.getCachedSession(session_id, avatar_id) == null) | ||
113 | { | ||
114 | // cache miss, ask userserver | ||
115 | Hashtable requestData = new Hashtable(); | ||
116 | requestData["avatar_uuid"] = avatar_id; | ||
117 | requestData["session_id"] = session_id; | ||
118 | ArrayList SendParams = new ArrayList(); | ||
119 | SendParams.Add(requestData); | ||
120 | XmlRpcRequest UserReq = new XmlRpcRequest("check_auth_session", SendParams); | ||
121 | XmlRpcResponse UserResp = UserReq.Send(m_userserver_url, 3000); | ||
122 | |||
123 | Hashtable responseData = (Hashtable)UserResp.Value; | ||
124 | if (responseData.ContainsKey("auth_session") && responseData["auth_session"].ToString() == "TRUE") | ||
125 | { | ||
126 | m_log.Info("[GRID AGENT INVENTORY]: got authed session from userserver"); | ||
127 | // add to cache; the session time will be automatically renewed | ||
128 | m_session_cache.Add(session_id, avatar_id); | ||
129 | return true; | ||
130 | } | ||
131 | } | ||
132 | else | ||
133 | { | ||
134 | // cache hits | ||
135 | m_log.Info("[GRID AGENT INVENTORY]: got authed session from cache"); | ||
136 | return true; | ||
137 | } | ||
138 | |||
139 | m_log.Warn("[GRID AGENT INVENTORY]: unknown session_id, request rejected"); | ||
140 | return false; | ||
141 | } | ||
142 | else | ||
143 | { | ||
144 | return true; | ||
145 | } | ||
146 | } | ||
147 | |||
148 | /// <summary> | ||
149 | /// Return a user's entire inventory | ||
150 | /// </summary> | ||
151 | /// <param name="rawUserID"></param> | ||
152 | /// <returns>The user's inventory. If an inventory cannot be found then an empty collection is returned.</returns> | ||
153 | public InventoryCollection GetUserInventory(Guid rawUserID) | ||
154 | { | ||
155 | UUID userID = new UUID(rawUserID); | ||
156 | |||
157 | m_log.InfoFormat("[GRID AGENT INVENTORY]: Processing request for inventory of {0}", userID); | ||
158 | |||
159 | // Uncomment me to simulate a slow responding inventory server | ||
160 | //Thread.Sleep(16000); | ||
161 | |||
162 | InventoryCollection invCollection = new InventoryCollection(); | ||
163 | |||
164 | List<InventoryFolderBase> allFolders = GetInventorySkeleton(userID); | ||
165 | |||
166 | if (null == allFolders) | ||
167 | { | ||
168 | m_log.WarnFormat("[GRID AGENT INVENTORY]: No inventory found for user {0}", rawUserID); | ||
169 | |||
170 | return invCollection; | ||
171 | } | ||
172 | |||
173 | List<InventoryItemBase> allItems = new List<InventoryItemBase>(); | ||
174 | |||
175 | foreach (InventoryFolderBase folder in allFolders) | ||
176 | { | ||
177 | List<InventoryItemBase> items = RequestFolderItems(folder.ID); | ||
178 | |||
179 | if (items != null) | ||
180 | { | ||
181 | allItems.InsertRange(0, items); | ||
182 | } | ||
183 | } | ||
184 | |||
185 | invCollection.UserID = userID; | ||
186 | invCollection.Folders = allFolders; | ||
187 | invCollection.Items = allItems; | ||
188 | |||
189 | // foreach (InventoryFolderBase folder in invCollection.Folders) | ||
190 | // { | ||
191 | // m_log.DebugFormat("[GRID AGENT INVENTORY]: Sending back folder {0} {1}", folder.Name, folder.ID); | ||
192 | // } | ||
193 | // | ||
194 | // foreach (InventoryItemBase item in invCollection.Items) | ||
195 | // { | ||
196 | // m_log.DebugFormat("[GRID AGENT INVENTORY]: Sending back item {0} {1}, folder {2}", item.Name, item.ID, item.Folder); | ||
197 | // } | ||
198 | |||
199 | m_log.InfoFormat( | ||
200 | "[GRID AGENT INVENTORY]: Sending back inventory response to user {0} containing {1} folders and {2} items", | ||
201 | invCollection.UserID, invCollection.Folders.Count, invCollection.Items.Count); | ||
202 | |||
203 | return invCollection; | ||
204 | } | ||
205 | |||
206 | public List<InventoryItemBase> GetFolderItems(Guid folderID) | ||
207 | { | ||
208 | List<InventoryItemBase> allItems = new List<InventoryItemBase>(); | ||
209 | |||
210 | |||
211 | List<InventoryItemBase> items = RequestFolderItems(new UUID(folderID)); | ||
212 | |||
213 | if (items != null) | ||
214 | { | ||
215 | allItems.InsertRange(0, items); | ||
216 | } | ||
217 | m_log.InfoFormat( | ||
218 | "[GRID AGENT INVENTORY]: Sending back inventory response containing {0} items", allItems.Count.ToString()); | ||
219 | return allItems; | ||
220 | } | ||
221 | |||
222 | /// <summary> | ||
223 | /// Guid to UUID wrapper for same name IInventoryServices method | ||
224 | /// </summary> | ||
225 | /// <param name="rawUserID"></param> | ||
226 | /// <returns></returns> | ||
227 | public List<InventoryFolderBase> GetInventorySkeleton(Guid rawUserID) | ||
228 | { | ||
229 | UUID userID = new UUID(rawUserID); | ||
230 | return GetInventorySkeleton(userID); | ||
231 | } | ||
232 | |||
233 | /// <summary> | ||
234 | /// Create an inventory for the given user. | ||
235 | /// </summary> | ||
236 | /// <param name="rawUserID"></param> | ||
237 | /// <returns></returns> | ||
238 | public bool CreateUsersInventory(Guid rawUserID) | ||
239 | { | ||
240 | UUID userID = new UUID(rawUserID); | ||
241 | |||
242 | m_log.InfoFormat("[GRID AGENT INVENTORY]: Creating new set of inventory folders for user {0}", userID); | ||
243 | |||
244 | return CreateNewUserInventory(userID); | ||
245 | } | ||
246 | |||
247 | public List<InventoryItemBase> GetActiveGestures(Guid rawUserID) | ||
248 | { | ||
249 | UUID userID = new UUID(rawUserID); | ||
250 | |||
251 | m_log.InfoFormat("[GRID AGENT INVENTORY]: fetching active gestures for user {0}", userID); | ||
252 | |||
253 | return GetActiveGestures(userID); | ||
254 | } | ||
255 | } | ||
256 | } | ||
diff --git a/OpenSim/Grid/InventoryServer/InventoryServiceBase.cs b/OpenSim/Grid/InventoryServer/InventoryServiceBase.cs deleted file mode 100644 index f8b4949..0000000 --- a/OpenSim/Grid/InventoryServer/InventoryServiceBase.cs +++ /dev/null | |||
@@ -1,519 +0,0 @@ | |||
1 | /* | ||
2 | * Copyright (c) Contributors, http://opensimulator.org/ | ||
3 | * See CONTRIBUTORS.TXT for a full list of copyright holders. | ||
4 | * | ||
5 | * Redistribution and use in source and binary forms, with or without | ||
6 | * modification, are permitted provided that the following conditions are met: | ||
7 | * * Redistributions of source code must retain the above copyright | ||
8 | * notice, this list of conditions and the following disclaimer. | ||
9 | * * Redistributions in binary form must reproduce the above copyright | ||
10 | * notice, this list of conditions and the following disclaimer in the | ||
11 | * documentation and/or other materials provided with the distribution. | ||
12 | * * Neither the name of the OpenSimulator Project nor the | ||
13 | * names of its contributors may be used to endorse or promote products | ||
14 | * derived from this software without specific prior written permission. | ||
15 | * | ||
16 | * THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS'' AND ANY | ||
17 | * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED | ||
18 | * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE | ||
19 | * DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY | ||
20 | * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES | ||
21 | * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; | ||
22 | * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND | ||
23 | * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT | ||
24 | * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS | ||
25 | * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | ||
26 | */ | ||
27 | |||
28 | using System.Collections.Generic; | ||
29 | using System.Reflection; | ||
30 | using log4net; | ||
31 | using OpenMetaverse; | ||
32 | using OpenSim.Data; | ||
33 | using OpenSim.Framework; | ||
34 | using OpenSim.Framework.Communications; | ||
35 | |||
36 | namespace OpenSim.Grid.InventoryServer | ||
37 | { | ||
38 | /// <summary> | ||
39 | /// Abstract base class used by local and grid implementations of an inventory service. | ||
40 | /// </summary> | ||
41 | public abstract class InventoryServiceBase : IInterServiceInventoryServices | ||
42 | { | ||
43 | |||
44 | private static readonly ILog m_log | ||
45 | = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); | ||
46 | |||
47 | protected List<IInventoryDataPlugin> m_plugins = new List<IInventoryDataPlugin>(); | ||
48 | |||
49 | #region Plugin methods | ||
50 | |||
51 | /// <summary> | ||
52 | /// Add a new inventory data plugin - plugins will be requested in the order they were added. | ||
53 | /// </summary> | ||
54 | /// <param name="plugin">The plugin that will provide data</param> | ||
55 | public void AddPlugin(IInventoryDataPlugin plugin) | ||
56 | { | ||
57 | m_plugins.Add(plugin); | ||
58 | } | ||
59 | |||
60 | /// <summary> | ||
61 | /// Adds a list of inventory data plugins, as described by `provider' | ||
62 | /// and `connect', to `m_plugins'. | ||
63 | /// </summary> | ||
64 | /// <param name="provider"> | ||
65 | /// The filename of the inventory server plugin DLL. | ||
66 | /// </param> | ||
67 | /// <param name="connect"> | ||
68 | /// The connection string for the storage backend. | ||
69 | /// </param> | ||
70 | public void AddPlugin(string provider, string connect) | ||
71 | { | ||
72 | m_plugins.AddRange(DataPluginFactory.LoadDataPlugins<IInventoryDataPlugin>(provider, connect)); | ||
73 | } | ||
74 | |||
75 | #endregion | ||
76 | |||
77 | #region IInventoryServices methods | ||
78 | |||
79 | public string Host | ||
80 | { | ||
81 | get { return "default"; } | ||
82 | } | ||
83 | |||
84 | public List<InventoryFolderBase> GetInventorySkeleton(UUID userId) | ||
85 | { | ||
86 | // m_log.DebugFormat("[AGENT INVENTORY]: Getting inventory skeleton for {0}", userId); | ||
87 | |||
88 | InventoryFolderBase rootFolder = RequestRootFolder(userId); | ||
89 | |||
90 | // Agent has no inventory structure yet. | ||
91 | if (null == rootFolder) | ||
92 | { | ||
93 | return null; | ||
94 | } | ||
95 | |||
96 | List<InventoryFolderBase> userFolders = new List<InventoryFolderBase>(); | ||
97 | |||
98 | userFolders.Add(rootFolder); | ||
99 | |||
100 | foreach (IInventoryDataPlugin plugin in m_plugins) | ||
101 | { | ||
102 | IList<InventoryFolderBase> folders = plugin.getFolderHierarchy(rootFolder.ID); | ||
103 | userFolders.AddRange(folders); | ||
104 | } | ||
105 | |||
106 | // foreach (InventoryFolderBase folder in userFolders) | ||
107 | // { | ||
108 | // m_log.DebugFormat("[AGENT INVENTORY]: Got folder {0} {1}", folder.name, folder.folderID); | ||
109 | // } | ||
110 | |||
111 | return userFolders; | ||
112 | } | ||
113 | |||
114 | // See IInventoryServices | ||
115 | public virtual bool HasInventoryForUser(UUID userID) | ||
116 | { | ||
117 | return false; | ||
118 | } | ||
119 | |||
120 | // See IInventoryServices | ||
121 | public virtual InventoryFolderBase RequestRootFolder(UUID userID) | ||
122 | { | ||
123 | // Retrieve the first root folder we get from the list of plugins. | ||
124 | foreach (IInventoryDataPlugin plugin in m_plugins) | ||
125 | { | ||
126 | InventoryFolderBase rootFolder = plugin.getUserRootFolder(userID); | ||
127 | if (rootFolder != null) | ||
128 | return rootFolder; | ||
129 | } | ||
130 | |||
131 | // Return nothing if no plugin was able to supply a root folder | ||
132 | return null; | ||
133 | } | ||
134 | |||
135 | // See IInventoryServices | ||
136 | public bool CreateNewUserInventory(UUID user) | ||
137 | { | ||
138 | InventoryFolderBase existingRootFolder = RequestRootFolder(user); | ||
139 | |||
140 | if (null != existingRootFolder) | ||
141 | { | ||
142 | m_log.WarnFormat( | ||
143 | "[AGENT INVENTORY]: Did not create a new inventory for user {0} since they already have " | ||
144 | + "a root inventory folder with id {1}", | ||
145 | user, existingRootFolder.ID); | ||
146 | } | ||
147 | else | ||
148 | { | ||
149 | UsersInventory inven = new UsersInventory(); | ||
150 | inven.CreateNewInventorySet(user); | ||
151 | AddNewInventorySet(inven); | ||
152 | |||
153 | return true; | ||
154 | } | ||
155 | |||
156 | return false; | ||
157 | } | ||
158 | |||
159 | public List<InventoryItemBase> GetActiveGestures(UUID userId) | ||
160 | { | ||
161 | List<InventoryItemBase> activeGestures = new List<InventoryItemBase>(); | ||
162 | foreach (IInventoryDataPlugin plugin in m_plugins) | ||
163 | { | ||
164 | activeGestures.AddRange(plugin.fetchActiveGestures(userId)); | ||
165 | } | ||
166 | |||
167 | return activeGestures; | ||
168 | } | ||
169 | |||
170 | #endregion | ||
171 | |||
172 | #region Methods used by GridInventoryService | ||
173 | |||
174 | public List<InventoryFolderBase> RequestSubFolders(UUID parentFolderID) | ||
175 | { | ||
176 | List<InventoryFolderBase> inventoryList = new List<InventoryFolderBase>(); | ||
177 | |||
178 | foreach (IInventoryDataPlugin plugin in m_plugins) | ||
179 | { | ||
180 | inventoryList.AddRange(plugin.getInventoryFolders(parentFolderID)); | ||
181 | } | ||
182 | |||
183 | return inventoryList; | ||
184 | } | ||
185 | |||
186 | public List<InventoryItemBase> RequestFolderItems(UUID folderID) | ||
187 | { | ||
188 | List<InventoryItemBase> itemsList = new List<InventoryItemBase>(); | ||
189 | |||
190 | foreach (IInventoryDataPlugin plugin in m_plugins) | ||
191 | { | ||
192 | itemsList.AddRange(plugin.getInventoryInFolder(folderID)); | ||
193 | } | ||
194 | |||
195 | return itemsList; | ||
196 | } | ||
197 | |||
198 | #endregion | ||
199 | |||
200 | // See IInventoryServices | ||
201 | public virtual bool AddFolder(InventoryFolderBase folder) | ||
202 | { | ||
203 | m_log.DebugFormat( | ||
204 | "[AGENT INVENTORY]: Adding folder {0} {1} to folder {2}", folder.Name, folder.ID, folder.ParentID); | ||
205 | |||
206 | foreach (IInventoryDataPlugin plugin in m_plugins) | ||
207 | { | ||
208 | plugin.addInventoryFolder(folder); | ||
209 | } | ||
210 | |||
211 | // FIXME: Should return false on failure | ||
212 | return true; | ||
213 | } | ||
214 | |||
215 | // See IInventoryServices | ||
216 | public virtual bool UpdateFolder(InventoryFolderBase folder) | ||
217 | { | ||
218 | m_log.DebugFormat( | ||
219 | "[AGENT INVENTORY]: Updating folder {0} {1} to folder {2}", folder.Name, folder.ID, folder.ParentID); | ||
220 | |||
221 | foreach (IInventoryDataPlugin plugin in m_plugins) | ||
222 | { | ||
223 | plugin.updateInventoryFolder(folder); | ||
224 | } | ||
225 | |||
226 | // FIXME: Should return false on failure | ||
227 | return true; | ||
228 | } | ||
229 | |||
230 | // See IInventoryServices | ||
231 | public virtual bool MoveFolder(InventoryFolderBase folder) | ||
232 | { | ||
233 | m_log.DebugFormat( | ||
234 | "[AGENT INVENTORY]: Moving folder {0} {1} to folder {2}", folder.Name, folder.ID, folder.ParentID); | ||
235 | |||
236 | foreach (IInventoryDataPlugin plugin in m_plugins) | ||
237 | { | ||
238 | plugin.moveInventoryFolder(folder); | ||
239 | } | ||
240 | |||
241 | // FIXME: Should return false on failure | ||
242 | return true; | ||
243 | } | ||
244 | |||
245 | // See IInventoryServices | ||
246 | public virtual bool AddItem(InventoryItemBase item) | ||
247 | { | ||
248 | m_log.DebugFormat( | ||
249 | "[AGENT INVENTORY]: Adding item {0} {1} to folder {2}", item.Name, item.ID, item.Folder); | ||
250 | |||
251 | foreach (IInventoryDataPlugin plugin in m_plugins) | ||
252 | { | ||
253 | plugin.addInventoryItem(item); | ||
254 | } | ||
255 | |||
256 | // FIXME: Should return false on failure | ||
257 | return true; | ||
258 | } | ||
259 | |||
260 | // See IInventoryServices | ||
261 | public virtual bool UpdateItem(InventoryItemBase item) | ||
262 | { | ||
263 | m_log.InfoFormat( | ||
264 | "[AGENT INVENTORY]: Updating item {0} {1} in folder {2}", item.Name, item.ID, item.Folder); | ||
265 | |||
266 | foreach (IInventoryDataPlugin plugin in m_plugins) | ||
267 | { | ||
268 | plugin.updateInventoryItem(item); | ||
269 | } | ||
270 | |||
271 | // FIXME: Should return false on failure | ||
272 | return true; | ||
273 | } | ||
274 | |||
275 | // See IInventoryServices | ||
276 | public virtual bool DeleteItem(InventoryItemBase item) | ||
277 | { | ||
278 | m_log.InfoFormat( | ||
279 | "[AGENT INVENTORY]: Deleting item {0} {1} from folder {2}", item.Name, item.ID, item.Folder); | ||
280 | |||
281 | foreach (IInventoryDataPlugin plugin in m_plugins) | ||
282 | { | ||
283 | plugin.deleteInventoryItem(item.ID); | ||
284 | } | ||
285 | |||
286 | // FIXME: Should return false on failure | ||
287 | return true; | ||
288 | } | ||
289 | |||
290 | public virtual InventoryItemBase QueryItem(InventoryItemBase item) | ||
291 | { | ||
292 | foreach (IInventoryDataPlugin plugin in m_plugins) | ||
293 | { | ||
294 | InventoryItemBase result = plugin.queryInventoryItem(item.ID); | ||
295 | if (result != null) | ||
296 | return result; | ||
297 | } | ||
298 | |||
299 | return null; | ||
300 | } | ||
301 | |||
302 | public virtual InventoryFolderBase QueryFolder(InventoryFolderBase item) | ||
303 | { | ||
304 | foreach (IInventoryDataPlugin plugin in m_plugins) | ||
305 | { | ||
306 | InventoryFolderBase result = plugin.queryInventoryFolder(item.ID); | ||
307 | if (result != null) | ||
308 | return result; | ||
309 | } | ||
310 | |||
311 | return null; | ||
312 | } | ||
313 | |||
314 | /// <summary> | ||
315 | /// Purge a folder of all items items and subfolders. | ||
316 | /// | ||
317 | /// FIXME: Really nasty in a sense, because we have to query the database to get information we may | ||
318 | /// already know... Needs heavy refactoring. | ||
319 | /// </summary> | ||
320 | /// <param name="folder"></param> | ||
321 | public virtual bool PurgeFolder(InventoryFolderBase folder) | ||
322 | { | ||
323 | m_log.DebugFormat( | ||
324 | "[AGENT INVENTORY]: Purging folder {0} {1} of its contents", folder.Name, folder.ID); | ||
325 | |||
326 | List<InventoryFolderBase> subFolders = RequestSubFolders(folder.ID); | ||
327 | |||
328 | foreach (InventoryFolderBase subFolder in subFolders) | ||
329 | { | ||
330 | // m_log.DebugFormat("[AGENT INVENTORY]: Deleting folder {0} {1}", subFolder.Name, subFolder.ID); | ||
331 | |||
332 | foreach (IInventoryDataPlugin plugin in m_plugins) | ||
333 | { | ||
334 | plugin.deleteInventoryFolder(subFolder.ID); | ||
335 | } | ||
336 | } | ||
337 | |||
338 | List<InventoryItemBase> items = RequestFolderItems(folder.ID); | ||
339 | |||
340 | foreach (InventoryItemBase item in items) | ||
341 | { | ||
342 | DeleteItem(item); | ||
343 | } | ||
344 | |||
345 | // FIXME: Should return false on failure | ||
346 | return true; | ||
347 | } | ||
348 | |||
349 | private void AddNewInventorySet(UsersInventory inventory) | ||
350 | { | ||
351 | foreach (InventoryFolderBase folder in inventory.Folders.Values) | ||
352 | { | ||
353 | AddFolder(folder); | ||
354 | } | ||
355 | } | ||
356 | |||
357 | public InventoryItemBase GetInventoryItem(UUID itemID) | ||
358 | { | ||
359 | foreach (IInventoryDataPlugin plugin in m_plugins) | ||
360 | { | ||
361 | InventoryItemBase item = plugin.getInventoryItem(itemID); | ||
362 | if (item != null) | ||
363 | return item; | ||
364 | } | ||
365 | |||
366 | return null; | ||
367 | } | ||
368 | |||
369 | /// <summary> | ||
370 | /// Used to create a new user inventory. | ||
371 | /// </summary> | ||
372 | private class UsersInventory | ||
373 | { | ||
374 | public Dictionary<UUID, InventoryFolderBase> Folders = new Dictionary<UUID, InventoryFolderBase>(); | ||
375 | public Dictionary<UUID, InventoryItemBase> Items = new Dictionary<UUID, InventoryItemBase>(); | ||
376 | |||
377 | public virtual void CreateNewInventorySet(UUID user) | ||
378 | { | ||
379 | InventoryFolderBase folder = new InventoryFolderBase(); | ||
380 | |||
381 | folder.ParentID = UUID.Zero; | ||
382 | folder.Owner = user; | ||
383 | folder.ID = UUID.Random(); | ||
384 | folder.Name = "My Inventory"; | ||
385 | folder.Type = (short)AssetType.Folder; | ||
386 | folder.Version = 1; | ||
387 | Folders.Add(folder.ID, folder); | ||
388 | |||
389 | UUID rootFolder = folder.ID; | ||
390 | |||
391 | folder = new InventoryFolderBase(); | ||
392 | folder.ParentID = rootFolder; | ||
393 | folder.Owner = user; | ||
394 | folder.ID = UUID.Random(); | ||
395 | folder.Name = "Animations"; | ||
396 | folder.Type = (short)AssetType.Animation; | ||
397 | folder.Version = 1; | ||
398 | Folders.Add(folder.ID, folder); | ||
399 | |||
400 | folder = new InventoryFolderBase(); | ||
401 | folder.ParentID = rootFolder; | ||
402 | folder.Owner = user; | ||
403 | folder.ID = UUID.Random(); | ||
404 | folder.Name = "Body Parts"; | ||
405 | folder.Type = (short)AssetType.Bodypart; | ||
406 | folder.Version = 1; | ||
407 | Folders.Add(folder.ID, folder); | ||
408 | |||
409 | folder = new InventoryFolderBase(); | ||
410 | folder.ParentID = rootFolder; | ||
411 | folder.Owner = user; | ||
412 | folder.ID = UUID.Random(); | ||
413 | folder.Name = "Calling Cards"; | ||
414 | folder.Type = (short)AssetType.CallingCard; | ||
415 | folder.Version = 1; | ||
416 | Folders.Add(folder.ID, folder); | ||
417 | |||
418 | folder = new InventoryFolderBase(); | ||
419 | folder.ParentID = rootFolder; | ||
420 | folder.Owner = user; | ||
421 | folder.ID = UUID.Random(); | ||
422 | folder.Name = "Clothing"; | ||
423 | folder.Type = (short)AssetType.Clothing; | ||
424 | folder.Version = 1; | ||
425 | Folders.Add(folder.ID, folder); | ||
426 | |||
427 | folder = new InventoryFolderBase(); | ||
428 | folder.ParentID = rootFolder; | ||
429 | folder.Owner = user; | ||
430 | folder.ID = UUID.Random(); | ||
431 | folder.Name = "Gestures"; | ||
432 | folder.Type = (short)AssetType.Gesture; | ||
433 | folder.Version = 1; | ||
434 | Folders.Add(folder.ID, folder); | ||
435 | |||
436 | folder = new InventoryFolderBase(); | ||
437 | folder.ParentID = rootFolder; | ||
438 | folder.Owner = user; | ||
439 | folder.ID = UUID.Random(); | ||
440 | folder.Name = "Landmarks"; | ||
441 | folder.Type = (short)AssetType.Landmark; | ||
442 | folder.Version = 1; | ||
443 | Folders.Add(folder.ID, folder); | ||
444 | |||
445 | folder = new InventoryFolderBase(); | ||
446 | folder.ParentID = rootFolder; | ||
447 | folder.Owner = user; | ||
448 | folder.ID = UUID.Random(); | ||
449 | folder.Name = "Lost And Found"; | ||
450 | folder.Type = (short)AssetType.LostAndFoundFolder; | ||
451 | folder.Version = 1; | ||
452 | Folders.Add(folder.ID, folder); | ||
453 | |||
454 | folder = new InventoryFolderBase(); | ||
455 | folder.ParentID = rootFolder; | ||
456 | folder.Owner = user; | ||
457 | folder.ID = UUID.Random(); | ||
458 | folder.Name = "Notecards"; | ||
459 | folder.Type = (short)AssetType.Notecard; | ||
460 | folder.Version = 1; | ||
461 | Folders.Add(folder.ID, folder); | ||
462 | |||
463 | folder = new InventoryFolderBase(); | ||
464 | folder.ParentID = rootFolder; | ||
465 | folder.Owner = user; | ||
466 | folder.ID = UUID.Random(); | ||
467 | folder.Name = "Objects"; | ||
468 | folder.Type = (short)AssetType.Object; | ||
469 | folder.Version = 1; | ||
470 | Folders.Add(folder.ID, folder); | ||
471 | |||
472 | folder = new InventoryFolderBase(); | ||
473 | folder.ParentID = rootFolder; | ||
474 | folder.Owner = user; | ||
475 | folder.ID = UUID.Random(); | ||
476 | folder.Name = "Photo Album"; | ||
477 | folder.Type = (short)AssetType.SnapshotFolder; | ||
478 | folder.Version = 1; | ||
479 | Folders.Add(folder.ID, folder); | ||
480 | |||
481 | folder = new InventoryFolderBase(); | ||
482 | folder.ParentID = rootFolder; | ||
483 | folder.Owner = user; | ||
484 | folder.ID = UUID.Random(); | ||
485 | folder.Name = "Scripts"; | ||
486 | folder.Type = (short)AssetType.LSLText; | ||
487 | folder.Version = 1; | ||
488 | Folders.Add(folder.ID, folder); | ||
489 | |||
490 | folder = new InventoryFolderBase(); | ||
491 | folder.ParentID = rootFolder; | ||
492 | folder.Owner = user; | ||
493 | folder.ID = UUID.Random(); | ||
494 | folder.Name = "Sounds"; | ||
495 | folder.Type = (short)AssetType.Sound; | ||
496 | folder.Version = 1; | ||
497 | Folders.Add(folder.ID, folder); | ||
498 | |||
499 | folder = new InventoryFolderBase(); | ||
500 | folder.ParentID = rootFolder; | ||
501 | folder.Owner = user; | ||
502 | folder.ID = UUID.Random(); | ||
503 | folder.Name = "Textures"; | ||
504 | folder.Type = (short)AssetType.Texture; | ||
505 | folder.Version = 1; | ||
506 | Folders.Add(folder.ID, folder); | ||
507 | |||
508 | folder = new InventoryFolderBase(); | ||
509 | folder.ParentID = rootFolder; | ||
510 | folder.Owner = user; | ||
511 | folder.ID = UUID.Random(); | ||
512 | folder.Name = "Trash"; | ||
513 | folder.Type = (short)AssetType.TrashFolder; | ||
514 | folder.Version = 1; | ||
515 | Folders.Add(folder.ID, folder); | ||
516 | } | ||
517 | } | ||
518 | } | ||
519 | } | ||
diff --git a/OpenSim/Grid/InventoryServer/Main.cs b/OpenSim/Grid/InventoryServer/Main.cs deleted file mode 100644 index 6106d93..0000000 --- a/OpenSim/Grid/InventoryServer/Main.cs +++ /dev/null | |||
@@ -1,182 +0,0 @@ | |||
1 | /* | ||
2 | * Copyright (c) Contributors, http://opensimulator.org/ | ||
3 | * See CONTRIBUTORS.TXT for a full list of copyright holders. | ||
4 | * | ||
5 | * Redistribution and use in source and binary forms, with or without | ||
6 | * modification, are permitted provided that the following conditions are met: | ||
7 | * * Redistributions of source code must retain the above copyright | ||
8 | * notice, this list of conditions and the following disclaimer. | ||
9 | * * Redistributions in binary form must reproduce the above copyright | ||
10 | * notice, this list of conditions and the following disclaimer in the | ||
11 | * documentation and/or other materials provided with the distribution. | ||
12 | * * Neither the name of the OpenSimulator Project nor the | ||
13 | * names of its contributors may be used to endorse or promote products | ||
14 | * derived from this software without specific prior written permission. | ||
15 | * | ||
16 | * THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS'' AND ANY | ||
17 | * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED | ||
18 | * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE | ||
19 | * DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY | ||
20 | * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES | ||
21 | * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; | ||
22 | * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND | ||
23 | * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT | ||
24 | * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS | ||
25 | * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | ||
26 | */ | ||
27 | |||
28 | using System; | ||
29 | using System.Collections.Generic; | ||
30 | using System.IO; | ||
31 | using System.Reflection; | ||
32 | using log4net; | ||
33 | using log4net.Config; | ||
34 | using OpenMetaverse; | ||
35 | using OpenSim.Framework; | ||
36 | using OpenSim.Framework.Communications.Services; | ||
37 | using OpenSim.Framework.Console; | ||
38 | using OpenSim.Framework.Servers; | ||
39 | using OpenSim.Framework.Servers.HttpServer; | ||
40 | |||
41 | namespace OpenSim.Grid.InventoryServer | ||
42 | { | ||
43 | public class OpenInventory_Main : BaseOpenSimServer | ||
44 | { | ||
45 | private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); | ||
46 | |||
47 | private GridInventoryService m_inventoryService; | ||
48 | //private HGInventoryService m_directInventoryService; | ||
49 | |||
50 | public const string LogName = "INVENTORY"; | ||
51 | |||
52 | public static void Main(string[] args) | ||
53 | { | ||
54 | XmlConfigurator.Configure(); | ||
55 | |||
56 | OpenInventory_Main theServer = new OpenInventory_Main(); | ||
57 | theServer.Startup(); | ||
58 | |||
59 | theServer.Work(); | ||
60 | } | ||
61 | |||
62 | public OpenInventory_Main() | ||
63 | { | ||
64 | m_console = new LocalConsole("Inventory"); | ||
65 | MainConsole.Instance = m_console; | ||
66 | } | ||
67 | |||
68 | protected override void StartupSpecific() | ||
69 | { | ||
70 | InventoryConfig config = new InventoryConfig(LogName, (Path.Combine(Util.configDir(), "InventoryServer_Config.xml"))); | ||
71 | |||
72 | m_inventoryService = new GridInventoryService(config.UserServerURL); | ||
73 | m_inventoryService.DoLookup = config.SessionLookUp; | ||
74 | m_inventoryService.AddPlugin(config.DatabaseProvider, config.DatabaseConnect); | ||
75 | |||
76 | |||
77 | m_log.Info("[" + LogName + "]: Starting HTTP server ..."); | ||
78 | |||
79 | m_httpServer = new BaseHttpServer(config.HttpPort); | ||
80 | |||
81 | AddHttpHandlers(config.RegionAccessToAgentsInventory); | ||
82 | |||
83 | m_httpServer.Start(); | ||
84 | |||
85 | m_log.Info("[" + LogName + "]: Started HTTP server"); | ||
86 | |||
87 | base.StartupSpecific(); | ||
88 | |||
89 | m_console.Commands.AddCommand("inventoryserver", false, "add user", | ||
90 | "add user", | ||
91 | "Add a random user inventory", HandleAddUser); | ||
92 | } | ||
93 | |||
94 | protected void AddHttpHandlers(bool regionAccess) | ||
95 | { | ||
96 | if (regionAccess) | ||
97 | { | ||
98 | m_httpServer.AddStreamHandler( | ||
99 | new RestDeserialiseSecureHandler<Guid, InventoryCollection>( | ||
100 | "POST", "/GetInventory/", m_inventoryService.GetUserInventory, m_inventoryService.CheckAuthSession)); | ||
101 | |||
102 | m_httpServer.AddStreamHandler( | ||
103 | new RestDeserialiseSecureHandler<InventoryFolderBase, bool>( | ||
104 | "POST", "/UpdateFolder/", m_inventoryService.UpdateFolder, m_inventoryService.CheckAuthSession)); | ||
105 | |||
106 | m_httpServer.AddStreamHandler( | ||
107 | new RestDeserialiseSecureHandler<InventoryFolderBase, bool>( | ||
108 | "POST", "/MoveFolder/", m_inventoryService.MoveFolder, m_inventoryService.CheckAuthSession)); | ||
109 | |||
110 | m_httpServer.AddStreamHandler( | ||
111 | new RestDeserialiseSecureHandler<InventoryFolderBase, bool>( | ||
112 | "POST", "/PurgeFolder/", m_inventoryService.PurgeFolder, m_inventoryService.CheckAuthSession)); | ||
113 | |||
114 | m_httpServer.AddStreamHandler( | ||
115 | new RestDeserialiseSecureHandler<InventoryItemBase, bool>( | ||
116 | "POST", "/DeleteItem/", m_inventoryService.DeleteItem, m_inventoryService.CheckAuthSession)); | ||
117 | |||
118 | m_httpServer.AddStreamHandler( | ||
119 | new RestDeserialiseSecureHandler<InventoryItemBase, InventoryItemBase>( | ||
120 | "POST", "/QueryItem/", m_inventoryService.QueryItem, m_inventoryService.CheckAuthSession)); | ||
121 | |||
122 | m_httpServer.AddStreamHandler( | ||
123 | new RestDeserialiseSecureHandler<InventoryFolderBase, InventoryFolderBase>( | ||
124 | "POST", "/QueryFolder/", m_inventoryService.QueryFolder, m_inventoryService.CheckAuthSession)); | ||
125 | |||
126 | } | ||
127 | |||
128 | m_httpServer.AddStreamHandler( | ||
129 | new RestDeserialiseTrustedHandler<Guid, bool>( | ||
130 | "POST", "/CreateInventory/", m_inventoryService.CreateUsersInventory, m_inventoryService.CheckTrustSource)); | ||
131 | |||
132 | m_httpServer.AddStreamHandler( | ||
133 | new RestDeserialiseSecureHandler<InventoryFolderBase, bool>( | ||
134 | "POST", "/NewFolder/", m_inventoryService.AddFolder, m_inventoryService.CheckAuthSession)); | ||
135 | |||
136 | m_httpServer.AddStreamHandler( | ||
137 | new RestDeserialiseTrustedHandler<InventoryFolderBase, bool>( | ||
138 | "POST", "/CreateFolder/", m_inventoryService.AddFolder, m_inventoryService.CheckTrustSource)); | ||
139 | |||
140 | m_httpServer.AddStreamHandler( | ||
141 | new RestDeserialiseSecureHandler<InventoryItemBase, bool>( | ||
142 | "POST", "/NewItem/", m_inventoryService.AddItem, m_inventoryService.CheckAuthSession)); | ||
143 | |||
144 | m_httpServer.AddStreamHandler( | ||
145 | new RestDeserialiseTrustedHandler<InventoryItemBase, bool>( | ||
146 | "POST", "/AddNewItem/", m_inventoryService.AddItem, m_inventoryService.CheckTrustSource)); | ||
147 | |||
148 | m_httpServer.AddStreamHandler( | ||
149 | new RestDeserialiseTrustedHandler<Guid, List<InventoryItemBase>>( | ||
150 | "POST", "/GetItems/", m_inventoryService.GetFolderItems, m_inventoryService.CheckTrustSource)); | ||
151 | |||
152 | // for persistent active gestures | ||
153 | m_httpServer.AddStreamHandler( | ||
154 | new RestDeserialiseTrustedHandler<Guid, List<InventoryItemBase>> | ||
155 | ("POST", "/ActiveGestures/", m_inventoryService.GetActiveGestures, m_inventoryService.CheckTrustSource)); | ||
156 | |||
157 | // WARNING: Root folders no longer just delivers the root and immediate child folders (e.g | ||
158 | // system folders such as Objects, Textures), but it now returns the entire inventory skeleton. | ||
159 | // It would have been better to rename this request, but complexities in the BaseHttpServer | ||
160 | // (e.g. any http request not found is automatically treated as an xmlrpc request) make it easier | ||
161 | // to do this for now. | ||
162 | m_httpServer.AddStreamHandler( | ||
163 | new RestDeserialiseTrustedHandler<Guid, List<InventoryFolderBase>> | ||
164 | ("POST", "/RootFolders/", m_inventoryService.GetInventorySkeleton, m_inventoryService.CheckTrustSource)); | ||
165 | } | ||
166 | |||
167 | private void Work() | ||
168 | { | ||
169 | m_console.Output("Enter help for a list of commands\n"); | ||
170 | |||
171 | while (true) | ||
172 | { | ||
173 | m_console.Prompt(); | ||
174 | } | ||
175 | } | ||
176 | |||
177 | private void HandleAddUser(string module, string[] args) | ||
178 | { | ||
179 | m_inventoryService.CreateUsersInventory(UUID.Random().Guid); | ||
180 | } | ||
181 | } | ||
182 | } | ||
diff --git a/prebuild.xml b/prebuild.xml index 79c767c..9498d7d 100644 --- a/prebuild.xml +++ b/prebuild.xml | |||
@@ -956,38 +956,6 @@ | |||
956 | </Project> | 956 | </Project> |
957 | 957 | ||
958 | 958 | ||
959 | <Project frameworkVersion="v3_5" name="OpenSim.Grid.AssetServer" path="OpenSim/Grid/AssetServer" type="Exe"> | ||
960 | <Configuration name="Debug"> | ||
961 | <Options> | ||
962 | <OutputPath>../../../bin/</OutputPath> | ||
963 | </Options> | ||
964 | </Configuration> | ||
965 | <Configuration name="Release"> | ||
966 | <Options> | ||
967 | <OutputPath>../../../bin/</OutputPath> | ||
968 | </Options> | ||
969 | </Configuration> | ||
970 | |||
971 | <ReferencePath>../../../bin/</ReferencePath> | ||
972 | <Reference name="System"/> | ||
973 | <Reference name="System.Data"/> | ||
974 | <Reference name="System.Xml"/> | ||
975 | <Reference name="OpenSim.Framework"/> | ||
976 | <Reference name="OpenSim.Framework.AssetLoader.Filesystem"/> | ||
977 | <Reference name="OpenSim.Framework.Console"/> | ||
978 | <Reference name="OpenSim.Framework.Servers"/> | ||
979 | <Reference name="OpenSim.Framework.Servers.HttpServer"/> | ||
980 | <Reference name="OpenSim.Framework.Communications"/> | ||
981 | <Reference name="OpenSim.Framework.Statistics"/> | ||
982 | <Reference name="OpenSim.Data"/> | ||
983 | <Reference name="OpenMetaverseTypes.dll"/> | ||
984 | <Reference name="log4net.dll"/> | ||
985 | |||
986 | <Files> | ||
987 | <Match pattern="*.cs" recurse="true"/> | ||
988 | </Files> | ||
989 | </Project> | ||
990 | |||
991 | <Project frameworkVersion="v3_5" name="OpenSim.Grid.UserServer.Modules" path="OpenSim/Grid/UserServer.Modules" type="Library"> | 959 | <Project frameworkVersion="v3_5" name="OpenSim.Grid.UserServer.Modules" path="OpenSim/Grid/UserServer.Modules" type="Library"> |
992 | <Configuration name="Debug"> | 960 | <Configuration name="Debug"> |
993 | <Options> | 961 | <Options> |
@@ -1068,38 +1036,6 @@ | |||
1068 | </Files> | 1036 | </Files> |
1069 | </Project> | 1037 | </Project> |
1070 | 1038 | ||
1071 | <Project frameworkVersion="v3_5" name="OpenSim.Grid.InventoryServer" path="OpenSim/Grid/InventoryServer" type="Exe"> | ||
1072 | <Configuration name="Debug"> | ||
1073 | <Options> | ||
1074 | <OutputPath>../../../bin/</OutputPath> | ||
1075 | </Options> | ||
1076 | </Configuration> | ||
1077 | <Configuration name="Release"> | ||
1078 | <Options> | ||
1079 | <OutputPath>../../../bin/</OutputPath> | ||
1080 | </Options> | ||
1081 | </Configuration> | ||
1082 | |||
1083 | <ReferencePath>../../../bin/</ReferencePath> | ||
1084 | <Reference name="System"/> | ||
1085 | <Reference name="System.Data"/> | ||
1086 | <Reference name="System.Xml"/> | ||
1087 | <Reference name="OpenSim.Framework"/> | ||
1088 | <Reference name="OpenSim.Framework.Console"/> | ||
1089 | <Reference name="OpenSim.Framework.Communications"/> | ||
1090 | <Reference name="OpenSim.Data"/> | ||
1091 | <Reference name="OpenSim.Framework.Servers"/> | ||
1092 | <Reference name="OpenSim.Framework.Servers.HttpServer"/> | ||
1093 | <Reference name="OpenSim.Services.Interfaces"/> | ||
1094 | <Reference name="OpenMetaverseTypes.dll"/> | ||
1095 | <Reference name="log4net.dll"/> | ||
1096 | <Reference name="XMLRPC.dll"/> | ||
1097 | |||
1098 | <Files> | ||
1099 | <Match pattern="*.cs" recurse="true"/> | ||
1100 | </Files> | ||
1101 | </Project> | ||
1102 | |||
1103 | <Project frameworkVersion="v3_5" name="OpenSim.Grid.MessagingServer.Modules" path="OpenSim/Grid/MessagingServer.Modules" type="Library"> | 1039 | <Project frameworkVersion="v3_5" name="OpenSim.Grid.MessagingServer.Modules" path="OpenSim/Grid/MessagingServer.Modules" type="Library"> |
1104 | <Configuration name="Debug"> | 1040 | <Configuration name="Debug"> |
1105 | <Options> | 1041 | <Options> |