diff options
24 files changed, 0 insertions, 5829 deletions
diff --git a/OpenSim/Grid/AssetInventoryServer/AssetInventoryConfig.cs b/OpenSim/Grid/AssetInventoryServer/AssetInventoryConfig.cs deleted file mode 100644 index 79b6c73..0000000 --- a/OpenSim/Grid/AssetInventoryServer/AssetInventoryConfig.cs +++ /dev/null | |||
@@ -1,98 +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 OpenSim.Framework; | ||
32 | using log4net; | ||
33 | using Nini.Config; | ||
34 | |||
35 | namespace OpenSim.Grid.AssetInventoryServer | ||
36 | { | ||
37 | public static class AssetInventoryConfig | ||
38 | { | ||
39 | public const string CONFIG_FILE = "AssetInventoryServer.ini"; | ||
40 | private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); | ||
41 | |||
42 | public static IConfigSource LoadConfig() | ||
43 | { | ||
44 | IConfigSource configSource = new IniConfigSource(); | ||
45 | configSource.AddConfig("Startup"); | ||
46 | return LoadConfig(configSource); | ||
47 | } | ||
48 | |||
49 | public static IConfigSource LoadConfig(IConfigSource source) | ||
50 | { | ||
51 | string iniFileName = source.Configs["Startup"].GetString("inifile", CONFIG_FILE); | ||
52 | string iniFilePath = Path.Combine(Util.configDir(), iniFileName); | ||
53 | |||
54 | source.Merge(DefaultConfig()); | ||
55 | |||
56 | if (!File.Exists(iniFilePath)) | ||
57 | { | ||
58 | m_log.FatalFormat("[CONFIG]: File {0} not found, could not load any configuration.", iniFilePath); | ||
59 | m_log.FatalFormat("[CONFIG]: Did you copy the AssetInventoryServer.ini.example file to AssetInventoryServer.ini?"); | ||
60 | Environment.Exit(1); | ||
61 | } | ||
62 | |||
63 | source.Merge(new IniConfigSource(iniFilePath)); | ||
64 | return source; | ||
65 | } | ||
66 | |||
67 | private static IConfigSource DefaultConfig() | ||
68 | { | ||
69 | IConfigSource result = new IniConfigSource(); | ||
70 | |||
71 | { | ||
72 | IConfig config = result.AddConfig("Config"); | ||
73 | config.Set("listen_port", 8003); | ||
74 | config.Set("assetset_location", String.Format(".{0}assets{0}AssetSets.xml", Path.DirectorySeparatorChar)); | ||
75 | } | ||
76 | |||
77 | { | ||
78 | IConfig config = result.AddConfig("Plugins"); | ||
79 | config.Set("asset_storage_provider", "OpenSimAssetStorage"); | ||
80 | config.Set("inventory_storage_provider", "OpenSimInventoryStorage"); | ||
81 | config.Set("authentication_provider", "NullAuthentication"); | ||
82 | config.Set("authorization_provider", "AuthorizeAll"); | ||
83 | config.Set("metrics_provider", "NullMetrics"); | ||
84 | config.Set("frontends", "ReferenceFrontend,OpenSimAssetFrontend,OpenSimInventoryFrontend,BrowseFrontend"); | ||
85 | } | ||
86 | |||
87 | { | ||
88 | IConfig config = result.AddConfig("OpenSim"); | ||
89 | config.Set("asset_database_provider", "OpenSim.Data.MySQL.dll"); | ||
90 | config.Set("inventory_database_provider", "OpenSim.Data.MySQL.dll"); | ||
91 | config.Set("asset_database_connect", String.Empty); | ||
92 | config.Set("inventory_database_connect", String.Empty); | ||
93 | } | ||
94 | |||
95 | return result; | ||
96 | } | ||
97 | } | ||
98 | } | ||
diff --git a/OpenSim/Grid/AssetInventoryServer/AssetInventoryServer.cs b/OpenSim/Grid/AssetInventoryServer/AssetInventoryServer.cs deleted file mode 100644 index 16b9d9e..0000000 --- a/OpenSim/Grid/AssetInventoryServer/AssetInventoryServer.cs +++ /dev/null | |||
@@ -1,216 +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.Reflection; | ||
31 | using OpenSim.Framework; | ||
32 | using OpenSim.Framework.Servers; | ||
33 | using OpenSim.Framework.Servers.HttpServer; | ||
34 | using OpenSim.Framework.Console; | ||
35 | using OpenSim.Framework.AssetLoader.Filesystem; | ||
36 | using Nini.Config; | ||
37 | using log4net; | ||
38 | |||
39 | namespace OpenSim.Grid.AssetInventoryServer | ||
40 | { | ||
41 | public class AssetInventoryServer : BaseOpenSimServer | ||
42 | { | ||
43 | private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); | ||
44 | public IConfigSource ConfigFile; | ||
45 | |||
46 | public IAssetStorageProvider StorageProvider; | ||
47 | public IInventoryStorageProvider InventoryProvider; | ||
48 | public IAuthenticationProvider AuthenticationProvider; | ||
49 | public IAuthorizationProvider AuthorizationProvider; | ||
50 | public IMetricsProvider MetricsProvider; | ||
51 | |||
52 | private List<IAssetInventoryServerPlugin> m_frontends = new List<IAssetInventoryServerPlugin>(); | ||
53 | private List<IAssetInventoryServerPlugin> m_backends = new List<IAssetInventoryServerPlugin>(); | ||
54 | |||
55 | public AssetInventoryServer(IConfigSource config) | ||
56 | { | ||
57 | ConfigFile = config; | ||
58 | |||
59 | m_console = new LocalConsole("AssetInventory"); | ||
60 | MainConsole.Instance = m_console; | ||
61 | } | ||
62 | |||
63 | public bool Start() | ||
64 | { | ||
65 | Startup(); | ||
66 | m_log.Info("[ASSETINVENTORY]: Starting AssetInventory Server"); | ||
67 | |||
68 | try | ||
69 | { | ||
70 | ConfigFile = AssetInventoryConfig.LoadConfig(ConfigFile); | ||
71 | } | ||
72 | catch (Exception) | ||
73 | { | ||
74 | m_log.Error("[ASSETINVENTORY]: Failed to load the config."); | ||
75 | return false; | ||
76 | } | ||
77 | |||
78 | StorageProvider = LoadAssetInventoryServerPlugin("/OpenSim/AssetInventoryServer/AssetStorageProvider", | ||
79 | "asset_storage_provider", false) as IAssetStorageProvider; | ||
80 | m_backends.Add(StorageProvider); | ||
81 | |||
82 | InventoryProvider = LoadAssetInventoryServerPlugin("/OpenSim/AssetInventoryServer/InventoryStorageProvider", | ||
83 | "inventory_storage_provider", false) as IInventoryStorageProvider; | ||
84 | m_backends.Add(InventoryProvider); | ||
85 | |||
86 | MetricsProvider = LoadAssetInventoryServerPlugin("/OpenSim/AssetInventoryServer/MetricsProvider", | ||
87 | "metrics_provider", false) as IMetricsProvider; | ||
88 | m_backends.Add(MetricsProvider); | ||
89 | |||
90 | try | ||
91 | { | ||
92 | InitHttpServer((uint) ConfigFile.Configs["Config"].GetInt("listen_port")); | ||
93 | } | ||
94 | catch (Exception ex) | ||
95 | { | ||
96 | m_log.Error("[ASSETINVENTORY]: Initializing the HTTP server failed, shutting down: " + ex.Message); | ||
97 | Shutdown(); | ||
98 | return false; | ||
99 | } | ||
100 | |||
101 | LoadDefaultAssets(); | ||
102 | |||
103 | AuthenticationProvider = LoadAssetInventoryServerPlugin("/OpenSim/AssetInventoryServer/AuthenticationProvider", | ||
104 | "authentication_provider", false) as IAuthenticationProvider; | ||
105 | m_backends.Add(AuthenticationProvider); | ||
106 | |||
107 | AuthorizationProvider = LoadAssetInventoryServerPlugin("/OpenSim/AssetInventoryServer/AuthorizationProvider", | ||
108 | "authorization_provider", false) as IAuthorizationProvider; | ||
109 | m_backends.Add(AuthorizationProvider); | ||
110 | |||
111 | m_frontends.AddRange(LoadAssetInventoryServerPlugins("/OpenSim/AssetInventoryServer/Frontend", "frontends")); | ||
112 | |||
113 | // Inform the user if we don't have any frontends at this point. | ||
114 | if (m_frontends.Count == 0) | ||
115 | m_log.Info("[ASSETINVENTORY]: Starting with no frontends loaded, which isn't extremely useful. Did you set the 'frontends' configuration parameter?"); | ||
116 | |||
117 | return true; | ||
118 | } | ||
119 | |||
120 | public void Work() | ||
121 | { | ||
122 | m_console.Output("Enter help for a list of commands"); | ||
123 | |||
124 | while (true) | ||
125 | { | ||
126 | m_console.Prompt(); | ||
127 | } | ||
128 | } | ||
129 | |||
130 | public override void ShutdownSpecific() | ||
131 | { | ||
132 | foreach (IAssetInventoryServerPlugin plugin in m_frontends) | ||
133 | { | ||
134 | m_log.Debug("[ASSETINVENTORY]: Disposing plugin " + plugin.Name); | ||
135 | try { plugin.Dispose(); } | ||
136 | catch (Exception ex) | ||
137 | { m_log.ErrorFormat("[ASSETINVENTORY]: Failure shutting down plugin {0}: {1}", plugin.Name, ex.Message); } | ||
138 | } | ||
139 | |||
140 | foreach (IAssetInventoryServerPlugin plugin in m_backends) | ||
141 | { | ||
142 | m_log.Debug("[ASSETINVENTORY]: Disposing plugin " + plugin.Name); | ||
143 | try { plugin.Dispose(); } | ||
144 | catch (Exception ex) | ||
145 | { m_log.ErrorFormat("[ASSETINVENTORY]: Failure shutting down plugin {0}: {1}", plugin.Name, ex.Message); } | ||
146 | } | ||
147 | |||
148 | if (HttpServer != null) | ||
149 | HttpServer.Stop(); | ||
150 | } | ||
151 | |||
152 | void InitHttpServer(uint port) | ||
153 | { | ||
154 | m_httpServer = new BaseHttpServer(port); | ||
155 | m_httpServer.Start(); | ||
156 | |||
157 | m_log.Info("[ASSETINVENTORY]: AssetInventory server is listening on port " + port); | ||
158 | } | ||
159 | |||
160 | private IAssetInventoryServerPlugin LoadAssetInventoryServerPlugin(string addinPath, string configParam, bool optional) | ||
161 | { | ||
162 | IAssetInventoryServerPlugin result = null; | ||
163 | List<IAssetInventoryServerPlugin> plugins = LoadAssetInventoryServerPlugins(addinPath, configParam); | ||
164 | |||
165 | if (plugins.Count == 1) | ||
166 | { | ||
167 | result = plugins[0]; | ||
168 | } | ||
169 | else if (plugins.Count > 1) | ||
170 | { | ||
171 | m_log.ErrorFormat("[ASSETINVENTORY]: Only 1 plugin expected for extension point '{0}', {1} plugins loaded. Check the '{2}' parameter in the config file.", | ||
172 | addinPath, plugins.Count, configParam); | ||
173 | Shutdown(); | ||
174 | Environment.Exit(0); | ||
175 | } | ||
176 | else if (!optional) | ||
177 | { | ||
178 | m_log.ErrorFormat("[ASSETINVENTORY]: The extension point '{0}' is not optional. Check the '{1}' parameter in the config file.", addinPath, configParam); | ||
179 | Shutdown(); | ||
180 | Environment.Exit(0); | ||
181 | } | ||
182 | |||
183 | return result; | ||
184 | } | ||
185 | |||
186 | private List<IAssetInventoryServerPlugin> LoadAssetInventoryServerPlugins(string addinPath, string configParam) | ||
187 | { | ||
188 | PluginLoader<IAssetInventoryServerPlugin> loader = new PluginLoader<IAssetInventoryServerPlugin>(new AssetInventoryServerPluginInitialiser(this)); | ||
189 | loader.Add(addinPath, new PluginIdFilter(ConfigFile.Configs["Plugins"].GetString(configParam))); | ||
190 | |||
191 | try | ||
192 | { | ||
193 | loader.Load(); | ||
194 | } | ||
195 | catch (PluginNotInitialisedException e) | ||
196 | { | ||
197 | m_log.ErrorFormat("[ASSETINVENTORY]: Error initialising plugin '{0}' for extension point '{1}'.", e.Message, addinPath); | ||
198 | Shutdown(); | ||
199 | Environment.Exit(0); | ||
200 | } | ||
201 | |||
202 | return loader.Plugins; | ||
203 | } | ||
204 | |||
205 | private void LoadDefaultAssets() | ||
206 | { | ||
207 | AssetLoaderFileSystem assetLoader = new AssetLoaderFileSystem(); | ||
208 | assetLoader.ForEachDefaultXmlAsset(ConfigFile.Configs["Config"].GetString("assetset_location"), StoreAsset); | ||
209 | } | ||
210 | |||
211 | private void StoreAsset(AssetBase asset) | ||
212 | { | ||
213 | StorageProvider.TryCreateAsset(asset); | ||
214 | } | ||
215 | } | ||
216 | } | ||
diff --git a/OpenSim/Grid/AssetInventoryServer/Interfaces.cs b/OpenSim/Grid/AssetInventoryServer/Interfaces.cs deleted file mode 100644 index e808dd3..0000000 --- a/OpenSim/Grid/AssetInventoryServer/Interfaces.cs +++ /dev/null | |||
@@ -1,143 +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 OpenMetaverse; | ||
31 | using OpenSim.Framework; | ||
32 | |||
33 | namespace OpenSim.Grid.AssetInventoryServer | ||
34 | { | ||
35 | /// <summary> | ||
36 | /// Response from a call to a backend provider | ||
37 | /// </summary> | ||
38 | public enum BackendResponse | ||
39 | { | ||
40 | /// <summary>The call succeeded</summary> | ||
41 | Success, | ||
42 | /// <summary>The resource requested was not found</summary> | ||
43 | NotFound, | ||
44 | /// <summary>A server failure prevented the call from | ||
45 | /// completing</summary> | ||
46 | Failure | ||
47 | } | ||
48 | |||
49 | public class AssetInventoryServerPluginInitialiser : PluginInitialiserBase | ||
50 | { | ||
51 | private AssetInventoryServer server; | ||
52 | |||
53 | public AssetInventoryServerPluginInitialiser(AssetInventoryServer server) | ||
54 | { | ||
55 | this.server = server; | ||
56 | } | ||
57 | |||
58 | public override void Initialise(IPlugin plugin) | ||
59 | { | ||
60 | IAssetInventoryServerPlugin p = plugin as IAssetInventoryServerPlugin; | ||
61 | p.Initialise (server); | ||
62 | } | ||
63 | } | ||
64 | |||
65 | #region Interfaces | ||
66 | |||
67 | public interface IAssetInventoryServerPlugin : IPlugin | ||
68 | { | ||
69 | void Initialise(AssetInventoryServer server); | ||
70 | } | ||
71 | |||
72 | public interface IAssetStorageProvider : IAssetInventoryServerPlugin | ||
73 | { | ||
74 | BackendResponse TryFetchMetadata(UUID assetID, out AssetMetadata metadata); | ||
75 | BackendResponse TryFetchData(UUID assetID, out byte[] assetData); | ||
76 | BackendResponse TryFetchDataMetadata(UUID assetID, out AssetBase asset); | ||
77 | BackendResponse TryCreateAsset(AssetBase asset); | ||
78 | BackendResponse TryCreateAsset(AssetBase asset, out UUID assetID); | ||
79 | int ForEach(Action<AssetMetadata> action, int start, int count); | ||
80 | } | ||
81 | |||
82 | public interface IInventoryStorageProvider : IAssetInventoryServerPlugin | ||
83 | { | ||
84 | BackendResponse TryFetchItem(Uri owner, UUID itemID, out InventoryItemBase item); | ||
85 | BackendResponse TryFetchFolder(Uri owner, UUID folderID, out InventoryFolderWithChildren folder); | ||
86 | BackendResponse TryFetchFolderContents(Uri owner, UUID folderID, out InventoryCollection contents); | ||
87 | BackendResponse TryFetchFolderList(Uri owner, out List<InventoryFolderWithChildren> folders); | ||
88 | BackendResponse TryFetchInventory(Uri owner, out InventoryCollection inventory); | ||
89 | |||
90 | BackendResponse TryFetchActiveGestures(Uri owner, out List<InventoryItemBase> gestures); | ||
91 | |||
92 | BackendResponse TryCreateItem(Uri owner, InventoryItemBase item); | ||
93 | BackendResponse TryCreateFolder(Uri owner, InventoryFolderWithChildren folder); | ||
94 | BackendResponse TryCreateInventory(Uri owner, InventoryFolderWithChildren rootFolder); | ||
95 | |||
96 | BackendResponse TryDeleteItem(Uri owner, UUID itemID); | ||
97 | BackendResponse TryDeleteFolder(Uri owner, UUID folderID); | ||
98 | BackendResponse TryPurgeFolder(Uri owner, UUID folderID); | ||
99 | } | ||
100 | |||
101 | public interface IAuthenticationProvider : IAssetInventoryServerPlugin | ||
102 | { | ||
103 | void AddIdentifier(UUID authToken, Uri identifier); | ||
104 | bool RemoveIdentifier(UUID authToken); | ||
105 | bool TryGetIdentifier(UUID authToken, out Uri identifier); | ||
106 | } | ||
107 | |||
108 | public interface IAuthorizationProvider : IAssetInventoryServerPlugin | ||
109 | { | ||
110 | bool IsMetadataAuthorized(UUID authToken, UUID assetID); | ||
111 | /// <summary> | ||
112 | /// Authorizes access to the data for an asset. Access to asset data | ||
113 | /// also implies access to the metadata for that asset | ||
114 | /// </summary> | ||
115 | /// <param name="authToken">Authentication token to check for access</param> | ||
116 | /// <param name="assetID">ID of the requested asset</param> | ||
117 | /// <returns>True if access is granted, otherwise false</returns> | ||
118 | bool IsDataAuthorized(UUID authToken, UUID assetID); | ||
119 | bool IsCreateAuthorized(UUID authToken); | ||
120 | |||
121 | bool IsInventoryReadAuthorized(UUID authToken, Uri owner); | ||
122 | bool IsInventoryWriteAuthorized(UUID authToken, Uri owner); | ||
123 | } | ||
124 | |||
125 | public interface IMetricsProvider : IAssetInventoryServerPlugin | ||
126 | { | ||
127 | void LogAssetMetadataFetch(string extension, BackendResponse response, UUID assetID, DateTime time); | ||
128 | void LogAssetDataFetch(string extension, BackendResponse response, UUID assetID, int dataSize, DateTime time); | ||
129 | void LogAssetCreate(string extension, BackendResponse response, UUID assetID, int dataSize, DateTime time); | ||
130 | |||
131 | void LogInventoryFetch(string extension, BackendResponse response, Uri owner, UUID objID, bool folder, DateTime time); | ||
132 | void LogInventoryFetchFolderContents(string extension, BackendResponse response, Uri owner, UUID folderID, DateTime time); | ||
133 | void LogInventoryFetchFolderList(string extension, BackendResponse response, Uri owner, DateTime time); | ||
134 | void LogInventoryFetchInventory(string extension, BackendResponse response, Uri owner, DateTime time); | ||
135 | void LogInventoryFetchActiveGestures(string extension, BackendResponse response, Uri owner, DateTime time); | ||
136 | void LogInventoryCreate(string extension, BackendResponse response, Uri owner, bool folder, DateTime time); | ||
137 | void LogInventoryCreateInventory(string extension, BackendResponse response, DateTime time); | ||
138 | void LogInventoryDelete(string extension, BackendResponse response, Uri owner, UUID objID, bool folder, DateTime time); | ||
139 | void LogInventoryPurgeFolder(string extension, BackendResponse response, Uri owner, UUID folderID, DateTime time); | ||
140 | } | ||
141 | |||
142 | #endregion Interfaces | ||
143 | } | ||
diff --git a/OpenSim/Grid/AssetInventoryServer/InventoryObjects.cs b/OpenSim/Grid/AssetInventoryServer/InventoryObjects.cs deleted file mode 100644 index 4f42a20..0000000 --- a/OpenSim/Grid/AssetInventoryServer/InventoryObjects.cs +++ /dev/null | |||
@@ -1,139 +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 OpenMetaverse; | ||
31 | using OpenSim.Framework; | ||
32 | |||
33 | namespace OpenSim.Grid.AssetInventoryServer | ||
34 | { | ||
35 | //public class InventoryBase | ||
36 | //{ | ||
37 | //} | ||
38 | |||
39 | //public class InventoryFolder : InventoryBase | ||
40 | //{ | ||
41 | // public string Name; | ||
42 | // public UUID Owner; | ||
43 | // public UUID ParentID; | ||
44 | // public UUID ID; | ||
45 | // public short Type; | ||
46 | // public ushort Version; | ||
47 | |||
48 | // [NonSerialized] | ||
49 | // public Dictionary<UUID, InventoryBase> Children = new Dictionary<UUID, InventoryBase>(); | ||
50 | |||
51 | // public InventoryFolder() | ||
52 | // { | ||
53 | // } | ||
54 | |||
55 | // public InventoryFolder(string name, UUID ownerID, UUID parentID, short assetType) | ||
56 | // { | ||
57 | // ID = UUID.Random(); | ||
58 | // Name = name; | ||
59 | // Owner = ownerID; | ||
60 | // ParentID = parentID; | ||
61 | // Type = assetType; | ||
62 | // Version = 1; | ||
63 | // } | ||
64 | |||
65 | // public override string ToString() | ||
66 | // { | ||
67 | // return String.Format("{0} ({1})", Name, ID); | ||
68 | // } | ||
69 | //} | ||
70 | |||
71 | //public class InventoryItem : InventoryBase | ||
72 | //{ | ||
73 | // public UUID ID; | ||
74 | // public int InvType; | ||
75 | // public UUID Folder; | ||
76 | // public UUID Owner; | ||
77 | // public UUID Creator; | ||
78 | // public string Name; | ||
79 | // public string Description; | ||
80 | // public uint NextPermissions; | ||
81 | // public uint CurrentPermissions; | ||
82 | // public uint BasePermissions; | ||
83 | // public uint EveryOnePermissions; | ||
84 | // public uint GroupPermissions; | ||
85 | // public int AssetType; | ||
86 | // public UUID AssetID; | ||
87 | // public UUID GroupID; | ||
88 | // public bool GroupOwned; | ||
89 | // public int SalePrice; | ||
90 | // public byte SaleType; | ||
91 | // public uint Flags; | ||
92 | // public int CreationDate; | ||
93 | |||
94 | // public override string ToString() | ||
95 | // { | ||
96 | // return String.Format("{0} ({1})", Name, ID); | ||
97 | // } | ||
98 | //} | ||
99 | |||
100 | public class InventoryFolderWithChildren : InventoryFolderBase | ||
101 | { | ||
102 | public InventoryFolderWithChildren() | ||
103 | { | ||
104 | } | ||
105 | |||
106 | public InventoryFolderWithChildren(InventoryFolderBase folder) | ||
107 | { | ||
108 | // from InventoryNodeBase | ||
109 | Name = folder.Name; | ||
110 | ID = folder.ID; | ||
111 | Owner = folder.Owner; | ||
112 | |||
113 | // from InventoryFolderBase | ||
114 | ParentID = folder.ParentID; | ||
115 | Type = folder.Type; | ||
116 | Version = folder.Version; | ||
117 | } | ||
118 | |||
119 | public InventoryFolderWithChildren(string name, UUID ownerID, UUID parentID, short assetType) | ||
120 | { | ||
121 | ID = UUID.Random(); | ||
122 | Name = name; | ||
123 | Owner = ownerID; | ||
124 | ParentID = parentID; | ||
125 | Type = assetType; | ||
126 | Version = 1; | ||
127 | } | ||
128 | |||
129 | [NonSerialized] | ||
130 | public Dictionary<UUID, InventoryNodeBase> Children = new Dictionary<UUID, InventoryNodeBase>(); | ||
131 | } | ||
132 | |||
133 | public class InventoryCollection | ||
134 | { | ||
135 | public Dictionary<UUID, InventoryFolderWithChildren> Folders; | ||
136 | public Dictionary<UUID, InventoryItemBase> Items; | ||
137 | public UUID UserID; | ||
138 | } | ||
139 | } | ||
diff --git a/OpenSim/Grid/AssetInventoryServer/Main.cs b/OpenSim/Grid/AssetInventoryServer/Main.cs deleted file mode 100644 index 598b754..0000000 --- a/OpenSim/Grid/AssetInventoryServer/Main.cs +++ /dev/null | |||
@@ -1,62 +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 Nini.Config; | ||
30 | using log4net.Config; | ||
31 | using log4net; | ||
32 | using System.Reflection; | ||
33 | |||
34 | namespace OpenSim.Grid.AssetInventoryServer | ||
35 | { | ||
36 | class MainEntry | ||
37 | { | ||
38 | private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); | ||
39 | |||
40 | static void Main(string[] args) | ||
41 | { | ||
42 | XmlConfigurator.Configure(); | ||
43 | |||
44 | ArgvConfigSource configSource = new ArgvConfigSource(args); | ||
45 | configSource.AddSwitch("Startup", "inifile"); | ||
46 | |||
47 | AssetInventoryServer server = new AssetInventoryServer(configSource); | ||
48 | if (server.Start()) | ||
49 | { | ||
50 | Console.CancelKeyPress += | ||
51 | delegate(object sender, ConsoleCancelEventArgs e) | ||
52 | { | ||
53 | m_log.Info("AssetInventory server is shutting down..."); | ||
54 | server.Shutdown(); | ||
55 | Environment.Exit(0); | ||
56 | }; | ||
57 | |||
58 | server.Work(); | ||
59 | } | ||
60 | } | ||
61 | } | ||
62 | } | ||
diff --git a/OpenSim/Grid/AssetInventoryServer/Plugins/AuthorizeAllPlugin.cs b/OpenSim/Grid/AssetInventoryServer/Plugins/AuthorizeAllPlugin.cs deleted file mode 100644 index 3d0a283..0000000 --- a/OpenSim/Grid/AssetInventoryServer/Plugins/AuthorizeAllPlugin.cs +++ /dev/null | |||
@@ -1,105 +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.Reflection; | ||
30 | using OpenMetaverse; | ||
31 | using OpenSim.Framework; | ||
32 | using log4net; | ||
33 | |||
34 | namespace OpenSim.Grid.AssetInventoryServer.Plugins | ||
35 | { | ||
36 | public class AuthorizeAllPlugin : IAuthorizationProvider | ||
37 | { | ||
38 | private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); | ||
39 | //private AssetInventoryServer m_server; | ||
40 | |||
41 | public AuthorizeAllPlugin() | ||
42 | { | ||
43 | } | ||
44 | |||
45 | #region IPlugin implementation | ||
46 | |||
47 | public void Initialise(AssetInventoryServer server) | ||
48 | { | ||
49 | //m_server = server; | ||
50 | |||
51 | m_log.Info("[AUTHORIZEALL]: Authorize All loaded."); | ||
52 | } | ||
53 | |||
54 | /// <summary> | ||
55 | /// <para>Initialises asset interface</para> | ||
56 | /// </summary> | ||
57 | public void Initialise() | ||
58 | { | ||
59 | m_log.InfoFormat("[AUTHORIZEALL]: {0} cannot be default-initialized!", Name); | ||
60 | throw new PluginNotInitialisedException(Name); | ||
61 | } | ||
62 | |||
63 | public void Dispose() | ||
64 | { | ||
65 | } | ||
66 | |||
67 | public string Version | ||
68 | { | ||
69 | // TODO: this should be something meaningful and not hardcoded? | ||
70 | get { return "0.1"; } | ||
71 | } | ||
72 | |||
73 | public string Name | ||
74 | { | ||
75 | get { return "AuthorizeAll"; } | ||
76 | } | ||
77 | |||
78 | #endregion IPlugin implementation | ||
79 | |||
80 | public bool IsMetadataAuthorized(UUID authToken, UUID assetID) | ||
81 | { | ||
82 | return true; | ||
83 | } | ||
84 | |||
85 | public bool IsDataAuthorized(UUID authToken, UUID assetID) | ||
86 | { | ||
87 | return true; | ||
88 | } | ||
89 | |||
90 | public bool IsCreateAuthorized(UUID authToken) | ||
91 | { | ||
92 | return true; | ||
93 | } | ||
94 | |||
95 | public bool IsInventoryReadAuthorized(UUID authToken, Uri owner) | ||
96 | { | ||
97 | return true; | ||
98 | } | ||
99 | |||
100 | public bool IsInventoryWriteAuthorized(UUID authToken, Uri owner) | ||
101 | { | ||
102 | return true; | ||
103 | } | ||
104 | } | ||
105 | } | ||
diff --git a/OpenSim/Grid/AssetInventoryServer/Plugins/BrowseFrontendPlugin.cs b/OpenSim/Grid/AssetInventoryServer/Plugins/BrowseFrontendPlugin.cs deleted file mode 100644 index 90ea2e0..0000000 --- a/OpenSim/Grid/AssetInventoryServer/Plugins/BrowseFrontendPlugin.cs +++ /dev/null | |||
@@ -1,173 +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.Collections.Specialized; | ||
32 | using System.Net; | ||
33 | using System.Text; | ||
34 | using System.Web; | ||
35 | using OpenMetaverse; | ||
36 | using OpenSim.Framework; | ||
37 | using OpenSim.Framework.Servers; | ||
38 | using OpenSim.Framework.Servers.HttpServer; | ||
39 | using log4net; | ||
40 | |||
41 | namespace OpenSim.Grid.AssetInventoryServer.Plugins | ||
42 | { | ||
43 | public class BrowseFrontendPlugin : IAssetInventoryServerPlugin | ||
44 | { | ||
45 | private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); | ||
46 | private AssetInventoryServer m_server; | ||
47 | |||
48 | public BrowseFrontendPlugin() | ||
49 | { | ||
50 | } | ||
51 | |||
52 | #region IPlugin implementation | ||
53 | |||
54 | public void Initialise(AssetInventoryServer server) | ||
55 | { | ||
56 | m_server = server; | ||
57 | |||
58 | // Request for / or /?... | ||
59 | m_server.HttpServer.AddStreamHandler(new BrowseRequestHandler(server)); | ||
60 | |||
61 | m_log.Info("[BROWSEFRONTEND]: Browser Frontend loaded."); | ||
62 | } | ||
63 | |||
64 | /// <summary> | ||
65 | /// <para>Initialises asset interface</para> | ||
66 | /// </summary> | ||
67 | public void Initialise() | ||
68 | { | ||
69 | m_log.InfoFormat("[BROWSEFRONTEND]: {0} cannot be default-initialized!", Name); | ||
70 | throw new PluginNotInitialisedException(Name); | ||
71 | } | ||
72 | |||
73 | public void Dispose() | ||
74 | { | ||
75 | } | ||
76 | |||
77 | public string Version | ||
78 | { | ||
79 | // TODO: this should be something meaningful and not hardcoded? | ||
80 | get { return "0.1"; } | ||
81 | } | ||
82 | |||
83 | public string Name | ||
84 | { | ||
85 | get { return "BrowseFrontend"; } | ||
86 | } | ||
87 | |||
88 | #endregion IPlugin implementation | ||
89 | |||
90 | public class BrowseRequestHandler : BaseStreamHandler | ||
91 | { | ||
92 | AssetInventoryServer m_server; | ||
93 | |||
94 | //public BrowseRequestHandler(AssetInventoryServer server) : base("GET", "(^/$|(^/\?.*)") | ||
95 | public BrowseRequestHandler(AssetInventoryServer server) : base("GET", "/") | ||
96 | { | ||
97 | m_server = server; | ||
98 | } | ||
99 | |||
100 | public override string ContentType | ||
101 | { | ||
102 | get { return "text/html"; } | ||
103 | } | ||
104 | |||
105 | #region IStreamedRequestHandler implementation | ||
106 | |||
107 | public override byte[] Handle(string path, Stream request, OSHttpRequest httpRequest, OSHttpResponse httpResponse) | ||
108 | { | ||
109 | const int ASSETS_PER_PAGE = 25; | ||
110 | const string HEADER = "<html><head><title>Asset Server</title></head><body>"; | ||
111 | const string TABLE_HEADER = | ||
112 | "<table><tr><th>Name</th><th>Description</th><th>Type</th><th>ID</th><th>Temporary</th><th>SHA-1</th></tr>"; | ||
113 | const string TABLE_FOOTER = "</table>"; | ||
114 | const string FOOTER = "</body></html>"; | ||
115 | |||
116 | UUID authToken = Utils.GetAuthToken(httpRequest); | ||
117 | |||
118 | StringBuilder html = new StringBuilder(); | ||
119 | int start = 0; | ||
120 | uint page = 0; | ||
121 | |||
122 | if (!String.IsNullOrEmpty(httpRequest.Url.Query)) | ||
123 | { | ||
124 | NameValueCollection query = HttpUtility.ParseQueryString(httpRequest.Url.Query); | ||
125 | if (!String.IsNullOrEmpty(query["page"]) && UInt32.TryParse(query["page"], out page)) | ||
126 | start = (int)page * ASSETS_PER_PAGE; | ||
127 | } | ||
128 | |||
129 | html.AppendLine(HEADER); | ||
130 | |||
131 | html.AppendLine("<p>"); | ||
132 | if (page > 0) | ||
133 | html.AppendFormat("<a href=\"{0}?page={1}\">< Previous Page</a> | ", httpRequest.RawUrl, page - 1); | ||
134 | html.AppendFormat("<a href=\"{0}?page={1}\">Next Page ></a>", httpRequest.RawUrl, page + 1); | ||
135 | html.AppendLine("</p>"); | ||
136 | |||
137 | html.AppendLine(TABLE_HEADER); | ||
138 | |||
139 | m_server.StorageProvider.ForEach( | ||
140 | delegate(AssetMetadata data) | ||
141 | { | ||
142 | if (m_server.AuthorizationProvider.IsMetadataAuthorized(authToken, data.FullID)) | ||
143 | { | ||
144 | html.AppendLine(String.Format( | ||
145 | "<tr><td>{0}</td><td>{1}</td><td>{2}</td><td>{3}</td><td>{4}</td><td>{5}</td></tr>", | ||
146 | data.Name, data.Description, data.ContentType, data.ID, data.Temporary, | ||
147 | BitConverter.ToString(data.SHA1).Replace("-", String.Empty))); | ||
148 | } | ||
149 | else | ||
150 | { | ||
151 | html.AppendLine(String.Format( | ||
152 | "<tr><td>[Protected Asset]</td><td> </td><td> </td><td>{0}</td><td>{1}</td><td> </td></tr>", | ||
153 | data.ID, data.Temporary)); | ||
154 | } | ||
155 | }, start, ASSETS_PER_PAGE | ||
156 | ); | ||
157 | |||
158 | html.AppendLine(TABLE_FOOTER); | ||
159 | |||
160 | html.AppendLine(FOOTER); | ||
161 | |||
162 | byte[] responseData = System.Text.Encoding.UTF8.GetBytes(html.ToString()); | ||
163 | |||
164 | httpResponse.StatusCode = (int) HttpStatusCode.OK; | ||
165 | //httpResponse.Body.Write(responseData, 0, responseData.Length); | ||
166 | //httpResponse.Body.Flush(); | ||
167 | return responseData; | ||
168 | } | ||
169 | |||
170 | #endregion IStreamedRequestHandler implementation | ||
171 | } | ||
172 | } | ||
173 | } | ||
diff --git a/OpenSim/Grid/AssetInventoryServer/Plugins/InventoryArchivePlugin.cs b/OpenSim/Grid/AssetInventoryServer/Plugins/InventoryArchivePlugin.cs deleted file mode 100644 index 8323450..0000000 --- a/OpenSim/Grid/AssetInventoryServer/Plugins/InventoryArchivePlugin.cs +++ /dev/null | |||
@@ -1,211 +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.Net; | ||
30 | using System.IO; | ||
31 | using System.IO.Compression; | ||
32 | using System.Xml; | ||
33 | using System.Reflection; | ||
34 | using OpenMetaverse; | ||
35 | using OpenSim.Framework; | ||
36 | using OpenSim.Framework.Serialization; | ||
37 | using OpenSim.Framework.Serialization.External; | ||
38 | using OpenSim.Framework.Servers; | ||
39 | using OpenSim.Framework.Servers.HttpServer; | ||
40 | using log4net; | ||
41 | |||
42 | namespace OpenSim.Grid.AssetInventoryServer.Plugins | ||
43 | { | ||
44 | public class InventoryArchivePlugin : IAssetInventoryServerPlugin | ||
45 | { | ||
46 | private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); | ||
47 | private AssetInventoryServer m_server; | ||
48 | |||
49 | public InventoryArchivePlugin() | ||
50 | { | ||
51 | } | ||
52 | |||
53 | #region IPlugin implementation | ||
54 | |||
55 | public void Initialise(AssetInventoryServer server) | ||
56 | { | ||
57 | m_server = server; | ||
58 | |||
59 | m_server.HttpServer.AddStreamHandler(new GetInventoryArchive(server)); | ||
60 | |||
61 | m_log.Info("[INVENTORYARCHIVE]: Inventory Archive loaded."); | ||
62 | } | ||
63 | |||
64 | /// <summary> | ||
65 | /// <para>Initialises asset interface</para> | ||
66 | /// </summary> | ||
67 | public void Initialise() | ||
68 | { | ||
69 | m_log.InfoFormat("[INVENTORYARCHIVE]: {0} cannot be default-initialized!", Name); | ||
70 | throw new PluginNotInitialisedException(Name); | ||
71 | } | ||
72 | |||
73 | public void Dispose() | ||
74 | { | ||
75 | } | ||
76 | |||
77 | public string Version | ||
78 | { | ||
79 | // TODO: this should be something meaningful and not hardcoded? | ||
80 | get { return "0.1"; } | ||
81 | } | ||
82 | |||
83 | public string Name | ||
84 | { | ||
85 | get { return "InventoryArchive"; } | ||
86 | } | ||
87 | |||
88 | #endregion IPlugin implementation | ||
89 | |||
90 | public class GetInventoryArchive : BaseStreamHandler | ||
91 | { | ||
92 | AssetInventoryServer m_server; | ||
93 | |||
94 | //public GetInventoryArchive(AssetInventoryServer server) : base("GET", @"^/inventoryarchive/") | ||
95 | public GetInventoryArchive(AssetInventoryServer server) : base("GET", "/inventoryarchive") | ||
96 | { | ||
97 | m_server = server; | ||
98 | } | ||
99 | |||
100 | public override string ContentType | ||
101 | { | ||
102 | get { return "application/x-compressed"; } | ||
103 | } | ||
104 | |||
105 | public override byte[] Handle(string path, Stream request, OSHttpRequest httpRequest, OSHttpResponse httpResponse) | ||
106 | { | ||
107 | byte[] buffer = new byte[] {}; | ||
108 | UUID ownerID; | ||
109 | // Split the URL up to get the asset ID out | ||
110 | string[] rawUrl = httpRequest.Url.PathAndQuery.Split('/'); | ||
111 | |||
112 | if (rawUrl.Length >= 3 && rawUrl[2].Length >= 36 && UUID.TryParse(rawUrl[2].Substring(0, 36), out ownerID)) | ||
113 | { | ||
114 | Uri owner = Utils.GetOpenSimUri(ownerID); | ||
115 | InventoryCollection inventory; | ||
116 | BackendResponse storageResponse = m_server.InventoryProvider.TryFetchInventory(owner, out inventory); | ||
117 | |||
118 | if (storageResponse == BackendResponse.Success) | ||
119 | { | ||
120 | m_log.DebugFormat("[INVENTORYARCHIVE]: Archiving inventory for user UUID {0}", ownerID); | ||
121 | buffer = ArchiveInventoryCollection(inventory); | ||
122 | httpResponse.StatusCode = (int) HttpStatusCode.OK; | ||
123 | } | ||
124 | else | ||
125 | { | ||
126 | httpResponse.StatusCode = (int) HttpStatusCode.InternalServerError; | ||
127 | } | ||
128 | } | ||
129 | else | ||
130 | { | ||
131 | m_log.Warn("[INVENTORYARCHIVE]: Unrecognized inventory archive request: " + httpRequest.Url.PathAndQuery); | ||
132 | } | ||
133 | |||
134 | return buffer; | ||
135 | } | ||
136 | } | ||
137 | |||
138 | private static byte[] ArchiveInventoryCollection(InventoryCollection inventory) | ||
139 | { | ||
140 | byte[] buffer = new byte[] {}; | ||
141 | |||
142 | // Fill in each folder's Children dictionary. | ||
143 | InventoryFolderWithChildren rootFolder = BuildInventoryHierarchy(ref inventory); | ||
144 | |||
145 | // TODO: It's probably a bad idea to tar to memory for large | ||
146 | // inventories. | ||
147 | MemoryStream ms = new MemoryStream(); | ||
148 | GZipStream gzs = new GZipStream(ms, CompressionMode.Compress, true); | ||
149 | TarArchiveWriter archive = new TarArchiveWriter(gzs); | ||
150 | WriteInventoryFolderToArchive(archive, rootFolder, ArchiveConstants.INVENTORY_PATH); | ||
151 | |||
152 | archive.Close(); | ||
153 | |||
154 | ms.Seek(0, SeekOrigin.Begin); | ||
155 | buffer = ms.GetBuffer(); | ||
156 | Array.Resize<byte>(ref buffer, (int) ms.Length); | ||
157 | ms.Close(); | ||
158 | return buffer; | ||
159 | } | ||
160 | |||
161 | private static InventoryFolderWithChildren BuildInventoryHierarchy(ref InventoryCollection inventory) | ||
162 | { | ||
163 | m_log.DebugFormat("[INVENTORYARCHIVE]: Building inventory hierarchy"); | ||
164 | InventoryFolderWithChildren rootFolder = null; | ||
165 | |||
166 | foreach (InventoryFolderWithChildren parentFolder in inventory.Folders.Values) | ||
167 | { | ||
168 | // Grab the root folder, it has no parents. | ||
169 | if (UUID.Zero == parentFolder.ParentID) rootFolder = parentFolder; | ||
170 | |||
171 | foreach (InventoryFolderWithChildren folder in inventory.Folders.Values) | ||
172 | if (parentFolder.ID == folder.ParentID) | ||
173 | parentFolder.Children.Add(folder.ID, folder); | ||
174 | |||
175 | foreach (InventoryItemBase item in inventory.Items.Values) | ||
176 | if (parentFolder.ID == item.Folder) | ||
177 | parentFolder.Children.Add(item.ID, item); | ||
178 | } | ||
179 | |||
180 | return rootFolder; | ||
181 | } | ||
182 | |||
183 | private static void WriteInventoryFolderToArchive( | ||
184 | TarArchiveWriter archive, InventoryFolderWithChildren folder, string path) | ||
185 | { | ||
186 | path += string.Format("{0}{1}{2}/", folder.Name, ArchiveConstants.INVENTORY_NODE_NAME_COMPONENT_SEPARATOR, folder.ID); | ||
187 | archive.WriteDir(path); | ||
188 | |||
189 | foreach (InventoryNodeBase inventoryNode in folder.Children.Values) | ||
190 | { | ||
191 | if (inventoryNode is InventoryFolderWithChildren) | ||
192 | { | ||
193 | WriteInventoryFolderToArchive(archive, (InventoryFolderWithChildren) inventoryNode, path); | ||
194 | } | ||
195 | else if (inventoryNode is InventoryItemBase) | ||
196 | { | ||
197 | WriteInventoryItemToArchive(archive, (InventoryItemBase) inventoryNode, path); | ||
198 | } | ||
199 | } | ||
200 | } | ||
201 | |||
202 | private static void WriteInventoryItemToArchive(TarArchiveWriter archive, InventoryItemBase item, string path) | ||
203 | { | ||
204 | string filename = string.Format("{0}{1}_{2}.xml", path, item.Name, item.ID); | ||
205 | string serialization = UserInventoryItemSerializer.Serialize(item); | ||
206 | archive.WriteFile(filename, serialization); | ||
207 | |||
208 | //m_assetGatherer.GatherAssetUuids(item.AssetID, (AssetType) item.AssetType, assetUuids); | ||
209 | } | ||
210 | } | ||
211 | } | ||
diff --git a/OpenSim/Grid/AssetInventoryServer/Plugins/NullAuthenticationPlugin.cs b/OpenSim/Grid/AssetInventoryServer/Plugins/NullAuthenticationPlugin.cs deleted file mode 100644 index 026b3c8..0000000 --- a/OpenSim/Grid/AssetInventoryServer/Plugins/NullAuthenticationPlugin.cs +++ /dev/null | |||
@@ -1,95 +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.Reflection; | ||
30 | using OpenMetaverse; | ||
31 | using OpenSim.Framework; | ||
32 | using log4net; | ||
33 | |||
34 | namespace OpenSim.Grid.AssetInventoryServer.Plugins | ||
35 | { | ||
36 | public class NullAuthenticationPlugin : IAuthenticationProvider | ||
37 | { | ||
38 | private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); | ||
39 | //private AssetInventoryServer m_server; | ||
40 | |||
41 | public NullAuthenticationPlugin() | ||
42 | { | ||
43 | } | ||
44 | |||
45 | #region IPlugin implementation | ||
46 | |||
47 | public void Initialise(AssetInventoryServer server) | ||
48 | { | ||
49 | //m_server = server; | ||
50 | |||
51 | m_log.Info("[NULLAUTHENTICATION]: Null Authentication loaded."); | ||
52 | } | ||
53 | |||
54 | /// <summary> | ||
55 | /// <para>Initialises asset interface</para> | ||
56 | /// </summary> | ||
57 | public void Initialise() | ||
58 | { | ||
59 | m_log.InfoFormat("[NULLAUTHENTICATION]: {0} cannot be default-initialized!", Name); | ||
60 | throw new PluginNotInitialisedException(Name); | ||
61 | } | ||
62 | |||
63 | public void Dispose() | ||
64 | { | ||
65 | } | ||
66 | |||
67 | public string Version | ||
68 | { | ||
69 | // TODO: this should be something meaningful and not hardcoded? | ||
70 | get { return "0.1"; } | ||
71 | } | ||
72 | |||
73 | public string Name | ||
74 | { | ||
75 | get { return "NullAuthentication"; } | ||
76 | } | ||
77 | |||
78 | #endregion IPlugin implementation | ||
79 | |||
80 | public void AddIdentifier(UUID authToken, Uri identifier) | ||
81 | { | ||
82 | } | ||
83 | |||
84 | public bool RemoveIdentifier(UUID authToken) | ||
85 | { | ||
86 | return true; | ||
87 | } | ||
88 | |||
89 | public bool TryGetIdentifier(UUID authToken, out Uri identifier) | ||
90 | { | ||
91 | identifier = null; | ||
92 | return true; | ||
93 | } | ||
94 | } | ||
95 | } | ||
diff --git a/OpenSim/Grid/AssetInventoryServer/Plugins/NullMetricsPlugin.cs b/OpenSim/Grid/AssetInventoryServer/Plugins/NullMetricsPlugin.cs deleted file mode 100644 index 8cde8f4..0000000 --- a/OpenSim/Grid/AssetInventoryServer/Plugins/NullMetricsPlugin.cs +++ /dev/null | |||
@@ -1,151 +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.Reflection; | ||
30 | using OpenMetaverse; | ||
31 | using log4net; | ||
32 | |||
33 | namespace OpenSim.Grid.AssetInventoryServer.Plugins | ||
34 | { | ||
35 | public class NullMetricsPlugin : IMetricsProvider | ||
36 | { | ||
37 | private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); | ||
38 | //private AssetInventoryServer m_server; | ||
39 | |||
40 | public NullMetricsPlugin() | ||
41 | { | ||
42 | } | ||
43 | |||
44 | #region IMetricsProvider implementation | ||
45 | |||
46 | public void LogAssetMetadataFetch(string extension, BackendResponse response, UUID assetID, DateTime time) | ||
47 | { | ||
48 | m_log.DebugFormat("[{0}]: AssetMetadataFetch(): AssetID: {1}, Response: {2}", extension, assetID, response); | ||
49 | } | ||
50 | |||
51 | public void LogAssetDataFetch(string extension, BackendResponse response, UUID assetID, int dataSize, DateTime time) | ||
52 | { | ||
53 | m_log.DebugFormat("[{0}]: AssetDataFetch(): AssetID: {1}, DataSize: {2}, Response: {3}", extension, assetID, | ||
54 | dataSize, response); | ||
55 | } | ||
56 | |||
57 | public void LogAssetCreate(string extension, BackendResponse response, UUID assetID, int dataSize, DateTime time) | ||
58 | { | ||
59 | m_log.DebugFormat("[{0}]: AssetCreate(): AssetID: {1}, DataSize: {2}, Response: {3}", extension, assetID, | ||
60 | dataSize, response); | ||
61 | } | ||
62 | |||
63 | public void LogInventoryFetch(string extension, BackendResponse response, Uri owner, UUID objID, bool folder, DateTime time) | ||
64 | { | ||
65 | m_log.DebugFormat("[{0}]: InventoryFetch(): ObjID: {1}, Folder: {2}, OwnerID: {3}, Response: {4}", extension, | ||
66 | objID, folder, owner, response); | ||
67 | } | ||
68 | |||
69 | public void LogInventoryFetchFolderContents(string extension, BackendResponse response, Uri owner, UUID folderID, DateTime time) | ||
70 | { | ||
71 | m_log.DebugFormat("[{0}]: InventoryFetchFolderContents(): FolderID: {1}, OwnerID: {2}, Response: {3}", extension, | ||
72 | folderID, owner, response); | ||
73 | } | ||
74 | |||
75 | public void LogInventoryFetchFolderList(string extension, BackendResponse response, Uri owner, DateTime time) | ||
76 | { | ||
77 | m_log.DebugFormat("[{0}]: InventoryFetchFolderList(): OwnerID: {1}, Response: {2}", extension, | ||
78 | owner, response); | ||
79 | } | ||
80 | |||
81 | public void LogInventoryFetchInventory(string extension, BackendResponse response, Uri owner, DateTime time) | ||
82 | { | ||
83 | m_log.DebugFormat("[{0}]: InventoryFetchInventory(): OwnerID: {1}, Response: {2}", extension, | ||
84 | owner, response); | ||
85 | } | ||
86 | |||
87 | public void LogInventoryFetchActiveGestures(string extension, BackendResponse response, Uri owner, DateTime time) | ||
88 | { | ||
89 | m_log.DebugFormat("[{0}]: InventoryFetchActiveGestures(): OwnerID: {1}, Response: {2}", extension, | ||
90 | owner, response); | ||
91 | } | ||
92 | |||
93 | public void LogInventoryCreate(string extension, BackendResponse response, Uri owner, bool folder, DateTime time) | ||
94 | { | ||
95 | m_log.DebugFormat("[{0}]: InventoryCreate(): OwnerID: {1}, Response: {2}", extension, | ||
96 | owner, response); | ||
97 | } | ||
98 | |||
99 | public void LogInventoryCreateInventory(string extension, BackendResponse response, DateTime time) | ||
100 | { | ||
101 | m_log.DebugFormat("[{0}]: InventoryCreateInventory(): Response: {1}", extension, | ||
102 | response); | ||
103 | } | ||
104 | |||
105 | public void LogInventoryDelete(string extension, BackendResponse response, Uri owner, UUID objID, bool folder, DateTime time) | ||
106 | { | ||
107 | m_log.DebugFormat("[{0}]: InventoryDelete(): OwnerID: {1}, Folder: {2}, Response: {3}", extension, | ||
108 | owner, folder, response); | ||
109 | } | ||
110 | |||
111 | public void LogInventoryPurgeFolder(string extension, BackendResponse response, Uri owner, UUID folderID, DateTime time) | ||
112 | { | ||
113 | m_log.DebugFormat("[{0}]: InventoryPurgeFolder(): OwnerID: {1}, FolderID: {2}, Response: {3}", extension, | ||
114 | owner, folderID, response); | ||
115 | } | ||
116 | |||
117 | #endregion IMetricsProvider implementation | ||
118 | |||
119 | #region IPlugin implementation | ||
120 | |||
121 | public void Initialise(AssetInventoryServer server) | ||
122 | { | ||
123 | //m_server = server; | ||
124 | } | ||
125 | |||
126 | /// <summary> | ||
127 | /// <para>Initialises metrics interface</para> | ||
128 | /// </summary> | ||
129 | public void Initialise() | ||
130 | { | ||
131 | m_log.Info("[NULLMETRICS]: Null metrics loaded."); | ||
132 | } | ||
133 | |||
134 | public void Dispose() | ||
135 | { | ||
136 | } | ||
137 | |||
138 | public string Version | ||
139 | { | ||
140 | // TODO: this should be something meaningful and not hardcoded? | ||
141 | get { return "0.1"; } | ||
142 | } | ||
143 | |||
144 | public string Name | ||
145 | { | ||
146 | get { return "NullMetrics"; } | ||
147 | } | ||
148 | |||
149 | #endregion IPlugin implementation | ||
150 | } | ||
151 | } | ||
diff --git a/OpenSim/Grid/AssetInventoryServer/Plugins/OpenSim/OpenSimAssetFrontendPlugin.cs b/OpenSim/Grid/AssetInventoryServer/Plugins/OpenSim/OpenSimAssetFrontendPlugin.cs deleted file mode 100644 index e4be55e..0000000 --- a/OpenSim/Grid/AssetInventoryServer/Plugins/OpenSim/OpenSimAssetFrontendPlugin.cs +++ /dev/null | |||
@@ -1,198 +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.Reflection; | ||
30 | using System.Net; | ||
31 | using System.IO; | ||
32 | using System.Text; | ||
33 | using System.Xml; | ||
34 | using System.Xml.Serialization; | ||
35 | using OpenMetaverse; | ||
36 | using OpenSim.Framework; | ||
37 | using OpenSim.Framework.Servers; | ||
38 | using OpenSim.Framework.Servers.HttpServer; | ||
39 | using log4net; | ||
40 | |||
41 | namespace OpenSim.Grid.AssetInventoryServer.Plugins.OpenSim | ||
42 | { | ||
43 | public class OpenSimAssetFrontendPlugin : IAssetInventoryServerPlugin | ||
44 | { | ||
45 | private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); | ||
46 | private AssetInventoryServer m_server; | ||
47 | |||
48 | public OpenSimAssetFrontendPlugin() | ||
49 | { | ||
50 | } | ||
51 | |||
52 | #region IPlugin implementation | ||
53 | |||
54 | public void Initialise(AssetInventoryServer server) | ||
55 | { | ||
56 | m_server = server; | ||
57 | |||
58 | // Asset request | ||
59 | m_server.HttpServer.AddStreamHandler(new AssetRequestHandler(server)); | ||
60 | |||
61 | // Asset creation | ||
62 | m_server.HttpServer.AddStreamHandler(new AssetPostHandler(server)); | ||
63 | |||
64 | m_log.Info("[OPENSIMASSETFRONTEND]: OpenSim Asset Frontend loaded."); | ||
65 | } | ||
66 | |||
67 | /// <summary> | ||
68 | /// <para>Initialises asset interface</para> | ||
69 | /// </summary> | ||
70 | public void Initialise() | ||
71 | { | ||
72 | m_log.InfoFormat("[OPENSIMASSETFRONTEND]: {0} cannot be default-initialized!", Name); | ||
73 | throw new PluginNotInitialisedException(Name); | ||
74 | } | ||
75 | |||
76 | public void Dispose() | ||
77 | { | ||
78 | } | ||
79 | |||
80 | public string Version | ||
81 | { | ||
82 | // TODO: this should be something meaningful and not hardcoded? | ||
83 | get { return "0.1"; } | ||
84 | } | ||
85 | |||
86 | public string Name | ||
87 | { | ||
88 | get { return "OpenSimAssetFrontend"; } | ||
89 | } | ||
90 | |||
91 | #endregion IPlugin implementation | ||
92 | |||
93 | public class AssetRequestHandler : BaseStreamHandler | ||
94 | { | ||
95 | AssetInventoryServer m_server; | ||
96 | |||
97 | //public AssetRequestHandler(AssetInventoryServer server) : base("GET", "^/assets") | ||
98 | public AssetRequestHandler(AssetInventoryServer server) : base("GET", "/assets") | ||
99 | { | ||
100 | m_server = server; | ||
101 | } | ||
102 | |||
103 | public override byte[] Handle(string path, Stream request, OSHttpRequest httpRequest, OSHttpResponse httpResponse) | ||
104 | { | ||
105 | byte[] buffer = new byte[] {}; | ||
106 | UUID assetID; | ||
107 | // Split the URL up to get the asset ID out | ||
108 | string[] rawUrl = httpRequest.Url.PathAndQuery.Split('/'); | ||
109 | |||
110 | if (rawUrl.Length >= 3 && rawUrl[2].Length >= 36 && UUID.TryParse(rawUrl[2].Substring(0, 36), out assetID)) | ||
111 | { | ||
112 | BackendResponse dataResponse; | ||
113 | |||
114 | AssetBase asset = new AssetBase(); | ||
115 | if ((dataResponse = m_server.StorageProvider.TryFetchDataMetadata(assetID, out asset)) == BackendResponse.Success) | ||
116 | { | ||
117 | if (rawUrl.Length >= 4 && rawUrl[3] == "data") | ||
118 | { | ||
119 | httpResponse.StatusCode = (int)HttpStatusCode.OK; | ||
120 | httpResponse.ContentType = Utils.SLAssetTypeToContentType(asset.Type); | ||
121 | buffer=asset.Data; | ||
122 | } | ||
123 | else | ||
124 | { | ||
125 | XmlSerializer xs = new XmlSerializer(typeof(AssetBase)); | ||
126 | MemoryStream ms = new MemoryStream(); | ||
127 | XmlTextWriter xw = new XmlTextWriter(ms, Encoding.UTF8); | ||
128 | xs.Serialize(xw, asset); | ||
129 | xw.Flush(); | ||
130 | |||
131 | ms.Seek(0, SeekOrigin.Begin); | ||
132 | buffer = ms.GetBuffer(); | ||
133 | Array.Resize<byte>(ref buffer, (int)ms.Length); | ||
134 | ms.Close(); | ||
135 | httpResponse.StatusCode = (int)HttpStatusCode.OK; | ||
136 | } | ||
137 | } | ||
138 | else | ||
139 | { | ||
140 | m_log.WarnFormat("[OPENSIMASSETFRONTEND]: Failed to fetch asset data or metadata for {0}: {1}", assetID, dataResponse); | ||
141 | httpResponse.StatusCode = (int) HttpStatusCode.NotFound; | ||
142 | } | ||
143 | } | ||
144 | else | ||
145 | { | ||
146 | m_log.Warn("[OPENSIMASSETFRONTEND]: Unrecognized OpenSim asset request: " + httpRequest.Url.PathAndQuery); | ||
147 | } | ||
148 | |||
149 | return buffer; | ||
150 | } | ||
151 | } | ||
152 | |||
153 | public class AssetPostHandler : BaseStreamHandler | ||
154 | { | ||
155 | AssetInventoryServer m_server; | ||
156 | |||
157 | //public AssetPostHandler(AssetInventoryServer server) : base("POST", "/^assets") | ||
158 | public AssetPostHandler(AssetInventoryServer server) : base("POST", "/assets") | ||
159 | { | ||
160 | m_server = server; | ||
161 | } | ||
162 | |||
163 | public override byte[] Handle(string path, Stream request, OSHttpRequest httpRequest, OSHttpResponse httpResponse) | ||
164 | { | ||
165 | AssetBase asset = null; | ||
166 | |||
167 | try | ||
168 | { | ||
169 | asset = (AssetBase) new XmlSerializer(typeof (AssetBase)).Deserialize(httpRequest.InputStream); | ||
170 | } | ||
171 | catch (Exception ex) | ||
172 | { | ||
173 | m_log.Warn("[OPENSIMASSETFRONTEND]: Failed to parse POST data (expecting AssetBase): " + ex.Message); | ||
174 | httpResponse.StatusCode = (int) HttpStatusCode.BadRequest; | ||
175 | } | ||
176 | |||
177 | if (asset != null && asset.Data != null && asset.Data.Length > 0) | ||
178 | { | ||
179 | BackendResponse storageResponse = m_server.StorageProvider.TryCreateAsset(asset); | ||
180 | |||
181 | if (storageResponse == BackendResponse.Success) | ||
182 | httpResponse.StatusCode = (int) HttpStatusCode.Created; | ||
183 | else if (storageResponse == BackendResponse.NotFound) | ||
184 | httpResponse.StatusCode = (int) HttpStatusCode.NotFound; | ||
185 | else | ||
186 | httpResponse.StatusCode = (int) HttpStatusCode.InternalServerError; | ||
187 | } | ||
188 | else | ||
189 | { | ||
190 | m_log.Warn("[OPENSIMASSETFRONTEND]: AssetPostHandler called with no asset data"); | ||
191 | httpResponse.StatusCode = (int) HttpStatusCode.BadRequest; | ||
192 | } | ||
193 | |||
194 | return new byte[] {}; | ||
195 | } | ||
196 | } | ||
197 | } | ||
198 | } | ||
diff --git a/OpenSim/Grid/AssetInventoryServer/Plugins/OpenSim/OpenSimAssetStoragePlugin.cs b/OpenSim/Grid/AssetInventoryServer/Plugins/OpenSim/OpenSimAssetStoragePlugin.cs deleted file mode 100644 index 92ac84f..0000000 --- a/OpenSim/Grid/AssetInventoryServer/Plugins/OpenSim/OpenSimAssetStoragePlugin.cs +++ /dev/null | |||
@@ -1,189 +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.Reflection; | ||
30 | using System.Data; | ||
31 | using System.Collections.Generic; | ||
32 | using OpenMetaverse; | ||
33 | using OpenSim.Framework; | ||
34 | using OpenSim.Data; | ||
35 | using Nini.Config; | ||
36 | using log4net; | ||
37 | |||
38 | namespace OpenSim.Grid.AssetInventoryServer.Plugins.OpenSim | ||
39 | { | ||
40 | public class OpenSimAssetStoragePlugin : IAssetStorageProvider | ||
41 | { | ||
42 | private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); | ||
43 | const string EXTENSION_NAME = "OpenSimAssetStorage"; // Used in metrics reporting | ||
44 | |||
45 | private AssetInventoryServer m_server; | ||
46 | private IAssetDataPlugin m_assetProvider; | ||
47 | private IConfig m_openSimConfig; | ||
48 | |||
49 | public OpenSimAssetStoragePlugin() | ||
50 | { | ||
51 | } | ||
52 | |||
53 | #region IAssetStorageProvider implementation | ||
54 | |||
55 | public BackendResponse TryFetchMetadata(UUID assetID, out AssetMetadata metadata) | ||
56 | { | ||
57 | metadata = null; | ||
58 | BackendResponse ret; | ||
59 | |||
60 | AssetBase asset = m_assetProvider.GetAsset(assetID); | ||
61 | |||
62 | if (asset == null) ret = BackendResponse.NotFound; | ||
63 | else | ||
64 | { | ||
65 | metadata = asset.Metadata; | ||
66 | ret = BackendResponse.Success; | ||
67 | } | ||
68 | |||
69 | m_server.MetricsProvider.LogAssetMetadataFetch(EXTENSION_NAME, ret, assetID, DateTime.Now); | ||
70 | return ret; | ||
71 | } | ||
72 | |||
73 | public BackendResponse TryFetchData(UUID assetID, out byte[] assetData) | ||
74 | { | ||
75 | assetData = null; | ||
76 | BackendResponse ret; | ||
77 | |||
78 | AssetBase asset = m_assetProvider.GetAsset(assetID); | ||
79 | |||
80 | if (asset == null) ret = BackendResponse.NotFound; | ||
81 | else | ||
82 | { | ||
83 | assetData = asset.Data; | ||
84 | ret = BackendResponse.Success; | ||
85 | } | ||
86 | |||
87 | m_server.MetricsProvider.LogAssetDataFetch(EXTENSION_NAME, ret, assetID, (assetData != null ? assetData.Length : 0), DateTime.Now); | ||
88 | return ret; | ||
89 | } | ||
90 | |||
91 | public BackendResponse TryFetchDataMetadata(UUID assetID, out AssetBase asset) | ||
92 | { | ||
93 | asset = m_assetProvider.GetAsset(assetID); | ||
94 | |||
95 | if (asset == null) return BackendResponse.NotFound; | ||
96 | |||
97 | return BackendResponse.Success; | ||
98 | } | ||
99 | |||
100 | public BackendResponse TryCreateAsset(AssetBase asset, out UUID assetID) | ||
101 | { | ||
102 | assetID = asset.FullID = UUID.Random(); | ||
103 | return TryCreateAsset(asset); | ||
104 | } | ||
105 | |||
106 | public BackendResponse TryCreateAsset(AssetBase asset) | ||
107 | { | ||
108 | BackendResponse ret; | ||
109 | |||
110 | m_assetProvider.StoreAsset(asset); | ||
111 | ret = BackendResponse.Success; | ||
112 | |||
113 | m_server.MetricsProvider.LogAssetCreate(EXTENSION_NAME, ret, asset.FullID, asset.Data.Length, DateTime.Now); | ||
114 | return ret; | ||
115 | } | ||
116 | |||
117 | public int ForEach(Action<AssetMetadata> action, int start, int count) | ||
118 | { | ||
119 | int rowCount = 0; | ||
120 | |||
121 | foreach (AssetMetadata metadata in m_assetProvider.FetchAssetMetadataSet(start, count)) | ||
122 | { | ||
123 | // We set the ContentType here because Utils is only in | ||
124 | // AssetInventoryServer. This should be moved to the DB | ||
125 | // backends when the equivalent of SLAssetTypeToContentType is | ||
126 | // in OpenSim.Framework or similar. | ||
127 | metadata.ContentType = Utils.SLAssetTypeToContentType(metadata.Type); | ||
128 | |||
129 | action(metadata); | ||
130 | ++rowCount; | ||
131 | } | ||
132 | |||
133 | return rowCount; | ||
134 | } | ||
135 | |||
136 | #endregion IAssetStorageProvider implementation | ||
137 | |||
138 | #region IPlugin implementation | ||
139 | |||
140 | public void Initialise(AssetInventoryServer server) | ||
141 | { | ||
142 | m_server = server; | ||
143 | m_openSimConfig = server.ConfigFile.Configs["OpenSim"]; | ||
144 | |||
145 | try | ||
146 | { | ||
147 | m_assetProvider = DataPluginFactory.LoadDataPlugin<IAssetDataPlugin>(m_openSimConfig.GetString("asset_database_provider"), | ||
148 | m_openSimConfig.GetString("asset_database_connect")); | ||
149 | if (m_assetProvider == null) | ||
150 | { | ||
151 | m_log.Error("[OPENSIMASSETSTORAGE]: Failed to load a database plugin, server halting."); | ||
152 | Environment.Exit(-1); | ||
153 | } | ||
154 | else | ||
155 | m_log.InfoFormat("[OPENSIMASSETSTORAGE]: Loaded storage backend: {0}", Version); | ||
156 | } | ||
157 | catch (Exception e) | ||
158 | { | ||
159 | m_log.WarnFormat("[OPENSIMASSETSTORAGE]: Failure loading data plugin: {0}", e.ToString()); | ||
160 | throw new PluginNotInitialisedException(Name); | ||
161 | } | ||
162 | } | ||
163 | |||
164 | /// <summary> | ||
165 | /// <para>Initialises asset interface</para> | ||
166 | /// </summary> | ||
167 | public void Initialise() | ||
168 | { | ||
169 | m_log.InfoFormat("[OPENSIMASSETSTORAGE]: {0} cannot be default-initialized!", Name); | ||
170 | throw new PluginNotInitialisedException(Name); | ||
171 | } | ||
172 | |||
173 | public void Dispose() | ||
174 | { | ||
175 | } | ||
176 | |||
177 | public string Version | ||
178 | { | ||
179 | get { return m_assetProvider.Version; } | ||
180 | } | ||
181 | |||
182 | public string Name | ||
183 | { | ||
184 | get { return "OpenSimAssetStorage"; } | ||
185 | } | ||
186 | |||
187 | #endregion IPlugin implementation | ||
188 | } | ||
189 | } | ||
diff --git a/OpenSim/Grid/AssetInventoryServer/Plugins/OpenSim/OpenSimInventoryFrontendPlugin.cs b/OpenSim/Grid/AssetInventoryServer/Plugins/OpenSim/OpenSimInventoryFrontendPlugin.cs deleted file mode 100644 index c83e911..0000000 --- a/OpenSim/Grid/AssetInventoryServer/Plugins/OpenSim/OpenSimInventoryFrontendPlugin.cs +++ /dev/null | |||
@@ -1,867 +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.Net; | ||
30 | using System.Reflection; | ||
31 | using System.Collections.Generic; | ||
32 | using System.IO; | ||
33 | using System.Xml; | ||
34 | using OpenMetaverse; | ||
35 | using OpenSim.Framework; | ||
36 | using OpenSim.Framework.Servers; | ||
37 | using OpenSim.Framework.Servers.HttpServer; | ||
38 | using log4net; | ||
39 | |||
40 | namespace OpenSim.Grid.AssetInventoryServer.Plugins.OpenSim | ||
41 | { | ||
42 | public class OpenSimInventoryFrontendPlugin : IAssetInventoryServerPlugin | ||
43 | { | ||
44 | private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); | ||
45 | private AssetInventoryServer m_server; | ||
46 | private Utils.InventoryCollectionSerializer collectionSerializer = new Utils.InventoryCollectionSerializer(); | ||
47 | |||
48 | public OpenSimInventoryFrontendPlugin() | ||
49 | { | ||
50 | } | ||
51 | |||
52 | #region IPlugin implementation | ||
53 | |||
54 | public void Initialise(AssetInventoryServer server) | ||
55 | { | ||
56 | m_server = server; | ||
57 | |||
58 | m_server.HttpServer.AddStreamHandler(new GetInventoryHandler(server, collectionSerializer)); | ||
59 | m_server.HttpServer.AddStreamHandler(new CreateInventoryHandler(server)); | ||
60 | m_server.HttpServer.AddStreamHandler(new NewFolderHandler(server)); | ||
61 | m_server.HttpServer.AddStreamHandler(new UpdateFolderHandler(server)); | ||
62 | m_server.HttpServer.AddStreamHandler(new MoveFolderHandler(server)); | ||
63 | m_server.HttpServer.AddStreamHandler(new PurgeFolderHandler(server)); | ||
64 | m_server.HttpServer.AddStreamHandler(new NewItemHandler(server)); | ||
65 | m_server.HttpServer.AddStreamHandler(new DeleteItemHandler(server)); | ||
66 | m_server.HttpServer.AddStreamHandler(new RootFoldersHandler(server)); | ||
67 | m_server.HttpServer.AddStreamHandler(new ActiveGesturesHandler(server)); | ||
68 | |||
69 | m_log.Info("[OPENSIMINVENTORYFRONTEND]: OpenSim Inventory Frontend loaded."); | ||
70 | } | ||
71 | |||
72 | /// <summary> | ||
73 | /// <para>Initialises asset interface</para> | ||
74 | /// </summary> | ||
75 | public void Initialise() | ||
76 | { | ||
77 | m_log.InfoFormat("[OPENSIMINVENTORYFRONTEND]: {0} cannot be default-initialized!", Name); | ||
78 | throw new PluginNotInitialisedException(Name); | ||
79 | } | ||
80 | |||
81 | public void Dispose() | ||
82 | { | ||
83 | } | ||
84 | |||
85 | public string Version | ||
86 | { | ||
87 | // TODO: this should be something meaningful and not hardcoded? | ||
88 | get { return "0.1"; } | ||
89 | } | ||
90 | |||
91 | public string Name | ||
92 | { | ||
93 | get { return "OpenSimInventoryFrontend"; } | ||
94 | } | ||
95 | |||
96 | #endregion IPlugin implementation | ||
97 | |||
98 | public class GetInventoryHandler : BaseStreamHandler | ||
99 | { | ||
100 | AssetInventoryServer m_server; | ||
101 | Utils.InventoryCollectionSerializer m_collectionSerializer; | ||
102 | |||
103 | //public GetInventoryHandler(AssetInventoryServer server, Utils.InventoryCollectionSerializer collectionSerializer) : base("POST", @"^/GetInventory/") | ||
104 | public GetInventoryHandler(AssetInventoryServer server, Utils.InventoryCollectionSerializer collectionSerializer) : base("POST", "/GetInventory") | ||
105 | { | ||
106 | m_server = server; | ||
107 | m_collectionSerializer = collectionSerializer; | ||
108 | } | ||
109 | |||
110 | public override byte[] Handle(string path, Stream request, OSHttpRequest httpRequest, OSHttpResponse httpResponse) | ||
111 | { | ||
112 | byte[] buffer = new byte[] {}; | ||
113 | UUID sessionID, agentID; | ||
114 | UUID ownerID = DeserializeUUID(httpRequest.InputStream, out agentID, out sessionID); | ||
115 | |||
116 | if (ownerID != UUID.Zero) | ||
117 | { | ||
118 | m_log.Warn("[OPENSIMINVENTORYFRONTEND]: GetInventory is not scalable on some inventory backends, avoid calling it wherever possible"); | ||
119 | |||
120 | Uri owner = Utils.GetOpenSimUri(ownerID); | ||
121 | InventoryCollection inventory; | ||
122 | BackendResponse storageResponse = m_server.InventoryProvider.TryFetchInventory(owner, out inventory); | ||
123 | |||
124 | if (storageResponse == BackendResponse.Success) | ||
125 | { | ||
126 | //collectionSerializer.Serialize(httpResponse.Body, inventory); | ||
127 | //httpResponse.Body.Flush(); | ||
128 | MemoryStream ms = new MemoryStream(); | ||
129 | m_collectionSerializer.Serialize(ms, inventory); | ||
130 | ms.Seek(0, SeekOrigin.Begin); | ||
131 | buffer = ms.GetBuffer(); | ||
132 | Array.Resize<byte>(ref buffer, (int) ms.Length); | ||
133 | ms.Close(); | ||
134 | httpResponse.StatusCode = (int) HttpStatusCode.OK; | ||
135 | } | ||
136 | else if (storageResponse == BackendResponse.NotFound) | ||
137 | { | ||
138 | // Return an empty inventory set to mimic OpenSim.Grid.InventoryServer.exe | ||
139 | inventory = new InventoryCollection(); | ||
140 | inventory.UserID = ownerID; | ||
141 | inventory.Folders = new Dictionary<UUID, InventoryFolderWithChildren>(); | ||
142 | inventory.Items = new Dictionary<UUID, InventoryItemBase>(); | ||
143 | //collectionSerializer.Serialize(httpResponse.Body, inventory); | ||
144 | //httpResponse.Body.Flush(); | ||
145 | MemoryStream ms = new MemoryStream(); | ||
146 | m_collectionSerializer.Serialize(ms, inventory); | ||
147 | ms.Seek(0, SeekOrigin.Begin); | ||
148 | buffer = ms.GetBuffer(); | ||
149 | Array.Resize<byte>(ref buffer, (int) ms.Length); | ||
150 | ms.Close(); | ||
151 | httpResponse.StatusCode = (int) HttpStatusCode.OK; | ||
152 | } | ||
153 | else | ||
154 | { | ||
155 | httpResponse.StatusCode = (int) HttpStatusCode.InternalServerError; | ||
156 | } | ||
157 | } | ||
158 | else | ||
159 | { | ||
160 | httpResponse.StatusCode = (int) HttpStatusCode.BadRequest; | ||
161 | } | ||
162 | |||
163 | return buffer; | ||
164 | } | ||
165 | } | ||
166 | |||
167 | public class CreateInventoryHandler : BaseStreamHandler | ||
168 | { | ||
169 | AssetInventoryServer m_server; | ||
170 | |||
171 | //public CreateInventoryHandler(AssetInventoryServer server) : base("POST", @"^/CreateInventory/") | ||
172 | public CreateInventoryHandler(AssetInventoryServer server) : base("POST", "/CreateInventory") | ||
173 | { | ||
174 | m_server = server; | ||
175 | } | ||
176 | |||
177 | public override byte[] Handle(string path, Stream request, OSHttpRequest httpRequest, OSHttpResponse httpResponse) | ||
178 | { | ||
179 | UUID ownerID = DeserializeUUID(httpRequest.InputStream); | ||
180 | |||
181 | if (ownerID != UUID.Zero) | ||
182 | { | ||
183 | Uri owner = Utils.GetOpenSimUri(ownerID); | ||
184 | m_log.DebugFormat("[OPENSIMINVENTORYFRONTEND]: Created URI {0} for inventory creation", owner); | ||
185 | |||
186 | InventoryFolderWithChildren rootFolder = new InventoryFolderWithChildren("My Inventory", ownerID, UUID.Zero, (short)AssetType.Folder); | ||
187 | BackendResponse storageResponse = m_server.InventoryProvider.TryCreateInventory(owner, rootFolder); | ||
188 | if (storageResponse == BackendResponse.Success) | ||
189 | { | ||
190 | // TODO: The CreateFolder calls need to be executed in SimpleStorage. | ||
191 | //CreateFolder("Animations", ownerID, rootFolder.ID, AssetType.Animation); | ||
192 | //CreateFolder("Body Parts", ownerID, rootFolder.ID, AssetType.Bodypart); | ||
193 | //CreateFolder("Calling Cards", ownerID, rootFolder.ID, AssetType.CallingCard); | ||
194 | //CreateFolder("Clothing", ownerID, rootFolder.ID, AssetType.Clothing); | ||
195 | //CreateFolder("Gestures", ownerID, rootFolder.ID, AssetType.Gesture); | ||
196 | //CreateFolder("Landmarks", ownerID, rootFolder.ID, AssetType.Landmark); | ||
197 | //CreateFolder("Lost and Found", ownerID, rootFolder.ID, AssetType.LostAndFoundFolder); | ||
198 | //CreateFolder("Notecards", ownerID, rootFolder.ID, AssetType.Notecard); | ||
199 | //CreateFolder("Objects", ownerID, rootFolder.ID, AssetType.Object); | ||
200 | //CreateFolder("Photo Album", ownerID, rootFolder.ID, AssetType.SnapshotFolder); | ||
201 | //CreateFolder("Scripts", ownerID, rootFolder.ID, AssetType.LSLText); | ||
202 | //CreateFolder("Sounds", ownerID, rootFolder.ID, AssetType.Sound); | ||
203 | //CreateFolder("Textures", ownerID, rootFolder.ID, AssetType.Texture); | ||
204 | //CreateFolder("Trash", ownerID, rootFolder.ID, AssetType.TrashFolder); | ||
205 | |||
206 | return SerializeBool(true); | ||
207 | } | ||
208 | } | ||
209 | |||
210 | return SerializeBool(false); | ||
211 | } | ||
212 | } | ||
213 | |||
214 | public class NewFolderHandler : BaseStreamHandler | ||
215 | { | ||
216 | AssetInventoryServer m_server; | ||
217 | |||
218 | //public NewFolderHandler(AssetInventoryServer server) : base("POST", @"^/NewFolder/") | ||
219 | public NewFolderHandler(AssetInventoryServer server) : base("POST", "/NewFolder") | ||
220 | { | ||
221 | m_server = server; | ||
222 | } | ||
223 | |||
224 | public override byte[] Handle(string path, Stream request, OSHttpRequest httpRequest, OSHttpResponse httpResponse) | ||
225 | { | ||
226 | UUID agentID, sessionID; | ||
227 | InventoryFolderWithChildren folder = DeserializeFolder(httpRequest.InputStream, out agentID, out sessionID); | ||
228 | |||
229 | if (folder != null) | ||
230 | { | ||
231 | Uri owner = Utils.GetOpenSimUri(folder.Owner); | ||
232 | |||
233 | // Some calls that are moving or updating a folder instead | ||
234 | // of creating a new one will pass in an InventoryFolder | ||
235 | // without the name set and type set to 0. If this is the | ||
236 | // case we need to look up the name first and preserver | ||
237 | // it's type. | ||
238 | if (String.IsNullOrEmpty(folder.Name)) | ||
239 | { | ||
240 | InventoryFolderWithChildren oldFolder; | ||
241 | if (m_server.InventoryProvider.TryFetchFolder(owner, folder.ID, out oldFolder) == BackendResponse.Success) | ||
242 | { | ||
243 | folder.Name = oldFolder.Name; | ||
244 | folder.Type = oldFolder.Type; | ||
245 | } | ||
246 | } | ||
247 | |||
248 | BackendResponse storageResponse = m_server.InventoryProvider.TryCreateFolder(owner, folder); | ||
249 | |||
250 | if (storageResponse == BackendResponse.Success) | ||
251 | { | ||
252 | return SerializeBool(true); | ||
253 | } | ||
254 | } | ||
255 | |||
256 | return SerializeBool(false); | ||
257 | } | ||
258 | } | ||
259 | |||
260 | public class UpdateFolderHandler : BaseStreamHandler | ||
261 | { | ||
262 | AssetInventoryServer m_server; | ||
263 | |||
264 | //public UpdateFolderHandler(AssetInventoryServer server) : base("POST", @"^/UpdateFolder/") | ||
265 | public UpdateFolderHandler(AssetInventoryServer server) : base("POST", "/UpdateFolder") | ||
266 | { | ||
267 | m_server = server; | ||
268 | } | ||
269 | |||
270 | public override byte[] Handle(string path, Stream request, OSHttpRequest httpRequest, OSHttpResponse httpResponse) | ||
271 | { | ||
272 | return new NewFolderHandler(m_server).Handle(path, request, httpRequest, httpResponse); | ||
273 | } | ||
274 | } | ||
275 | |||
276 | public class MoveFolderHandler : BaseStreamHandler | ||
277 | { | ||
278 | AssetInventoryServer m_server; | ||
279 | |||
280 | //public MoveFolderHandler(AssetInventoryServer server) : base("POST", @"^/MoveFolder/") | ||
281 | public MoveFolderHandler(AssetInventoryServer server) : base("POST", "/MoveFolder") | ||
282 | { | ||
283 | m_server = server; | ||
284 | } | ||
285 | |||
286 | public override byte[] Handle(string path, Stream request, OSHttpRequest httpRequest, OSHttpResponse httpResponse) | ||
287 | { | ||
288 | return new NewFolderHandler(m_server).Handle(path, request, httpRequest, httpResponse); | ||
289 | } | ||
290 | } | ||
291 | |||
292 | public class PurgeFolderHandler : BaseStreamHandler | ||
293 | { | ||
294 | AssetInventoryServer m_server; | ||
295 | |||
296 | //public PurgeFolderHandler(AssetInventoryServer server) : base("POST", @"^/PurgeFolder/") | ||
297 | public PurgeFolderHandler(AssetInventoryServer server) : base("POST", "/PurgeFolder") | ||
298 | { | ||
299 | m_server = server; | ||
300 | } | ||
301 | |||
302 | public override byte[] Handle(string path, Stream request, OSHttpRequest httpRequest, OSHttpResponse httpResponse) | ||
303 | { | ||
304 | UUID agentID, sessionID; | ||
305 | InventoryFolderWithChildren folder = DeserializeFolder(httpRequest.InputStream, out agentID, out sessionID); | ||
306 | |||
307 | if (folder != null) | ||
308 | { | ||
309 | Uri owner = Utils.GetOpenSimUri(folder.Owner); | ||
310 | BackendResponse storageResponse = m_server.InventoryProvider.TryPurgeFolder(owner, folder.ID); | ||
311 | |||
312 | if (storageResponse == BackendResponse.Success) | ||
313 | { | ||
314 | return SerializeBool(true); | ||
315 | } | ||
316 | } | ||
317 | |||
318 | return SerializeBool(false); | ||
319 | } | ||
320 | } | ||
321 | |||
322 | public class NewItemHandler : BaseStreamHandler | ||
323 | { | ||
324 | AssetInventoryServer m_server; | ||
325 | |||
326 | //public NewItemHandler(AssetInventoryServer server) : base("POST", @"^/NewItem/") | ||
327 | public NewItemHandler(AssetInventoryServer server) : base("POST", "/NewItem") | ||
328 | { | ||
329 | m_server = server; | ||
330 | } | ||
331 | |||
332 | public override byte[] Handle(string path, Stream request, OSHttpRequest httpRequest, OSHttpResponse httpResponse) | ||
333 | { | ||
334 | UUID agentID, sessionID; | ||
335 | InventoryItemBase item = DeserializeItem(httpRequest.InputStream, out agentID, out sessionID); | ||
336 | |||
337 | if (item != null) | ||
338 | { | ||
339 | Uri owner = Utils.GetOpenSimUri(agentID); | ||
340 | BackendResponse storageResponse = m_server.InventoryProvider.TryCreateItem(owner, item); | ||
341 | |||
342 | if (storageResponse == BackendResponse.Success) | ||
343 | { | ||
344 | return SerializeBool(true); | ||
345 | } | ||
346 | } | ||
347 | |||
348 | return SerializeBool(false); | ||
349 | } | ||
350 | } | ||
351 | |||
352 | public class DeleteItemHandler : BaseStreamHandler | ||
353 | { | ||
354 | AssetInventoryServer m_server; | ||
355 | |||
356 | //public DeleteItemHandler(AssetInventoryServer server) : base("POST", @"^/DeleteItem/") | ||
357 | public DeleteItemHandler(AssetInventoryServer server) : base("POST", "/DeleteItem") | ||
358 | { | ||
359 | m_server = server; | ||
360 | } | ||
361 | |||
362 | public override byte[] Handle(string path, Stream request, OSHttpRequest httpRequest, OSHttpResponse httpResponse) | ||
363 | { | ||
364 | UUID agentID, sessionID; | ||
365 | InventoryItemBase item = DeserializeItem(httpRequest.InputStream, out agentID, out sessionID); | ||
366 | |||
367 | if (item != null) | ||
368 | { | ||
369 | Uri owner = Utils.GetOpenSimUri(item.Owner); | ||
370 | BackendResponse storageResponse = m_server.InventoryProvider.TryDeleteItem(owner, item.ID); | ||
371 | |||
372 | if (storageResponse == BackendResponse.Success) | ||
373 | { | ||
374 | return SerializeBool(true); | ||
375 | } | ||
376 | } | ||
377 | |||
378 | return SerializeBool(false); | ||
379 | } | ||
380 | } | ||
381 | |||
382 | public class RootFoldersHandler : BaseStreamHandler | ||
383 | { | ||
384 | AssetInventoryServer m_server; | ||
385 | |||
386 | //public RootFoldersHandler(AssetInventoryServer server) : base("POST", @"^/RootFolders/") | ||
387 | public RootFoldersHandler(AssetInventoryServer server) : base("POST", "/RootFolders") | ||
388 | { | ||
389 | m_server = server; | ||
390 | } | ||
391 | |||
392 | public override byte[] Handle(string path, Stream request, OSHttpRequest httpRequest, OSHttpResponse httpResponse) | ||
393 | { | ||
394 | byte[] buffer = new byte[] {}; | ||
395 | UUID ownerID = DeserializeUUID(httpRequest.InputStream); | ||
396 | |||
397 | if (ownerID != UUID.Zero) | ||
398 | { | ||
399 | Uri owner = Utils.GetOpenSimUri(ownerID); | ||
400 | List<InventoryFolderWithChildren> skeleton; | ||
401 | BackendResponse storageResponse = m_server.InventoryProvider.TryFetchFolderList(owner, out skeleton); | ||
402 | |||
403 | if (storageResponse == BackendResponse.Success) | ||
404 | { | ||
405 | MemoryStream ms = new MemoryStream(); | ||
406 | SerializeFolderList(ms, skeleton); | ||
407 | ms.Seek(0, SeekOrigin.Begin); | ||
408 | buffer = ms.GetBuffer(); | ||
409 | Array.Resize<byte>(ref buffer, (int) ms.Length); | ||
410 | ms.Close(); | ||
411 | httpResponse.StatusCode = (int) HttpStatusCode.OK; | ||
412 | } | ||
413 | else if (storageResponse == BackendResponse.NotFound) | ||
414 | { | ||
415 | // Return an empty set of inventory so the requester knows that | ||
416 | // an inventory needs to be created for this agent | ||
417 | MemoryStream ms = new MemoryStream(); | ||
418 | SerializeFolderList(ms, new List<InventoryFolderWithChildren>(0)); | ||
419 | ms.Seek(0, SeekOrigin.Begin); | ||
420 | buffer = ms.GetBuffer(); | ||
421 | Array.Resize<byte>(ref buffer, (int) ms.Length); | ||
422 | ms.Close(); | ||
423 | httpResponse.StatusCode = (int) HttpStatusCode.OK; | ||
424 | } | ||
425 | else | ||
426 | { | ||
427 | httpResponse.StatusCode = (int) HttpStatusCode.InternalServerError; | ||
428 | } | ||
429 | } | ||
430 | else | ||
431 | { | ||
432 | httpResponse.StatusCode = (int) HttpStatusCode.BadRequest; | ||
433 | } | ||
434 | |||
435 | return buffer; | ||
436 | } | ||
437 | } | ||
438 | |||
439 | public class ActiveGesturesHandler : BaseStreamHandler | ||
440 | { | ||
441 | AssetInventoryServer m_server; | ||
442 | |||
443 | //public ActiveGesturesHandler(AssetInventoryServer server) : base("POST", @"^/ActiveGestures/") | ||
444 | public ActiveGesturesHandler(AssetInventoryServer server) : base("POST", "/ActiveGestures") | ||
445 | { | ||
446 | m_server = server; | ||
447 | } | ||
448 | |||
449 | public override byte[] Handle(string path, Stream request, OSHttpRequest httpRequest, OSHttpResponse httpResponse) | ||
450 | { | ||
451 | byte[] buffer = new byte[] {}; | ||
452 | UUID ownerID = DeserializeUUID(httpRequest.InputStream); | ||
453 | |||
454 | if (ownerID != UUID.Zero) | ||
455 | { | ||
456 | Uri owner = Utils.GetOpenSimUri(ownerID); | ||
457 | List<InventoryItemBase> gestures; | ||
458 | BackendResponse storageResponse = m_server.InventoryProvider.TryFetchActiveGestures(owner, out gestures); | ||
459 | |||
460 | if (storageResponse == BackendResponse.Success) | ||
461 | { | ||
462 | MemoryStream ms = new MemoryStream(); | ||
463 | SerializeItemList(ms, gestures); | ||
464 | ms.Seek(0, SeekOrigin.Begin); | ||
465 | buffer = ms.GetBuffer(); | ||
466 | Array.Resize<byte>(ref buffer, (int) ms.Length); | ||
467 | ms.Close(); | ||
468 | httpResponse.StatusCode = (int) HttpStatusCode.OK; | ||
469 | } | ||
470 | else if (storageResponse == BackendResponse.NotFound) | ||
471 | { | ||
472 | // Return an empty set of gestures to match OpenSim.Grid.InventoryServer.exe behavior | ||
473 | MemoryStream ms = new MemoryStream(); | ||
474 | SerializeItemList(ms, new List<InventoryItemBase>(0)); | ||
475 | ms.Seek(0, SeekOrigin.Begin); | ||
476 | buffer = ms.GetBuffer(); | ||
477 | Array.Resize<byte>(ref buffer, (int) ms.Length); | ||
478 | ms.Close(); | ||
479 | httpResponse.StatusCode = (int) HttpStatusCode.OK; | ||
480 | } | ||
481 | else | ||
482 | { | ||
483 | httpResponse.StatusCode = (int) HttpStatusCode.InternalServerError; | ||
484 | } | ||
485 | } | ||
486 | else | ||
487 | { | ||
488 | httpResponse.StatusCode = (int) HttpStatusCode.BadRequest; | ||
489 | } | ||
490 | |||
491 | return buffer; | ||
492 | } | ||
493 | } | ||
494 | |||
495 | //BackendResponse CreateFolder(string name, UUID ownerID, UUID parentID, AssetType assetType) | ||
496 | //{ | ||
497 | // InventoryFolder folder = new InventoryFolder(name, ownerID, parentID, (short)assetType); | ||
498 | // Uri owner = Utils.GetOpenSimUri(ownerID); | ||
499 | // return m_server.InventoryProvider.TryCreateFolder(owner, folder); | ||
500 | //} | ||
501 | |||
502 | private static UUID DeserializeUUID(Stream stream) | ||
503 | { | ||
504 | UUID id = UUID.Zero; | ||
505 | |||
506 | try | ||
507 | { | ||
508 | using (XmlReader reader = XmlReader.Create(stream)) | ||
509 | { | ||
510 | reader.MoveToContent(); | ||
511 | UUID.TryParse(reader.ReadElementContentAsString("guid", String.Empty), out id); | ||
512 | } | ||
513 | } | ||
514 | catch (Exception ex) | ||
515 | { | ||
516 | m_log.Warn("[OPENSIMINVENTORYFRONTEND]: Failed to parse POST data (expecting guid): " + ex.Message); | ||
517 | } | ||
518 | |||
519 | return id; | ||
520 | } | ||
521 | |||
522 | private static UUID DeserializeUUID(Stream stream, out UUID agentID, out UUID sessionID) | ||
523 | { | ||
524 | UUID id; | ||
525 | |||
526 | try | ||
527 | { | ||
528 | using (XmlReader reader = XmlReader.Create(stream)) | ||
529 | { | ||
530 | reader.MoveToContent(); | ||
531 | reader.ReadStartElement("RestSessionObjectOfGuid"); | ||
532 | UUID.TryParse(reader.ReadElementContentAsString("SessionID", String.Empty), out sessionID); | ||
533 | UUID.TryParse(reader.ReadElementContentAsString("AvatarID", String.Empty), out agentID); | ||
534 | UUID.TryParse(reader.ReadElementContentAsString("Body", String.Empty), out id); | ||
535 | reader.ReadEndElement(); | ||
536 | } | ||
537 | } | ||
538 | catch (Exception ex) | ||
539 | { | ||
540 | m_log.Warn("[OPENSIMINVENTORYFRONTEND]: Failed to parse GetInventory POST data: " + ex.Message); | ||
541 | agentID = UUID.Zero; | ||
542 | sessionID = UUID.Zero; | ||
543 | return UUID.Zero; | ||
544 | } | ||
545 | |||
546 | return id; | ||
547 | } | ||
548 | |||
549 | private static InventoryFolderWithChildren DeserializeFolder(Stream stream, out UUID agentID, out UUID sessionID) | ||
550 | { | ||
551 | InventoryFolderWithChildren folder = new InventoryFolderWithChildren(); | ||
552 | |||
553 | try | ||
554 | { | ||
555 | using (XmlReader reader = XmlReader.Create(stream)) | ||
556 | { | ||
557 | reader.MoveToContent(); | ||
558 | reader.ReadStartElement("RestSessionObjectOfInventoryFolderBase"); | ||
559 | UUID.TryParse(reader.ReadElementContentAsString("SessionID", String.Empty), out sessionID); | ||
560 | UUID.TryParse(reader.ReadElementContentAsString("AvatarID", String.Empty), out agentID); | ||
561 | reader.ReadStartElement("Body"); | ||
562 | if (reader.Name == "Name") | ||
563 | folder.Name = reader.ReadElementContentAsString("Name", String.Empty); | ||
564 | else | ||
565 | folder.Name = String.Empty; | ||
566 | |||
567 | UUID dummyUUID; | ||
568 | ReadUUID(reader, "ID", out dummyUUID); | ||
569 | folder.ID = dummyUUID; | ||
570 | ReadUUID(reader, "Owner", out dummyUUID); | ||
571 | folder.Owner = dummyUUID; | ||
572 | ReadUUID(reader, "ParentID", out dummyUUID); | ||
573 | folder.ParentID = dummyUUID; | ||
574 | |||
575 | short dummyType; | ||
576 | Int16.TryParse(reader.ReadElementContentAsString("Type", String.Empty), out dummyType); | ||
577 | folder.Type = dummyType; | ||
578 | |||
579 | ushort dummyVersion; | ||
580 | UInt16.TryParse(reader.ReadElementContentAsString("Version", String.Empty), out dummyVersion); | ||
581 | folder.Version = dummyVersion; | ||
582 | |||
583 | reader.ReadEndElement(); | ||
584 | reader.ReadEndElement(); | ||
585 | } | ||
586 | } | ||
587 | catch (Exception ex) | ||
588 | { | ||
589 | m_log.Warn("[OPENSIMINVENTORYFRONTEND]: Failed to parse POST data (expecting InventoryFolderBase): " + ex.Message); | ||
590 | agentID = UUID.Zero; | ||
591 | sessionID = UUID.Zero; | ||
592 | return null; | ||
593 | } | ||
594 | |||
595 | return folder; | ||
596 | } | ||
597 | |||
598 | private static InventoryItemBase DeserializeItem(Stream stream, out UUID agentID, out UUID sessionID) | ||
599 | { | ||
600 | InventoryItemBase item = new InventoryItemBase(); | ||
601 | |||
602 | try | ||
603 | { | ||
604 | using (XmlReader reader = XmlReader.Create(stream)) | ||
605 | { | ||
606 | reader.MoveToContent(); | ||
607 | reader.ReadStartElement("RestSessionObjectOfInventoryItemBase"); | ||
608 | UUID.TryParse(reader.ReadElementContentAsString("SessionID", String.Empty), out sessionID); | ||
609 | UUID.TryParse(reader.ReadElementContentAsString("AvatarID", String.Empty), out agentID); | ||
610 | reader.ReadStartElement("Body"); | ||
611 | |||
612 | item.Name = reader.ReadElementContentAsString("Name", String.Empty); | ||
613 | |||
614 | UUID dummyUUID; | ||
615 | ReadUUID(reader, "ID", out dummyUUID); | ||
616 | item.ID = dummyUUID; | ||
617 | |||
618 | ReadUUID(reader, "Owner", out dummyUUID); | ||
619 | item.Owner = dummyUUID; | ||
620 | |||
621 | int dummyInt; | ||
622 | Int32.TryParse(reader.ReadElementContentAsString("InvType", String.Empty), out dummyInt); | ||
623 | item.InvType = dummyInt; | ||
624 | |||
625 | ReadUUID(reader, "Folder", out dummyUUID); | ||
626 | item.Folder = dummyUUID; | ||
627 | |||
628 | item.CreatorId = reader.ReadElementContentAsString("CreatorId", String.Empty); | ||
629 | item.Description = reader.ReadElementContentAsString("Description", String.Empty); | ||
630 | |||
631 | uint dummyUInt; | ||
632 | UInt32.TryParse(reader.ReadElementContentAsString("NextPermissions", String.Empty), out dummyUInt); | ||
633 | item.NextPermissions = dummyUInt; | ||
634 | UInt32.TryParse(reader.ReadElementContentAsString("CurrentPermissions", String.Empty), out dummyUInt); | ||
635 | item.CurrentPermissions = dummyUInt; | ||
636 | UInt32.TryParse(reader.ReadElementContentAsString("BasePermissions", String.Empty), out dummyUInt); | ||
637 | item.BasePermissions = dummyUInt; | ||
638 | UInt32.TryParse(reader.ReadElementContentAsString("EveryOnePermissions", String.Empty), out dummyUInt); | ||
639 | item.EveryOnePermissions = dummyUInt; | ||
640 | UInt32.TryParse(reader.ReadElementContentAsString("GroupPermissions", String.Empty), out dummyUInt); | ||
641 | item.GroupPermissions = dummyUInt; | ||
642 | |||
643 | Int32.TryParse(reader.ReadElementContentAsString("AssetType", String.Empty), out dummyInt); | ||
644 | item.AssetType = dummyInt; | ||
645 | |||
646 | ReadUUID(reader, "AssetID", out dummyUUID); | ||
647 | item.AssetID = dummyUUID; | ||
648 | ReadUUID(reader, "GroupID", out dummyUUID); | ||
649 | item.GroupID = dummyUUID; | ||
650 | |||
651 | bool dummyBool; | ||
652 | Boolean.TryParse(reader.ReadElementContentAsString("GroupOwned", String.Empty), out dummyBool); | ||
653 | item.GroupOwned = dummyBool; | ||
654 | |||
655 | Int32.TryParse(reader.ReadElementContentAsString("SalePrice", String.Empty), out dummyInt); | ||
656 | item.SalePrice = dummyInt; | ||
657 | |||
658 | byte dummyByte; | ||
659 | Byte.TryParse(reader.ReadElementContentAsString("SaleType", String.Empty), out dummyByte); | ||
660 | item.SaleType = dummyByte; | ||
661 | |||
662 | UInt32.TryParse(reader.ReadElementContentAsString("Flags", String.Empty), out dummyUInt); | ||
663 | item.Flags = dummyUInt; | ||
664 | |||
665 | Int32.TryParse(reader.ReadElementContentAsString("CreationDate", String.Empty), out dummyInt); | ||
666 | item.CreationDate = dummyInt; | ||
667 | |||
668 | reader.ReadEndElement(); | ||
669 | reader.ReadEndElement(); | ||
670 | } | ||
671 | } | ||
672 | catch (Exception ex) | ||
673 | { | ||
674 | m_log.Warn("[OPENSIMINVENTORYFRONTEND]: Failed to parse POST data (expecting InventoryItemBase): " + ex.Message); | ||
675 | agentID = UUID.Zero; | ||
676 | sessionID = UUID.Zero; | ||
677 | return null; | ||
678 | } | ||
679 | |||
680 | return item; | ||
681 | } | ||
682 | |||
683 | private static byte[] SerializeBool(bool value) | ||
684 | { | ||
685 | byte[] buffer; | ||
686 | MemoryStream ms = new MemoryStream(); | ||
687 | |||
688 | using (XmlWriter writer = XmlWriter.Create(ms)) | ||
689 | { | ||
690 | writer.WriteStartDocument(); | ||
691 | writer.WriteStartElement("boolean"); | ||
692 | writer.WriteAttributeString("xmlns", "xsi", null, "http://www.w3.org/2001/XMLSchema-instance"); | ||
693 | writer.WriteAttributeString("xmlns", "xsd", null, "http://www.w3.org/2001/XMLSchema"); | ||
694 | writer.WriteString(value.ToString().ToLower()); | ||
695 | writer.WriteEndElement(); | ||
696 | writer.WriteEndDocument(); | ||
697 | writer.Flush(); | ||
698 | } | ||
699 | |||
700 | ms.Seek(0, SeekOrigin.Begin); | ||
701 | buffer = ms.GetBuffer(); | ||
702 | Array.Resize<byte>(ref buffer, (int) ms.Length); | ||
703 | ms.Close(); | ||
704 | |||
705 | return buffer; | ||
706 | } | ||
707 | |||
708 | private static void SerializeFolderList(Stream stream, List<InventoryFolderWithChildren> folders) | ||
709 | { | ||
710 | using (XmlWriter writer = XmlWriter.Create(stream)) | ||
711 | { | ||
712 | writer.WriteStartDocument(); | ||
713 | writer.WriteStartElement("ArrayOfInventoryFolderBase"); | ||
714 | writer.WriteAttributeString("xmlns", "xsi", null, "http://www.w3.org/2001/XMLSchema-instance"); | ||
715 | writer.WriteAttributeString("xmlns", "xsd", null, "http://www.w3.org/2001/XMLSchema"); | ||
716 | |||
717 | if (folders != null) | ||
718 | { | ||
719 | foreach (InventoryFolderWithChildren folder in folders) | ||
720 | { | ||
721 | writer.WriteStartElement("InventoryFolderBase"); | ||
722 | writer.WriteElementString("Name", folder.Name); | ||
723 | WriteUUID(writer, "Owner", folder.Owner); | ||
724 | WriteUUID(writer, "ParentID", folder.ParentID); | ||
725 | WriteUUID(writer, "ID", folder.ID); | ||
726 | writer.WriteElementString("Type", XmlConvert.ToString(folder.Type)); | ||
727 | writer.WriteElementString("Version", XmlConvert.ToString(folder.Version)); | ||
728 | writer.WriteEndElement(); | ||
729 | } | ||
730 | } | ||
731 | |||
732 | writer.WriteEndElement(); | ||
733 | writer.WriteEndDocument(); | ||
734 | |||
735 | writer.Flush(); | ||
736 | } | ||
737 | |||
738 | stream.Flush(); | ||
739 | } | ||
740 | |||
741 | private static void SerializeItemList(Stream stream, List<InventoryItemBase> items) | ||
742 | { | ||
743 | using (XmlWriter writer = XmlWriter.Create(stream)) | ||
744 | { | ||
745 | writer.WriteStartDocument(); | ||
746 | writer.WriteStartElement("ArrayOfInventoryItemBase"); | ||
747 | writer.WriteAttributeString("xmlns", "xsi", null, "http://www.w3.org/2001/XMLSchema-instance"); | ||
748 | writer.WriteAttributeString("xmlns", "xsd", null, "http://www.w3.org/2001/XMLSchema"); | ||
749 | |||
750 | if (items != null) | ||
751 | { | ||
752 | foreach (InventoryItemBase item in items) | ||
753 | { | ||
754 | writer.WriteStartElement("InventoryItemBase"); | ||
755 | WriteUUID(writer, "ID", item.ID); | ||
756 | writer.WriteElementString("InvType", XmlConvert.ToString(item.InvType)); | ||
757 | WriteUUID(writer, "Folder", item.Folder); | ||
758 | WriteUUID(writer, "Owner", item.Owner); | ||
759 | writer.WriteElementString("Creator", item.CreatorId); | ||
760 | writer.WriteElementString("Name", item.Name); | ||
761 | writer.WriteElementString("Description", item.Description); | ||
762 | writer.WriteElementString("NextPermissions", XmlConvert.ToString(item.NextPermissions)); | ||
763 | writer.WriteElementString("CurrentPermissions", XmlConvert.ToString(item.CurrentPermissions)); | ||
764 | writer.WriteElementString("BasePermissions", XmlConvert.ToString(item.BasePermissions)); | ||
765 | writer.WriteElementString("EveryOnePermissions", XmlConvert.ToString(item.EveryOnePermissions)); | ||
766 | writer.WriteElementString("GroupPermissions", XmlConvert.ToString(item.GroupPermissions)); | ||
767 | writer.WriteElementString("AssetType", XmlConvert.ToString(item.AssetType)); | ||
768 | WriteUUID(writer, "AssetID", item.AssetID); | ||
769 | WriteUUID(writer, "GroupID", item.GroupID); | ||
770 | writer.WriteElementString("GroupOwned", XmlConvert.ToString(item.GroupOwned)); | ||
771 | writer.WriteElementString("SalePrice", XmlConvert.ToString(item.SalePrice)); | ||
772 | writer.WriteElementString("SaleType", XmlConvert.ToString(item.SaleType)); | ||
773 | writer.WriteElementString("Flags", XmlConvert.ToString(item.Flags)); | ||
774 | writer.WriteElementString("CreationDate", XmlConvert.ToString(item.CreationDate)); | ||
775 | writer.WriteEndElement(); | ||
776 | } | ||
777 | } | ||
778 | |||
779 | writer.WriteEndElement(); | ||
780 | writer.WriteEndDocument(); | ||
781 | |||
782 | writer.Flush(); | ||
783 | } | ||
784 | |||
785 | stream.Flush(); | ||
786 | } | ||
787 | |||
788 | private static void WriteUUID(XmlWriter writer, string name, UUID id) | ||
789 | { | ||
790 | writer.WriteStartElement(name); | ||
791 | writer.WriteElementString("Guid", XmlConvert.ToString(id.Guid)); | ||
792 | writer.WriteEndElement(); | ||
793 | } | ||
794 | |||
795 | private static void ReadUUID(XmlReader reader, string name, out UUID id) | ||
796 | { | ||
797 | reader.ReadStartElement(name); | ||
798 | UUID.TryParse(reader.ReadElementContentAsString("Guid", String.Empty), out id); | ||
799 | reader.ReadEndElement(); | ||
800 | } | ||
801 | } | ||
802 | |||
803 | #region OpenSim AssetType | ||
804 | |||
805 | /// <summary> | ||
806 | /// The different types of grid assets | ||
807 | /// </summary> | ||
808 | public enum AssetType : sbyte | ||
809 | { | ||
810 | /// <summary>Unknown asset type</summary> | ||
811 | Unknown = -1, | ||
812 | /// <summary>Texture asset, stores in JPEG2000 J2C stream format</summary> | ||
813 | Texture = 0, | ||
814 | /// <summary>Sound asset</summary> | ||
815 | Sound = 1, | ||
816 | /// <summary>Calling card for another avatar</summary> | ||
817 | CallingCard = 2, | ||
818 | /// <summary>Link to a location in world</summary> | ||
819 | Landmark = 3, | ||
820 | // <summary>Legacy script asset, you should never see one of these</summary> | ||
821 | //[Obsolete] | ||
822 | //Script = 4, | ||
823 | /// <summary>Collection of textures and parameters that can be | ||
824 | /// worn by an avatar</summary> | ||
825 | Clothing = 5, | ||
826 | /// <summary>Primitive that can contain textures, sounds, | ||
827 | /// scripts and more</summary> | ||
828 | Object = 6, | ||
829 | /// <summary>Notecard asset</summary> | ||
830 | Notecard = 7, | ||
831 | /// <summary>Holds a collection of inventory items</summary> | ||
832 | Folder = 8, | ||
833 | /// <summary>Root inventory folder</summary> | ||
834 | RootFolder = 9, | ||
835 | /// <summary>Linden scripting language script</summary> | ||
836 | LSLText = 10, | ||
837 | /// <summary>LSO bytecode for a script</summary> | ||
838 | LSLBytecode = 11, | ||
839 | /// <summary>Uncompressed TGA texture</summary> | ||
840 | TextureTGA = 12, | ||
841 | /// <summary>Collection of textures and shape parameters that can | ||
842 | /// be worn</summary> | ||
843 | Bodypart = 13, | ||
844 | /// <summary>Trash folder</summary> | ||
845 | TrashFolder = 14, | ||
846 | /// <summary>Snapshot folder</summary> | ||
847 | SnapshotFolder = 15, | ||
848 | /// <summary>Lost and found folder</summary> | ||
849 | LostAndFoundFolder = 16, | ||
850 | /// <summary>Uncompressed sound</summary> | ||
851 | SoundWAV = 17, | ||
852 | /// <summary>Uncompressed TGA non-square image, not to be used as a | ||
853 | /// texture</summary> | ||
854 | ImageTGA = 18, | ||
855 | /// <summary>Compressed JPEG non-square image, not to be used as a | ||
856 | /// texture</summary> | ||
857 | ImageJPEG = 19, | ||
858 | /// <summary>Animation</summary> | ||
859 | Animation = 20, | ||
860 | /// <summary>Sequence of animations, sounds, chat, and pauses</summary> | ||
861 | Gesture = 21, | ||
862 | /// <summary>Simstate file</summary> | ||
863 | Simstate = 22, | ||
864 | } | ||
865 | |||
866 | #endregion OpenSim AssetType | ||
867 | } | ||
diff --git a/OpenSim/Grid/AssetInventoryServer/Plugins/OpenSim/OpenSimInventoryService.cs b/OpenSim/Grid/AssetInventoryServer/Plugins/OpenSim/OpenSimInventoryService.cs deleted file mode 100644 index 0effa9f..0000000 --- a/OpenSim/Grid/AssetInventoryServer/Plugins/OpenSim/OpenSimInventoryService.cs +++ /dev/null | |||
@@ -1,56 +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 OpenMetaverse; | ||
29 | using OpenSim.Framework; | ||
30 | using OpenSim.Framework.Communications; | ||
31 | using OpenSim.Data; | ||
32 | |||
33 | namespace OpenSim.Grid.AssetInventoryServer.Plugins.OpenSim | ||
34 | { | ||
35 | public class OpenSimInventoryService : InventoryServiceBase | ||
36 | { | ||
37 | public InventoryFolderWithChildren GetInventoryFolder(UUID folderID) | ||
38 | { | ||
39 | InventoryFolderBase baseFolder = null; | ||
40 | InventoryFolderWithChildren folder = null; | ||
41 | |||
42 | foreach (IInventoryDataPlugin plugin in m_plugins) | ||
43 | { | ||
44 | baseFolder = plugin.getInventoryFolder(folderID); | ||
45 | } | ||
46 | |||
47 | if (null != baseFolder) | ||
48 | { | ||
49 | folder = new InventoryFolderWithChildren(baseFolder); | ||
50 | folder.Children = null; // This call only returns data for the folder itself, no children data | ||
51 | } | ||
52 | |||
53 | return folder; | ||
54 | } | ||
55 | } | ||
56 | } | ||
diff --git a/OpenSim/Grid/AssetInventoryServer/Plugins/OpenSim/OpenSimInventoryStoragePlugin.cs b/OpenSim/Grid/AssetInventoryServer/Plugins/OpenSim/OpenSimInventoryStoragePlugin.cs deleted file mode 100644 index 2239b87..0000000 --- a/OpenSim/Grid/AssetInventoryServer/Plugins/OpenSim/OpenSimInventoryStoragePlugin.cs +++ /dev/null | |||
@@ -1,547 +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.Reflection; | ||
30 | using System.Collections.Generic; | ||
31 | using System.Data; | ||
32 | using OpenMetaverse; | ||
33 | using OpenSim.Framework; | ||
34 | using OpenSim.Data; | ||
35 | using Nini.Config; | ||
36 | using log4net; | ||
37 | |||
38 | namespace OpenSim.Grid.AssetInventoryServer.Plugins.OpenSim | ||
39 | { | ||
40 | public class OpenSimInventoryStoragePlugin : IInventoryStorageProvider | ||
41 | { | ||
42 | private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); | ||
43 | const string EXTENSION_NAME = "OpenSimInventoryStorage"; // Used in metrics reporting | ||
44 | |||
45 | private AssetInventoryServer m_server; | ||
46 | private IConfig m_openSimConfig; | ||
47 | private OpenSimInventoryService m_inventoryService; | ||
48 | |||
49 | public OpenSimInventoryStoragePlugin() | ||
50 | { | ||
51 | } | ||
52 | |||
53 | #region IInventoryStorageProvider implementation | ||
54 | |||
55 | public BackendResponse TryFetchItem(Uri owner, UUID itemID, out InventoryItemBase item) | ||
56 | { | ||
57 | item = null; | ||
58 | //BackendResponse ret; | ||
59 | |||
60 | //using (MySqlConnection dbConnection = new MySqlConnection(m_openSimConfig.GetString("inventory_database_connect"))) | ||
61 | //{ | ||
62 | // IDataReader reader; | ||
63 | |||
64 | // try | ||
65 | // { | ||
66 | // dbConnection.Open(); | ||
67 | |||
68 | // IDbCommand command = dbConnection.CreateCommand(); | ||
69 | // command.CommandText = String.Format("SELECT assetID,assetType,inventoryName,inventoryDescription,inventoryNextPermissions," + | ||
70 | // "inventoryCurrentPermissions,invType,creatorID,inventoryBasePermissions,inventoryEveryOnePermissions,salePrice,saleType," + | ||
71 | // "creationDate,groupID,groupOwned,flags,avatarID,parentFolderID,inventoryGroupPermissions FROM inventoryitems WHERE inventoryID='{0}'", | ||
72 | // itemID.ToString()); | ||
73 | // reader = command.ExecuteReader(); | ||
74 | |||
75 | // if (reader.Read()) | ||
76 | // { | ||
77 | // item = new InventoryItemBase(); | ||
78 | // item.ID = itemID; | ||
79 | // item.AssetID = UUID.Parse(reader.GetString(0)); | ||
80 | // item.AssetType = reader.GetInt32(1); | ||
81 | // item.Name = reader.GetString(2); | ||
82 | // item.Description = reader.GetString(3); | ||
83 | // item.NextPermissions = (uint)reader.GetInt32(4); | ||
84 | // item.CurrentPermissions = (uint)reader.GetInt32(5); | ||
85 | // item.InvType = reader.GetInt32(6); | ||
86 | // item.Creator = UUID.Parse(reader.GetString(7)); | ||
87 | // item.BasePermissions = (uint)reader.GetInt32(8); | ||
88 | // item.EveryOnePermissions = (uint)reader.GetInt32(9); | ||
89 | // item.SalePrice = reader.GetInt32(10); | ||
90 | // item.SaleType = reader.GetByte(11); | ||
91 | // item.CreationDate = reader.GetInt32(12); | ||
92 | // item.GroupID = UUID.Parse(reader.GetString(13)); | ||
93 | // item.GroupOwned = reader.GetBoolean(14); | ||
94 | // item.Flags = (uint)reader.GetInt32(15); | ||
95 | // item.Owner = UUID.Parse(reader.GetString(16)); | ||
96 | // item.Folder = UUID.Parse(reader.GetString(17)); | ||
97 | // item.GroupPermissions = (uint)reader.GetInt32(18); | ||
98 | |||
99 | // ret = BackendResponse.Success; | ||
100 | // } | ||
101 | // else | ||
102 | // { | ||
103 | // ret = BackendResponse.NotFound; | ||
104 | // } | ||
105 | // } | ||
106 | // catch (MySqlException ex) | ||
107 | // { | ||
108 | // m_log.Error("[OPENSIMINVENTORYSTORAGE]: Connection to MySQL backend failed: " + ex.Message); | ||
109 | // ret = BackendResponse.Failure; | ||
110 | // } | ||
111 | //} | ||
112 | |||
113 | //m_server.MetricsProvider.LogInventoryFetch(EXTENSION_NAME, ret, owner, itemID, false, DateTime.Now); | ||
114 | //return ret; | ||
115 | m_log.Warn("[OPENSIMINVENTORYSTORAGE]: Called TryFetchItem which is not implemented."); | ||
116 | return BackendResponse.Success; | ||
117 | } | ||
118 | |||
119 | public BackendResponse TryFetchFolder(Uri owner, UUID folderID, out InventoryFolderWithChildren folder) | ||
120 | { | ||
121 | BackendResponse ret; | ||
122 | |||
123 | // TODO: implement some logic for "folder not found" | ||
124 | folder = m_inventoryService.GetInventoryFolder(folderID); | ||
125 | ret = BackendResponse.Success; | ||
126 | |||
127 | m_server.MetricsProvider.LogInventoryFetch(EXTENSION_NAME, ret, owner, folderID, true, DateTime.Now); | ||
128 | return ret; | ||
129 | } | ||
130 | |||
131 | public BackendResponse TryFetchFolderContents(Uri owner, UUID folderID, out InventoryCollection contents) | ||
132 | { | ||
133 | contents = null; | ||
134 | //BackendResponse ret; | ||
135 | |||
136 | //using (MySqlConnection dbConnection = new MySqlConnection(m_openSimConfig.GetString("inventory_database_connect"))) | ||
137 | //{ | ||
138 | // IDataReader reader; | ||
139 | |||
140 | // try | ||
141 | // { | ||
142 | // dbConnection.Open(); | ||
143 | |||
144 | // contents = new InventoryCollection(); | ||
145 | |||
146 | // #region Folder retrieval | ||
147 | |||
148 | // IDbCommand command = dbConnection.CreateCommand(); | ||
149 | // command.CommandText = String.Format("SELECT folderName,type,version,agentID,folderID FROM inventoryfolders WHERE parentFolderID='{0}'", | ||
150 | // folderID.ToString()); | ||
151 | // reader = command.ExecuteReader(); | ||
152 | |||
153 | // contents.Folders = new Dictionary<UUID, InventoryFolderWithChildren>(); | ||
154 | |||
155 | // while (reader.Read()) | ||
156 | // { | ||
157 | // InventoryFolderWithChildren folder = new InventoryFolderWithChildren(); | ||
158 | // folder.ParentID = folderID; | ||
159 | // folder.Children = null; // This call doesn't do recursion | ||
160 | // folder.Name = reader.GetString(0); | ||
161 | // folder.Type = reader.GetInt16(1); | ||
162 | // folder.Version = (ushort)reader.GetInt16(2); | ||
163 | // folder.Owner = UUID.Parse(reader.GetString(3)); | ||
164 | // folder.ID = UUID.Parse(reader.GetString(4)); | ||
165 | |||
166 | // contents.Folders.Add(folder.ID, folder); | ||
167 | // contents.UserID = folder.Owner; | ||
168 | // } | ||
169 | |||
170 | // reader.Close(); | ||
171 | |||
172 | // #endregion Folder retrieval | ||
173 | |||
174 | // #region Item retrieval | ||
175 | |||
176 | // command = dbConnection.CreateCommand(); | ||
177 | // command.CommandText = String.Format("SELECT assetID,assetType,inventoryName,inventoryDescription,inventoryNextPermissions," + | ||
178 | // "inventoryCurrentPermissions,invType,creatorID,inventoryBasePermissions,inventoryEveryOnePermissions,salePrice,saleType," + | ||
179 | // "creationDate,groupID,groupOwned,flags,avatarID,inventoryID,inventoryGroupPermissions FROM inventoryitems WHERE parentFolderID='{0}'", | ||
180 | // folderID.ToString()); | ||
181 | // reader = command.ExecuteReader(); | ||
182 | |||
183 | // contents.Items = new Dictionary<UUID, InventoryItemBase>(); | ||
184 | |||
185 | // while (reader.Read()) | ||
186 | // { | ||
187 | // InventoryItemBase item = new InventoryItemBase(); | ||
188 | // item.Folder = folderID; | ||
189 | // item.AssetID = UUID.Parse(reader.GetString(0)); | ||
190 | // item.AssetType = reader.GetInt32(1); | ||
191 | // item.Name = reader.GetString(2); | ||
192 | // item.Description = reader.GetString(3); | ||
193 | // item.NextPermissions = (uint)reader.GetInt32(4); | ||
194 | // item.CurrentPermissions = (uint)reader.GetInt32(5); | ||
195 | // item.InvType = reader.GetInt32(6); | ||
196 | // item.Creator = UUID.Parse(reader.GetString(7)); | ||
197 | // item.BasePermissions = (uint)reader.GetInt32(8); | ||
198 | // item.EveryOnePermissions = (uint)reader.GetInt32(9); | ||
199 | // item.SalePrice = reader.GetInt32(10); | ||
200 | // item.SaleType = reader.GetByte(11); | ||
201 | // item.CreationDate = reader.GetInt32(12); | ||
202 | // item.GroupID = UUID.Parse(reader.GetString(13)); | ||
203 | // item.GroupOwned = reader.GetBoolean(14); | ||
204 | // item.Flags = (uint)reader.GetInt32(15); | ||
205 | // item.Owner = UUID.Parse(reader.GetString(16)); | ||
206 | // item.ID = UUID.Parse(reader.GetString(17)); | ||
207 | // item.GroupPermissions = (uint)reader.GetInt32(18); | ||
208 | |||
209 | // contents.Items.Add(item.ID, item); | ||
210 | // contents.UserID = item.Owner; | ||
211 | // } | ||
212 | |||
213 | // #endregion Item retrieval | ||
214 | |||
215 | // ret = BackendResponse.Success; | ||
216 | // } | ||
217 | // catch (MySqlException ex) | ||
218 | // { | ||
219 | // m_log.Error("[OPENSIMINVENTORYSTORAGE]: Connection to MySQL backend failed: " + ex.Message); | ||
220 | // ret = BackendResponse.Failure; | ||
221 | // } | ||
222 | //} | ||
223 | |||
224 | //m_server.MetricsProvider.LogInventoryFetchFolderContents(EXTENSION_NAME, ret, owner, folderID, DateTime.Now); | ||
225 | //return ret; | ||
226 | m_log.Warn("[OPENSIMINVENTORYSTORAGE]: Called TryFetchFolderContents which is not implemented."); | ||
227 | return BackendResponse.Success; | ||
228 | } | ||
229 | |||
230 | public BackendResponse TryFetchFolderList(Uri owner, out List<InventoryFolderWithChildren> folders) | ||
231 | { | ||
232 | folders = new List<InventoryFolderWithChildren>(); | ||
233 | BackendResponse ret; | ||
234 | UUID ownerID; | ||
235 | |||
236 | if (Utils.TryGetOpenSimUUID(owner, out ownerID)) | ||
237 | { | ||
238 | List<InventoryFolderBase> baseFolders = m_inventoryService.GetInventorySkeleton(ownerID); | ||
239 | foreach (InventoryFolderBase baseFolder in baseFolders) | ||
240 | { | ||
241 | InventoryFolderWithChildren folder = new InventoryFolderWithChildren(baseFolder); | ||
242 | //folder.Children = null; // This call does not create a folder hierarchy | ||
243 | folders.Add(folder); | ||
244 | } | ||
245 | |||
246 | ret = BackendResponse.Success; | ||
247 | } | ||
248 | else | ||
249 | { | ||
250 | folders = null; | ||
251 | ret = BackendResponse.NotFound; | ||
252 | } | ||
253 | |||
254 | m_server.MetricsProvider.LogInventoryFetchFolderList(EXTENSION_NAME, ret, owner, DateTime.Now); | ||
255 | return ret; | ||
256 | } | ||
257 | |||
258 | public BackendResponse TryFetchInventory(Uri owner, out InventoryCollection inventory) | ||
259 | { | ||
260 | inventory = null; | ||
261 | BackendResponse ret; | ||
262 | List<InventoryFolderWithChildren> folders; | ||
263 | |||
264 | ret = TryFetchFolderList(owner, out folders); | ||
265 | |||
266 | if (ret == BackendResponse.Success) | ||
267 | { | ||
268 | // Add the retrieved folders to the inventory collection | ||
269 | inventory = new InventoryCollection(); | ||
270 | inventory.Folders = new Dictionary<UUID, InventoryFolderWithChildren>(folders.Count); | ||
271 | foreach (InventoryFolderWithChildren folder in folders) | ||
272 | inventory.Folders[folder.ID] = folder; | ||
273 | |||
274 | // Fetch inventory items | ||
275 | UUID ownerID; | ||
276 | if (Utils.TryGetOpenSimUUID(owner, out ownerID)) | ||
277 | { | ||
278 | inventory.UserID = ownerID; | ||
279 | inventory.Items = new Dictionary<UUID, InventoryItemBase>(); | ||
280 | |||
281 | foreach (InventoryFolderWithChildren folder in folders) | ||
282 | { | ||
283 | foreach (InventoryItemBase item in m_inventoryService.RequestFolderItems(folder.ID)) | ||
284 | { | ||
285 | inventory.Items.Add(item.ID, item); | ||
286 | } | ||
287 | } | ||
288 | |||
289 | ret = BackendResponse.Success; | ||
290 | |||
291 | } | ||
292 | else | ||
293 | { | ||
294 | ret = BackendResponse.NotFound; | ||
295 | } | ||
296 | } | ||
297 | |||
298 | m_server.MetricsProvider.LogInventoryFetchInventory(EXTENSION_NAME, ret, owner, DateTime.Now); | ||
299 | return ret; | ||
300 | } | ||
301 | |||
302 | public BackendResponse TryFetchActiveGestures(Uri owner, out List<InventoryItemBase> gestures) | ||
303 | { | ||
304 | gestures = null; | ||
305 | BackendResponse ret; | ||
306 | UUID ownerID; | ||
307 | |||
308 | if (Utils.TryGetOpenSimUUID(owner, out ownerID)) | ||
309 | { | ||
310 | gestures = m_inventoryService.GetActiveGestures(ownerID); | ||
311 | ret = BackendResponse.Success; | ||
312 | } | ||
313 | else | ||
314 | { | ||
315 | ret = BackendResponse.NotFound; | ||
316 | } | ||
317 | |||
318 | m_server.MetricsProvider.LogInventoryFetchActiveGestures(EXTENSION_NAME, ret, owner, DateTime.Now); | ||
319 | return ret; | ||
320 | } | ||
321 | |||
322 | public BackendResponse TryCreateItem(Uri owner, InventoryItemBase item) | ||
323 | { | ||
324 | BackendResponse ret; | ||
325 | |||
326 | if (m_inventoryService.AddItem(item)) | ||
327 | { | ||
328 | ret = BackendResponse.Success; | ||
329 | } | ||
330 | else | ||
331 | { | ||
332 | ret = BackendResponse.Failure; | ||
333 | } | ||
334 | |||
335 | m_server.MetricsProvider.LogInventoryCreate(EXTENSION_NAME, ret, owner, false, DateTime.Now); | ||
336 | return ret; | ||
337 | } | ||
338 | |||
339 | public BackendResponse TryCreateFolder(Uri owner, InventoryFolderWithChildren folder) | ||
340 | { | ||
341 | BackendResponse ret; | ||
342 | |||
343 | if (m_inventoryService.AddFolder(folder)) | ||
344 | { | ||
345 | ret = BackendResponse.Success; | ||
346 | } | ||
347 | else | ||
348 | { | ||
349 | ret = BackendResponse.Failure; | ||
350 | } | ||
351 | |||
352 | m_server.MetricsProvider.LogInventoryCreate(EXTENSION_NAME, ret, owner, true, DateTime.Now); | ||
353 | return ret; | ||
354 | } | ||
355 | |||
356 | public BackendResponse TryCreateInventory(Uri owner, InventoryFolderWithChildren rootFolder) | ||
357 | { | ||
358 | BackendResponse ret; | ||
359 | UUID ownerID; | ||
360 | |||
361 | if (Utils.TryGetOpenSimUUID(owner, out ownerID)) | ||
362 | { | ||
363 | if (m_inventoryService.CreateNewUserInventory(ownerID)) | ||
364 | { | ||
365 | ret = BackendResponse.Success; | ||
366 | } | ||
367 | else | ||
368 | { | ||
369 | ret = BackendResponse.Failure; | ||
370 | } | ||
371 | } | ||
372 | else | ||
373 | { | ||
374 | ret = BackendResponse.Failure; | ||
375 | } | ||
376 | |||
377 | return ret; | ||
378 | } | ||
379 | |||
380 | public BackendResponse TryDeleteItem(Uri owner, UUID itemID) | ||
381 | { | ||
382 | BackendResponse ret; | ||
383 | |||
384 | if (m_inventoryService.DeleteItem(m_inventoryService.GetInventoryItem(itemID))) | ||
385 | { | ||
386 | ret = BackendResponse.Success; | ||
387 | } | ||
388 | else | ||
389 | { | ||
390 | ret = BackendResponse.Failure; | ||
391 | } | ||
392 | |||
393 | m_server.MetricsProvider.LogInventoryDelete(EXTENSION_NAME, ret, owner, itemID, false, DateTime.Now); | ||
394 | return ret; | ||
395 | } | ||
396 | |||
397 | public BackendResponse TryDeleteFolder(Uri owner, UUID folderID) | ||
398 | { | ||
399 | //BackendResponse ret; | ||
400 | //UUID ownerID; | ||
401 | |||
402 | //if (Utils.TryGetOpenSimUUID(owner, out ownerID)) | ||
403 | //{ | ||
404 | // using (MySqlConnection dbConnection = new MySqlConnection(m_openSimConfig.GetString("inventory_database_connect"))) | ||
405 | // { | ||
406 | // try | ||
407 | // { | ||
408 | // dbConnection.Open(); | ||
409 | |||
410 | // MySqlCommand command = new MySqlCommand( | ||
411 | // "DELETE FROM inventoryfolders WHERE folderID=?folderID AND agentID=?agentID", dbConnection); | ||
412 | |||
413 | // command.Parameters.AddWithValue("?folderID", folderID.ToString()); | ||
414 | // command.Parameters.AddWithValue("?agentID", ownerID.ToString()); | ||
415 | |||
416 | // int rowsAffected = command.ExecuteNonQuery(); | ||
417 | // if (rowsAffected == 1) | ||
418 | // { | ||
419 | // ret = BackendResponse.Success; | ||
420 | // } | ||
421 | // else | ||
422 | // { | ||
423 | // m_log.ErrorFormat("[OPENSIMINVENTORYSTORAGE]: MySQL DELETE query affected {0} rows", rowsAffected); | ||
424 | // ret = BackendResponse.NotFound; | ||
425 | // } | ||
426 | // } | ||
427 | // catch (MySqlException ex) | ||
428 | // { | ||
429 | // m_log.Error("[OPENSIMINVENTORYSTORAGE]: Connection to MySQL backend failed: " + ex.Message); | ||
430 | // ret = BackendResponse.Failure; | ||
431 | // } | ||
432 | // } | ||
433 | //} | ||
434 | //else | ||
435 | //{ | ||
436 | // ret = BackendResponse.NotFound; | ||
437 | //} | ||
438 | |||
439 | //m_server.MetricsProvider.LogInventoryDelete(EXTENSION_NAME, ret, owner, folderID, true, DateTime.Now); | ||
440 | //return ret; | ||
441 | m_log.Warn("[OPENSIMINVENTORYSTORAGE]: Called TryDeleteFolder which is not implemented."); | ||
442 | return BackendResponse.Success; | ||
443 | } | ||
444 | |||
445 | public BackendResponse TryPurgeFolder(Uri owner, UUID folderID) | ||
446 | { | ||
447 | BackendResponse ret; | ||
448 | |||
449 | if (m_inventoryService.PurgeFolder(m_inventoryService.GetInventoryFolder(folderID))) | ||
450 | { | ||
451 | ret = BackendResponse.Success; | ||
452 | } | ||
453 | else | ||
454 | { | ||
455 | ret = BackendResponse.Failure; | ||
456 | } | ||
457 | |||
458 | m_server.MetricsProvider.LogInventoryPurgeFolder(EXTENSION_NAME, ret, owner, folderID, DateTime.Now); | ||
459 | return ret; | ||
460 | } | ||
461 | |||
462 | public int ForEach(Action<AssetMetadata> action, int start, int count) | ||
463 | { | ||
464 | int rowCount = 0; | ||
465 | |||
466 | //using (MySqlConnection dbConnection = new MySqlConnection(m_openSimConfig.GetString("inventory_database_connect"))) | ||
467 | //{ | ||
468 | // MySqlDataReader reader; | ||
469 | |||
470 | // try | ||
471 | // { | ||
472 | // dbConnection.Open(); | ||
473 | |||
474 | // MySqlCommand command = dbConnection.CreateCommand(); | ||
475 | // command.CommandText = String.Format("SELECT name,description,assetType,temporary,data,id FROM assets LIMIT {0}, {1}", | ||
476 | // start, count); | ||
477 | // reader = command.ExecuteReader(); | ||
478 | // } | ||
479 | // catch (MySqlException ex) | ||
480 | // { | ||
481 | // m_log.Error("[OPENSIMINVENTORYSTORAGE]: Connection to MySQL backend failed: " + ex.Message); | ||
482 | // return 0; | ||
483 | // } | ||
484 | |||
485 | // while (reader.Read()) | ||
486 | // { | ||
487 | // Metadata metadata = new Metadata(); | ||
488 | // metadata.CreationDate = OpenMetaverse.Utils.Epoch; | ||
489 | // metadata.Description = reader.GetString(1); | ||
490 | // metadata.ID = UUID.Parse(reader.GetString(5)); | ||
491 | // metadata.Name = reader.GetString(0); | ||
492 | // metadata.SHA1 = OpenMetaverse.Utils.SHA1((byte[])reader.GetValue(4)); | ||
493 | // metadata.Temporary = reader.GetBoolean(3); | ||
494 | // metadata.ContentType = Utils.SLAssetTypeToContentType(reader.GetInt32(2)); | ||
495 | |||
496 | // action(metadata); | ||
497 | // ++rowCount; | ||
498 | // } | ||
499 | |||
500 | // reader.Close(); | ||
501 | //} | ||
502 | |||
503 | return rowCount; | ||
504 | } | ||
505 | |||
506 | #endregion IInventoryStorageProvider implementation | ||
507 | |||
508 | #region IPlugin implementation | ||
509 | |||
510 | public void Initialise(AssetInventoryServer server) | ||
511 | { | ||
512 | m_server = server; | ||
513 | m_openSimConfig = server.ConfigFile.Configs["OpenSim"]; | ||
514 | |||
515 | m_inventoryService = new OpenSimInventoryService(); | ||
516 | m_inventoryService.AddPlugin(m_openSimConfig.GetString("inventory_database_provider"), | ||
517 | m_openSimConfig.GetString("inventory_database_connect")); | ||
518 | } | ||
519 | |||
520 | public void Stop() | ||
521 | { | ||
522 | } | ||
523 | |||
524 | public void Initialise() | ||
525 | { | ||
526 | m_log.InfoFormat("[OPENSIMINVENTORYSTORAGE]: {0} cannot be default-initialized!", Name); | ||
527 | throw new PluginNotInitialisedException(Name); | ||
528 | } | ||
529 | |||
530 | public void Dispose() | ||
531 | { | ||
532 | } | ||
533 | |||
534 | public string Version | ||
535 | { | ||
536 | // TODO: this should be something meaningful and not hardcoded? | ||
537 | get { return "0.1"; } | ||
538 | } | ||
539 | |||
540 | public string Name | ||
541 | { | ||
542 | get { return "OpenSimInventoryStorage"; } | ||
543 | } | ||
544 | |||
545 | #endregion IPlugin implementation | ||
546 | } | ||
547 | } | ||
diff --git a/OpenSim/Grid/AssetInventoryServer/Plugins/OpenSim/Resources/AssetInventoryServerOpenSimPlugins.addin.xml b/OpenSim/Grid/AssetInventoryServer/Plugins/OpenSim/Resources/AssetInventoryServerOpenSimPlugins.addin.xml deleted file mode 100644 index 8cd7585..0000000 --- a/OpenSim/Grid/AssetInventoryServer/Plugins/OpenSim/Resources/AssetInventoryServerOpenSimPlugins.addin.xml +++ /dev/null | |||
@@ -1,27 +0,0 @@ | |||
1 | <Addin id="OpenSim.Grid.AssetInventoryServer.Plugins.OpenSim" version="0.1"> | ||
2 | <Runtime> | ||
3 | <Import assembly="OpenSim.Grid.AssetInventoryServer.Plugins.OpenSim.dll" /> | ||
4 | <Import assembly="OpenSim.Data.dll" /> | ||
5 | </Runtime> | ||
6 | |||
7 | <Dependencies> | ||
8 | <Addin id="OpenSim.Grid.AssetInventoryServer" version="0.1" /> | ||
9 | </Dependencies> | ||
10 | |||
11 | <ExtensionPoint path = "/OpenSim/AssetData"> | ||
12 | <ExtensionNode name="Plugin" type="OpenSim.Framework.PluginExtensionNode" objectType="OpenSim.Data.IAssetDataPlugin" /> | ||
13 | </ExtensionPoint> | ||
14 | |||
15 | <Extension path="/OpenSim/AssetInventoryServer/AssetStorageProvider"> | ||
16 | <Plugin id="OpenSimAssetStorage" provider="OpenSim.Grid.AssetInventoryServer.Plugins.OpenSim.dll" type="OpenSim.Grid.AssetInventoryServer.Plugins.OpenSim.OpenSimAssetStoragePlugin" /> | ||
17 | </Extension> | ||
18 | <Extension path="/OpenSim/AssetInventoryServer/InventoryStorageProvider"> | ||
19 | <Plugin id="OpenSimInventoryStorage" provider="OpenSim.Grid.AssetInventoryServer.Plugins.OpenSim.dll" type="OpenSim.Grid.AssetInventoryServer.Plugins.OpenSim.OpenSimInventoryStoragePlugin" /> | ||
20 | </Extension> | ||
21 | <Extension path="/OpenSim/AssetInventoryServer/Frontend"> | ||
22 | <Plugin id="OpenSimAssetFrontend" provider="OpenSim.Grid.AssetInventoryServer.Plugins.OpenSim.dll" type="OpenSim.Grid.AssetInventoryServer.Plugins.OpenSim.OpenSimAssetFrontendPlugin" /> | ||
23 | </Extension> | ||
24 | <Extension path="/OpenSim/AssetInventoryServer/Frontend"> | ||
25 | <Plugin id="OpenSimInventoryFrontend" provider="OpenSim.Grid.AssetInventoryServer.Plugins.OpenSim.dll" type="OpenSim.Grid.AssetInventoryServer.Plugins.OpenSim.OpenSimInventoryFrontendPlugin" /> | ||
26 | </Extension> | ||
27 | </Addin> | ||
diff --git a/OpenSim/Grid/AssetInventoryServer/Plugins/ReferenceFrontendPlugin.cs b/OpenSim/Grid/AssetInventoryServer/Plugins/ReferenceFrontendPlugin.cs deleted file mode 100644 index b5ad1a1..0000000 --- a/OpenSim/Grid/AssetInventoryServer/Plugins/ReferenceFrontendPlugin.cs +++ /dev/null | |||
@@ -1,369 +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.Net; | ||
32 | using OpenMetaverse; | ||
33 | using OpenMetaverse.StructuredData; | ||
34 | using OpenSim.Framework; | ||
35 | using OpenSim.Framework.Servers; | ||
36 | using OpenSim.Framework.Servers.HttpServer; | ||
37 | using log4net; | ||
38 | |||
39 | namespace OpenSim.Grid.AssetInventoryServer.Plugins | ||
40 | { | ||
41 | public class ReferenceFrontendPlugin : IAssetInventoryServerPlugin | ||
42 | { | ||
43 | private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); | ||
44 | AssetInventoryServer m_server; | ||
45 | |||
46 | public ReferenceFrontendPlugin() | ||
47 | { | ||
48 | } | ||
49 | |||
50 | #region IPlugin implementation | ||
51 | |||
52 | public void Initialise(AssetInventoryServer server) | ||
53 | { | ||
54 | m_server = server; | ||
55 | |||
56 | // Asset metadata request | ||
57 | //m_server.HttpServer.AddStreamHandler(new MetadataRequestHandler(server)); | ||
58 | |||
59 | // Asset data request | ||
60 | m_server.HttpServer.AddStreamHandler(new DataRequestHandler(server)); | ||
61 | |||
62 | // Asset creation | ||
63 | //m_server.HttpServer.AddStreamHandler(new CreateRequestHandler(server)); | ||
64 | |||
65 | m_log.Info("[REFERENCEFRONTEND]: Reference Frontend loaded."); | ||
66 | } | ||
67 | |||
68 | /// <summary> | ||
69 | /// <para>Initialises asset interface</para> | ||
70 | /// </summary> | ||
71 | public void Initialise() | ||
72 | { | ||
73 | m_log.InfoFormat("[REFERENCEFRONTEND]: {0} cannot be default-initialized!", Name); | ||
74 | throw new PluginNotInitialisedException(Name); | ||
75 | } | ||
76 | |||
77 | public void Dispose() | ||
78 | { | ||
79 | } | ||
80 | |||
81 | public string Version | ||
82 | { | ||
83 | // TODO: this should be something meaningful and not hardcoded? | ||
84 | get { return "0.1"; } | ||
85 | } | ||
86 | |||
87 | public string Name | ||
88 | { | ||
89 | get { return "ReferenceFrontend"; } | ||
90 | } | ||
91 | |||
92 | #endregion IPlugin implementation | ||
93 | |||
94 | //public class MetadataRequestHandler : IStreamedRequestHandler | ||
95 | //{ | ||
96 | // AssetInventoryServer m_server; | ||
97 | // string m_contentType; | ||
98 | // string m_httpMethod; | ||
99 | // string m_path; | ||
100 | |||
101 | // public MetadataRequestHandler(AssetInventoryServer server) | ||
102 | // { | ||
103 | // m_server = server; | ||
104 | // m_contentType = null; | ||
105 | // m_httpMethod = "GET"; | ||
106 | // m_path = @"^/[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}/metadata"; | ||
107 | // } | ||
108 | |||
109 | // #region IStreamedRequestHandler implementation | ||
110 | |||
111 | // public string ContentType | ||
112 | // { | ||
113 | // get { return m_contentType; } | ||
114 | // } | ||
115 | |||
116 | // public string HttpMethod | ||
117 | // { | ||
118 | // get { return m_httpMethod; } | ||
119 | // } | ||
120 | |||
121 | // public string Path | ||
122 | // { | ||
123 | // get { return m_path; } | ||
124 | // } | ||
125 | |||
126 | // public byte[] Handle(string path, Stream request, OSHttpRequest httpRequest, OSHttpResponse httpResponse) | ||
127 | // { | ||
128 | // byte[] serializedData = null; | ||
129 | // UUID assetID; | ||
130 | // // Split the URL up into an AssetID and a method | ||
131 | // string[] rawUrl = httpRequest.Url.PathAndQuery.Split('/'); | ||
132 | |||
133 | // if (rawUrl.Length >= 3 && UUID.TryParse(rawUrl[1], out assetID)) | ||
134 | // { | ||
135 | // UUID authToken = Utils.GetAuthToken(httpRequest); | ||
136 | |||
137 | // if (m_server.AuthorizationProvider.IsMetadataAuthorized(authToken, assetID)) | ||
138 | // { | ||
139 | // AssetMetadata metadata; | ||
140 | // BackendResponse storageResponse = m_server.StorageProvider.TryFetchMetadata(assetID, out metadata); | ||
141 | |||
142 | // if (storageResponse == BackendResponse.Success) | ||
143 | // { | ||
144 | // // If the asset data location wasn't specified in the metadata, specify it | ||
145 | // // manually here by pointing back to this asset server | ||
146 | // if (!metadata.Methods.ContainsKey("data")) | ||
147 | // { | ||
148 | // metadata.Methods["data"] = new Uri(String.Format("{0}://{1}/{2}/data", | ||
149 | // httpRequest.Url.Scheme, httpRequest.Url.Authority, assetID)); | ||
150 | // } | ||
151 | |||
152 | // serializedData = metadata.SerializeToBytes(); | ||
153 | |||
154 | // httpResponse.StatusCode = (int) HttpStatusCode.OK; | ||
155 | // httpResponse.ContentType = "application/json"; | ||
156 | // httpResponse.ContentLength = serializedData.Length; | ||
157 | // httpResponse.Body.Write(serializedData, 0, serializedData.Length); | ||
158 | // } | ||
159 | // else if (storageResponse == BackendResponse.NotFound) | ||
160 | // { | ||
161 | // m_log.Warn("[REFERENCEFRONTEND]: Could not find metadata for asset " + assetID.ToString()); | ||
162 | // httpResponse.StatusCode = (int) HttpStatusCode.NotFound; | ||
163 | // } | ||
164 | // else | ||
165 | // { | ||
166 | // httpResponse.StatusCode = (int) HttpStatusCode.InternalServerError; | ||
167 | // } | ||
168 | // } | ||
169 | // else | ||
170 | // { | ||
171 | // httpResponse.StatusCode = (int) HttpStatusCode.Forbidden; | ||
172 | // } | ||
173 | |||
174 | // return serializedData; | ||
175 | // } | ||
176 | |||
177 | // httpResponse.StatusCode = (int) HttpStatusCode.NotFound; | ||
178 | // return serializedData; | ||
179 | // } | ||
180 | |||
181 | // #endregion IStreamedRequestHandler implementation | ||
182 | //} | ||
183 | |||
184 | public class DataRequestHandler : IStreamedRequestHandler | ||
185 | { | ||
186 | AssetInventoryServer m_server; | ||
187 | string m_contentType; | ||
188 | string m_httpMethod; | ||
189 | string m_path; | ||
190 | |||
191 | public DataRequestHandler(AssetInventoryServer server) | ||
192 | { | ||
193 | m_server = server; | ||
194 | m_contentType = null; | ||
195 | m_httpMethod = "GET"; | ||
196 | m_path = @"^/[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}/data"; | ||
197 | } | ||
198 | |||
199 | #region IStreamedRequestHandler implementation | ||
200 | |||
201 | public string ContentType | ||
202 | { | ||
203 | get { return m_contentType; } | ||
204 | } | ||
205 | |||
206 | public string HttpMethod | ||
207 | { | ||
208 | get { return m_httpMethod; } | ||
209 | } | ||
210 | |||
211 | public string Path | ||
212 | { | ||
213 | get { return m_path; } | ||
214 | } | ||
215 | |||
216 | public byte[] Handle(string path, Stream request, OSHttpRequest httpRequest, OSHttpResponse httpResponse) | ||
217 | { | ||
218 | byte[] assetData = null; | ||
219 | UUID assetID; | ||
220 | // Split the URL up into an AssetID and a method | ||
221 | string[] rawUrl = httpRequest.Url.PathAndQuery.Split('/'); | ||
222 | |||
223 | if (rawUrl.Length >= 3 && UUID.TryParse(rawUrl[1], out assetID)) | ||
224 | { | ||
225 | UUID authToken = Utils.GetAuthToken(httpRequest); | ||
226 | |||
227 | if (m_server.AuthorizationProvider.IsDataAuthorized(authToken, assetID)) | ||
228 | { | ||
229 | BackendResponse storageResponse = m_server.StorageProvider.TryFetchData(assetID, out assetData); | ||
230 | |||
231 | if (storageResponse == BackendResponse.Success) | ||
232 | { | ||
233 | httpResponse.StatusCode = (int) HttpStatusCode.OK; | ||
234 | httpResponse.ContentType = "application/octet-stream"; | ||
235 | httpResponse.AddHeader("Content-Disposition", "attachment; filename=" + assetID.ToString()); | ||
236 | httpResponse.ContentLength = assetData.Length; | ||
237 | httpResponse.Body.Write(assetData, 0, assetData.Length); | ||
238 | } | ||
239 | else if (storageResponse == BackendResponse.NotFound) | ||
240 | { | ||
241 | httpResponse.StatusCode = (int) HttpStatusCode.NotFound; | ||
242 | } | ||
243 | else | ||
244 | { | ||
245 | httpResponse.StatusCode = (int) HttpStatusCode.InternalServerError; | ||
246 | } | ||
247 | } | ||
248 | else | ||
249 | { | ||
250 | httpResponse.StatusCode = (int) HttpStatusCode.Forbidden; | ||
251 | } | ||
252 | |||
253 | return assetData; | ||
254 | } | ||
255 | |||
256 | httpResponse.StatusCode = (int) HttpStatusCode.BadRequest; | ||
257 | return assetData; | ||
258 | } | ||
259 | |||
260 | #endregion IStreamedRequestHandler implementation | ||
261 | } | ||
262 | |||
263 | //public class CreateRequestHandler : IStreamedRequestHandler | ||
264 | //{ | ||
265 | // AssetInventoryServer m_server; | ||
266 | // string m_contentType; | ||
267 | // string m_httpMethod; | ||
268 | // string m_path; | ||
269 | |||
270 | // public CreateRequestHandler(AssetInventoryServer server) | ||
271 | // { | ||
272 | // m_server = server; | ||
273 | // m_contentType = null; | ||
274 | // m_httpMethod = "POST"; | ||
275 | // m_path = "^/createasset"; | ||
276 | // } | ||
277 | |||
278 | // #region IStreamedRequestHandler implementation | ||
279 | |||
280 | // public string ContentType | ||
281 | // { | ||
282 | // get { return m_contentType; } | ||
283 | // } | ||
284 | |||
285 | // public string HttpMethod | ||
286 | // { | ||
287 | // get { return m_httpMethod; } | ||
288 | // } | ||
289 | |||
290 | // public string Path | ||
291 | // { | ||
292 | // get { return m_path; } | ||
293 | // } | ||
294 | |||
295 | // public byte[] Handle(string path, Stream request, OSHttpRequest httpRequest, OSHttpResponse httpResponse) | ||
296 | // { | ||
297 | // byte[] responseData = null; | ||
298 | // UUID authToken = Utils.GetAuthToken(httpRequest); | ||
299 | |||
300 | // if (m_server.AuthorizationProvider.IsCreateAuthorized(authToken)) | ||
301 | // { | ||
302 | // try | ||
303 | // { | ||
304 | // OSD osdata = OSDParser.DeserializeJson(new StreamReader(httpRequest.InputStream).ReadToEnd()); | ||
305 | |||
306 | // if (osdata.Type == OSDType.Map) | ||
307 | // { | ||
308 | // OSDMap map = (OSDMap)osdata; | ||
309 | // Metadata metadata = new Metadata(); | ||
310 | // metadata.Deserialize(map); | ||
311 | |||
312 | // byte[] assetData = map["data"].AsBinary(); | ||
313 | |||
314 | // if (assetData != null && assetData.Length > 0) | ||
315 | // { | ||
316 | // BackendResponse storageResponse; | ||
317 | |||
318 | // if (metadata.ID != UUID.Zero) | ||
319 | // storageResponse = m_server.StorageProvider.TryCreateAsset(metadata, assetData); | ||
320 | // else | ||
321 | // storageResponse = m_server.StorageProvider.TryCreateAsset(metadata, assetData, out metadata.ID); | ||
322 | |||
323 | // if (storageResponse == BackendResponse.Success) | ||
324 | // { | ||
325 | // httpResponse.StatusCode = (int) HttpStatusCode.Created; | ||
326 | // OSDMap responseMap = new OSDMap(1); | ||
327 | // responseMap["id"] = OSD.FromUUID(metadata.ID); | ||
328 | // LitJson.JsonData jsonData = OSDParser.SerializeJson(responseMap); | ||
329 | // responseData = System.Text.Encoding.UTF8.GetBytes(jsonData.ToJson()); | ||
330 | // httpResponse.Body.Write(responseData, 0, responseData.Length); | ||
331 | // httpResponse.Body.Flush(); | ||
332 | // } | ||
333 | // else if (storageResponse == BackendResponse.NotFound) | ||
334 | // { | ||
335 | // httpResponse.StatusCode = (int) HttpStatusCode.NotFound; | ||
336 | // } | ||
337 | // else | ||
338 | // { | ||
339 | // httpResponse.StatusCode = (int) HttpStatusCode.InternalServerError; | ||
340 | // } | ||
341 | // } | ||
342 | // else | ||
343 | // { | ||
344 | // httpResponse.StatusCode = (int) HttpStatusCode.BadRequest; | ||
345 | // } | ||
346 | // } | ||
347 | // else | ||
348 | // { | ||
349 | // httpResponse.StatusCode = (int) HttpStatusCode.BadRequest; | ||
350 | // } | ||
351 | // } | ||
352 | // catch (Exception ex) | ||
353 | // { | ||
354 | // httpResponse.StatusCode = (int) HttpStatusCode.InternalServerError; | ||
355 | // httpResponse.StatusDescription = ex.Message; | ||
356 | // } | ||
357 | // } | ||
358 | // else | ||
359 | // { | ||
360 | // httpResponse.StatusCode = (int) HttpStatusCode.Forbidden; | ||
361 | // } | ||
362 | |||
363 | // return responseData; | ||
364 | // } | ||
365 | |||
366 | // #endregion IStreamedRequestHandler implementation | ||
367 | //} | ||
368 | } | ||
369 | } | ||
diff --git a/OpenSim/Grid/AssetInventoryServer/Plugins/Resources/AssetInventoryServerPlugins.addin.xml b/OpenSim/Grid/AssetInventoryServer/Plugins/Resources/AssetInventoryServerPlugins.addin.xml deleted file mode 100644 index 42a279d..0000000 --- a/OpenSim/Grid/AssetInventoryServer/Plugins/Resources/AssetInventoryServerPlugins.addin.xml +++ /dev/null | |||
@@ -1,28 +0,0 @@ | |||
1 | <Addin id="OpenSim.Grid.AssetInventoryServer.Plugins" version="0.1"> | ||
2 | <Runtime> | ||
3 | <Import assembly="OpenSim.Grid.AssetInventoryServer.Plugins.dll" /> | ||
4 | </Runtime> | ||
5 | |||
6 | <Dependencies> | ||
7 | <Addin id="OpenSim.Grid.AssetInventoryServer" version="0.1" /> | ||
8 | </Dependencies> | ||
9 | |||
10 | <Extension path="/OpenSim/AssetInventoryServer/MetricsProvider"> | ||
11 | <Plugin id="NullMetrics" provider="OpenSim.Grid.AssetInventoryServer.Plugins.dll" type="OpenSim.Grid.AssetInventoryServer.Plugins.NullMetricsPlugin" /> | ||
12 | </Extension> | ||
13 | <Extension path="/OpenSim/AssetInventoryServer/Frontend"> | ||
14 | <Plugin id="BrowseFrontend" provider="OpenSim.Grid.AssetInventoryServer.Plugins.dll" type="OpenSim.Grid.AssetInventoryServer.Plugins.BrowseFrontendPlugin" /> | ||
15 | </Extension> | ||
16 | <Extension path="/OpenSim/AssetInventoryServer/Frontend"> | ||
17 | <Plugin id="ReferenceFrontend" provider="OpenSim.Grid.AssetInventoryServer.Plugins.dll" type="OpenSim.Grid.AssetInventoryServer.Plugins.ReferenceFrontendPlugin" /> | ||
18 | </Extension> | ||
19 | <Extension path="/OpenSim/AssetInventoryServer/AuthenticationProvider"> | ||
20 | <Plugin id="NullAuthentication" provider="OpenSim.Grid.AssetInventoryServer.Plugins.dll" type="OpenSim.Grid.AssetInventoryServer.Plugins.NullAuthenticationPlugin" /> | ||
21 | </Extension> | ||
22 | <Extension path="/OpenSim/AssetInventoryServer/AuthorizationProvider"> | ||
23 | <Plugin id="AuthorizeAll" provider="OpenSim.Grid.AssetInventoryServer.Plugins.dll" type="OpenSim.Grid.AssetInventoryServer.Plugins.AuthorizeAllPlugin" /> | ||
24 | </Extension> | ||
25 | <Extension path="/OpenSim/AssetInventoryServer/Frontend"> | ||
26 | <Plugin id="InventoryArchive" provider="OpenSim.Grid.AssetInventoryServer.Plugins.dll" type="OpenSim.Grid.AssetInventoryServer.Plugins.InventoryArchivePlugin" /> | ||
27 | </Extension> | ||
28 | </Addin> | ||
diff --git a/OpenSim/Grid/AssetInventoryServer/Plugins/Simple/Resources/AssetInventoryServerSimplePlugins.addin.xml b/OpenSim/Grid/AssetInventoryServer/Plugins/Simple/Resources/AssetInventoryServerSimplePlugins.addin.xml deleted file mode 100644 index cb6959e..0000000 --- a/OpenSim/Grid/AssetInventoryServer/Plugins/Simple/Resources/AssetInventoryServerSimplePlugins.addin.xml +++ /dev/null | |||
@@ -1,16 +0,0 @@ | |||
1 | <Addin id="OpenSim.Grid.AssetInventoryServer.Plugins.Simple" version="0.1"> | ||
2 | <Runtime> | ||
3 | <Import assembly="OpenSim.Grid.AssetInventoryServer.Plugins.Simple.dll" /> | ||
4 | </Runtime> | ||
5 | |||
6 | <Dependencies> | ||
7 | <Addin id="OpenSim.Grid.AssetInventoryServer" version="0.1" /> | ||
8 | </Dependencies> | ||
9 | |||
10 | <Extension path="/OpenSim/AssetInventoryServer/AssetStorageProvider"> | ||
11 | <Plugin id="SimpleAssetStorage" provider="OpenSim.Grid.AssetInventoryServer.Plugins.Simple.dll" type="OpenSim.Grid.AssetInventoryServer.Plugins.Simple.SimpleAssetStoragePlugin" /> | ||
12 | </Extension> | ||
13 | <Extension path="/OpenSim/AssetInventoryServer/InventoryStorageProvider"> | ||
14 | <Plugin id="SimpleInventoryStorage" provider="OpenSim.Grid.AssetInventoryServer.Plugins.Simple.dll" type="OpenSim.Grid.AssetInventoryServer.Plugins.Simple.SimpleInventoryStoragePlugin" /> | ||
15 | </Extension> | ||
16 | </Addin> | ||
diff --git a/OpenSim/Grid/AssetInventoryServer/Plugins/Simple/SimpleAssetStoragePlugin.cs b/OpenSim/Grid/AssetInventoryServer/Plugins/Simple/SimpleAssetStoragePlugin.cs deleted file mode 100644 index 4ec2d96..0000000 --- a/OpenSim/Grid/AssetInventoryServer/Plugins/Simple/SimpleAssetStoragePlugin.cs +++ /dev/null | |||
@@ -1,290 +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.Reflection; | ||
30 | using System.Collections.Generic; | ||
31 | using System.IO; | ||
32 | using OpenMetaverse; | ||
33 | using OpenSim.Framework; | ||
34 | using log4net; | ||
35 | |||
36 | namespace OpenSim.Grid.AssetInventoryServer.Plugins.Simple | ||
37 | { | ||
38 | public class SimpleAssetStoragePlugin : IAssetStorageProvider | ||
39 | { | ||
40 | const string EXTENSION_NAME = "SimpleAssetStorage"; // Used in metrics reporting | ||
41 | const string DEFAULT_DATA_DIR = "SimpleAssets"; | ||
42 | const string TEMP_DATA_DIR = "SimpleAssetsTemp"; | ||
43 | |||
44 | private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); | ||
45 | AssetInventoryServer server; | ||
46 | Dictionary<UUID, AssetMetadata> metadataStorage; | ||
47 | Dictionary<UUID, string> filenames; | ||
48 | |||
49 | public SimpleAssetStoragePlugin() | ||
50 | { | ||
51 | } | ||
52 | |||
53 | #region Required Interfaces | ||
54 | |||
55 | public BackendResponse TryFetchMetadata(UUID assetID, out AssetMetadata metadata) | ||
56 | { | ||
57 | metadata = null; | ||
58 | BackendResponse ret; | ||
59 | |||
60 | if (metadataStorage.TryGetValue(assetID, out metadata)) | ||
61 | ret = BackendResponse.Success; | ||
62 | else | ||
63 | ret = BackendResponse.NotFound; | ||
64 | |||
65 | server.MetricsProvider.LogAssetMetadataFetch(EXTENSION_NAME, ret, assetID, DateTime.Now); | ||
66 | return ret; | ||
67 | } | ||
68 | |||
69 | public BackendResponse TryFetchData(UUID assetID, out byte[] assetData) | ||
70 | { | ||
71 | assetData = null; | ||
72 | string filename; | ||
73 | BackendResponse ret; | ||
74 | |||
75 | if (filenames.TryGetValue(assetID, out filename)) | ||
76 | { | ||
77 | try | ||
78 | { | ||
79 | assetData = File.ReadAllBytes(filename); | ||
80 | ret = BackendResponse.Success; | ||
81 | } | ||
82 | catch (Exception ex) | ||
83 | { | ||
84 | m_log.ErrorFormat("[SIMPLEASSETSTORAGE]: Failed reading data for asset {0} from {1}: {2}", assetID, filename, ex.Message); | ||
85 | ret = BackendResponse.Failure; | ||
86 | } | ||
87 | } | ||
88 | else | ||
89 | { | ||
90 | ret = BackendResponse.NotFound; | ||
91 | } | ||
92 | |||
93 | server.MetricsProvider.LogAssetDataFetch(EXTENSION_NAME, ret, assetID, (assetData != null ? assetData.Length : 0), DateTime.Now); | ||
94 | return ret; | ||
95 | } | ||
96 | |||
97 | public BackendResponse TryFetchDataMetadata(UUID assetID, out AssetBase asset) | ||
98 | { | ||
99 | asset = new AssetBase(); | ||
100 | AssetMetadata metadata = asset.Metadata; | ||
101 | |||
102 | string filename; | ||
103 | BackendResponse ret; | ||
104 | |||
105 | if (metadataStorage.TryGetValue(assetID, out metadata) && | ||
106 | filenames.TryGetValue(assetID, out filename)) | ||
107 | { | ||
108 | try | ||
109 | { | ||
110 | asset.Data = File.ReadAllBytes(filename); | ||
111 | ret = BackendResponse.Success; | ||
112 | } | ||
113 | catch (Exception ex) | ||
114 | { | ||
115 | m_log.ErrorFormat("[SIMPLEASSETSTORAGE]: Failed reading data for asset {0} from {1}: {2}", assetID, filename, ex.Message); | ||
116 | ret = BackendResponse.Failure; | ||
117 | } | ||
118 | |||
119 | asset.Type = (sbyte) Utils.ContentTypeToSLAssetType(metadata.ContentType); | ||
120 | asset.Local = false; | ||
121 | } | ||
122 | else | ||
123 | { | ||
124 | asset = null; | ||
125 | ret = BackendResponse.NotFound; | ||
126 | } | ||
127 | |||
128 | server.MetricsProvider.LogAssetMetadataFetch(EXTENSION_NAME, ret, assetID, DateTime.Now); | ||
129 | server.MetricsProvider.LogAssetDataFetch(EXTENSION_NAME, ret, assetID, (asset != null && asset.Data != null ? asset.Data.Length : 0), DateTime.Now); | ||
130 | return ret; | ||
131 | } | ||
132 | |||
133 | public BackendResponse TryCreateAsset(AssetBase asset, out UUID assetID) | ||
134 | { | ||
135 | assetID = asset.FullID = UUID.Random(); | ||
136 | return TryCreateAsset(asset); | ||
137 | } | ||
138 | |||
139 | public BackendResponse TryCreateAsset(AssetBase asset) | ||
140 | { | ||
141 | BackendResponse ret; | ||
142 | AssetMetadata metadata = asset.Metadata; | ||
143 | |||
144 | string path; | ||
145 | string filename = String.Format("{0}.{1}", asset.FullID, Utils.ContentTypeToExtension(metadata.ContentType)); | ||
146 | |||
147 | if (asset.Temporary) | ||
148 | path = Path.Combine(TEMP_DATA_DIR, filename); | ||
149 | else | ||
150 | path = Path.Combine(DEFAULT_DATA_DIR, filename); | ||
151 | |||
152 | try | ||
153 | { | ||
154 | File.WriteAllBytes(path, asset.Data); | ||
155 | lock (filenames) filenames[asset.FullID] = path; | ||
156 | |||
157 | // Set the creation date to right now | ||
158 | metadata.CreationDate = DateTime.Now; | ||
159 | |||
160 | lock (metadataStorage) | ||
161 | metadataStorage[asset.FullID] = metadata; | ||
162 | |||
163 | ret = BackendResponse.Success; | ||
164 | } | ||
165 | catch (Exception ex) | ||
166 | { | ||
167 | m_log.ErrorFormat("[SIMPLEASSETSTORAGE]: Failed writing data for asset {0} to {1}: {2}", asset.FullID, filename, ex.Message); | ||
168 | ret = BackendResponse.Failure; | ||
169 | } | ||
170 | |||
171 | server.MetricsProvider.LogAssetCreate(EXTENSION_NAME, ret, asset.FullID, asset.Data.Length, DateTime.Now); | ||
172 | return ret; | ||
173 | } | ||
174 | |||
175 | public int ForEach(Action<AssetMetadata> action, int start, int count) | ||
176 | { | ||
177 | int rowCount = 0; | ||
178 | |||
179 | //lock (metadataStorage) | ||
180 | //{ | ||
181 | // foreach (Metadata metadata in metadataStorage.Values) | ||
182 | // { | ||
183 | // action(metadata); | ||
184 | // ++rowCount; | ||
185 | // } | ||
186 | //} | ||
187 | |||
188 | return rowCount; | ||
189 | } | ||
190 | |||
191 | #endregion Required Interfaces | ||
192 | |||
193 | #region IPlugin implementation | ||
194 | |||
195 | public void Initialise(AssetInventoryServer server) | ||
196 | { | ||
197 | this.server = server; | ||
198 | |||
199 | metadataStorage = new Dictionary<UUID, AssetMetadata>(); | ||
200 | filenames = new Dictionary<UUID, string>(); | ||
201 | |||
202 | LoadFiles(DEFAULT_DATA_DIR, false); | ||
203 | LoadFiles(TEMP_DATA_DIR, true); | ||
204 | |||
205 | m_log.InfoFormat("[SIMPLEASSETSTORAGE]: Initialized the store index with metadata for {0} assets", | ||
206 | metadataStorage.Count); | ||
207 | } | ||
208 | |||
209 | /// <summary> | ||
210 | /// <para>Initialises asset interface</para> | ||
211 | /// </summary> | ||
212 | public void Initialise() | ||
213 | { | ||
214 | m_log.InfoFormat("[SIMPLEASSETSTORAGE]: {0} cannot be default-initialized!", Name); | ||
215 | throw new PluginNotInitialisedException(Name); | ||
216 | } | ||
217 | |||
218 | public void Dispose() | ||
219 | { | ||
220 | WipeTemporary(); | ||
221 | } | ||
222 | |||
223 | public string Version | ||
224 | { | ||
225 | // TODO: this should be something meaningful and not hardcoded? | ||
226 | get { return "0.1"; } | ||
227 | } | ||
228 | |||
229 | public string Name | ||
230 | { | ||
231 | get { return "SimpleAssetStorage"; } | ||
232 | } | ||
233 | |||
234 | #endregion IPlugin implementation | ||
235 | |||
236 | public void WipeTemporary() | ||
237 | { | ||
238 | if (Directory.Exists(TEMP_DATA_DIR)) | ||
239 | { | ||
240 | try { Directory.Delete(TEMP_DATA_DIR); } | ||
241 | catch (Exception ex) { m_log.Error("[SIMPLEASSETSTORAGE]: " + ex.Message); } | ||
242 | } | ||
243 | } | ||
244 | |||
245 | void LoadFiles(string folder, bool temporary) | ||
246 | { | ||
247 | // Try to create the directory if it doesn't already exist | ||
248 | if (!Directory.Exists(folder)) | ||
249 | { | ||
250 | try { Directory.CreateDirectory(folder); } | ||
251 | catch (Exception ex) | ||
252 | { | ||
253 | m_log.Warn("[SIMPLEASSETSTORAGE]: " + ex.Message); | ||
254 | return; | ||
255 | } | ||
256 | } | ||
257 | |||
258 | lock (metadataStorage) | ||
259 | { | ||
260 | try | ||
261 | { | ||
262 | string[] assets = Directory.GetFiles(folder); | ||
263 | |||
264 | for (int i = 0; i < assets.Length; i++) | ||
265 | { | ||
266 | string filename = assets[i]; | ||
267 | byte[] data = File.ReadAllBytes(filename); | ||
268 | |||
269 | AssetMetadata metadata = new AssetMetadata(); | ||
270 | metadata.CreationDate = File.GetCreationTime(filename); | ||
271 | metadata.Description = String.Empty; | ||
272 | metadata.FullID = SimpleUtils.ParseUUIDFromFilename(filename); | ||
273 | metadata.Name = SimpleUtils.ParseNameFromFilename(filename); | ||
274 | metadata.SHA1 = OpenMetaverse.Utils.SHA1(data); | ||
275 | metadata.Temporary = false; | ||
276 | metadata.ContentType = Utils.ExtensionToContentType(Path.GetExtension(filename).TrimStart('.')); | ||
277 | |||
278 | // Store the loaded data | ||
279 | metadataStorage[metadata.FullID] = metadata; | ||
280 | filenames[metadata.FullID] = filename; | ||
281 | } | ||
282 | } | ||
283 | catch (Exception ex) | ||
284 | { | ||
285 | m_log.Warn("[SIMPLEASSETSTORAGE]: " + ex.Message); | ||
286 | } | ||
287 | } | ||
288 | } | ||
289 | } | ||
290 | } | ||
diff --git a/OpenSim/Grid/AssetInventoryServer/Plugins/Simple/SimpleInventoryStoragePlugin.cs b/OpenSim/Grid/AssetInventoryServer/Plugins/Simple/SimpleInventoryStoragePlugin.cs deleted file mode 100644 index 4010818..0000000 --- a/OpenSim/Grid/AssetInventoryServer/Plugins/Simple/SimpleInventoryStoragePlugin.cs +++ /dev/null | |||
@@ -1,625 +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.Reflection; | ||
30 | using System.Collections.Generic; | ||
31 | using System.IO; | ||
32 | using System.Text; | ||
33 | using OpenMetaverse; | ||
34 | using OpenSim.Framework; | ||
35 | using log4net; | ||
36 | |||
37 | namespace OpenSim.Grid.AssetInventoryServer.Plugins.Simple | ||
38 | { | ||
39 | public class SimpleInventoryStoragePlugin : IInventoryStorageProvider | ||
40 | { | ||
41 | const string EXTENSION_NAME = "SimpleInventoryStorage"; // Used for metrics reporting | ||
42 | const string DEFAULT_INVENTORY_DIR = "SimpleInventory"; | ||
43 | |||
44 | private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); | ||
45 | AssetInventoryServer server; | ||
46 | Dictionary<Uri, InventoryCollection> inventories = new Dictionary<Uri, InventoryCollection>(); | ||
47 | Dictionary<Uri, List<InventoryItemBase>> activeGestures = new Dictionary<Uri, List<InventoryItemBase>>(); | ||
48 | Utils.InventoryItemSerializer itemSerializer = new Utils.InventoryItemSerializer(); | ||
49 | Utils.InventoryFolderSerializer folderSerializer = new Utils.InventoryFolderSerializer(); | ||
50 | |||
51 | public SimpleInventoryStoragePlugin() | ||
52 | { | ||
53 | } | ||
54 | |||
55 | #region Required Interfaces | ||
56 | |||
57 | public BackendResponse TryFetchItem(Uri owner, UUID itemID, out InventoryItemBase item) | ||
58 | { | ||
59 | item = null; | ||
60 | BackendResponse ret; | ||
61 | |||
62 | InventoryCollection collection; | ||
63 | if (inventories.TryGetValue(owner, out collection) && collection.Items.TryGetValue(itemID, out item)) | ||
64 | ret = BackendResponse.Success; | ||
65 | else | ||
66 | ret = BackendResponse.NotFound; | ||
67 | |||
68 | server.MetricsProvider.LogInventoryFetch(EXTENSION_NAME, ret, owner, itemID, false, DateTime.Now); | ||
69 | return ret; | ||
70 | } | ||
71 | |||
72 | public BackendResponse TryFetchFolder(Uri owner, UUID folderID, out InventoryFolderWithChildren folder) | ||
73 | { | ||
74 | folder = null; | ||
75 | BackendResponse ret; | ||
76 | |||
77 | InventoryCollection collection; | ||
78 | if (inventories.TryGetValue(owner, out collection) && collection.Folders.TryGetValue(folderID, out folder)) | ||
79 | ret = BackendResponse.Success; | ||
80 | else | ||
81 | ret = BackendResponse.NotFound; | ||
82 | |||
83 | server.MetricsProvider.LogInventoryFetch(EXTENSION_NAME, ret, owner, folderID, true, DateTime.Now); | ||
84 | return ret; | ||
85 | } | ||
86 | |||
87 | public BackendResponse TryFetchFolderContents(Uri owner, UUID folderID, out InventoryCollection contents) | ||
88 | { | ||
89 | contents = null; | ||
90 | BackendResponse ret; | ||
91 | |||
92 | InventoryCollection collection; | ||
93 | InventoryFolderWithChildren folder; | ||
94 | |||
95 | if (inventories.TryGetValue(owner, out collection) && collection.Folders.TryGetValue(folderID, out folder)) | ||
96 | { | ||
97 | contents = new InventoryCollection(); | ||
98 | contents.UserID = collection.UserID; | ||
99 | contents.Folders = new Dictionary<UUID, InventoryFolderWithChildren>(); | ||
100 | contents.Items = new Dictionary<UUID, InventoryItemBase>(); | ||
101 | |||
102 | foreach (InventoryNodeBase invBase in folder.Children.Values) | ||
103 | { | ||
104 | if (invBase is InventoryItemBase) | ||
105 | { | ||
106 | InventoryItemBase invItem = invBase as InventoryItemBase; | ||
107 | contents.Items.Add(invItem.ID, invItem); | ||
108 | } | ||
109 | else | ||
110 | { | ||
111 | InventoryFolderWithChildren invFolder = invBase as InventoryFolderWithChildren; | ||
112 | contents.Folders.Add(invFolder.ID, invFolder); | ||
113 | } | ||
114 | } | ||
115 | |||
116 | ret = BackendResponse.Success; | ||
117 | } | ||
118 | else | ||
119 | { | ||
120 | ret = BackendResponse.NotFound; | ||
121 | } | ||
122 | |||
123 | server.MetricsProvider.LogInventoryFetchFolderContents(EXTENSION_NAME, ret, owner, folderID, DateTime.Now); | ||
124 | return ret; | ||
125 | } | ||
126 | |||
127 | public BackendResponse TryFetchFolderList(Uri owner, out List<InventoryFolderWithChildren> folders) | ||
128 | { | ||
129 | folders = null; | ||
130 | BackendResponse ret; | ||
131 | |||
132 | InventoryCollection collection; | ||
133 | if (inventories.TryGetValue(owner, out collection)) | ||
134 | { | ||
135 | folders = new List<InventoryFolderWithChildren>(collection.Folders.Values); | ||
136 | return BackendResponse.Success; | ||
137 | } | ||
138 | else | ||
139 | { | ||
140 | ret = BackendResponse.NotFound; | ||
141 | } | ||
142 | |||
143 | server.MetricsProvider.LogInventoryFetchFolderList(EXTENSION_NAME, ret, owner, DateTime.Now); | ||
144 | return ret; | ||
145 | } | ||
146 | |||
147 | public BackendResponse TryFetchInventory(Uri owner, out InventoryCollection inventory) | ||
148 | { | ||
149 | inventory = null; | ||
150 | BackendResponse ret; | ||
151 | |||
152 | if (inventories.TryGetValue(owner, out inventory)) | ||
153 | ret = BackendResponse.Success; | ||
154 | else | ||
155 | ret = BackendResponse.NotFound; | ||
156 | |||
157 | server.MetricsProvider.LogInventoryFetchInventory(EXTENSION_NAME, ret, owner, DateTime.Now); | ||
158 | return ret; | ||
159 | } | ||
160 | |||
161 | public BackendResponse TryFetchActiveGestures(Uri owner, out List<InventoryItemBase> gestures) | ||
162 | { | ||
163 | gestures = null; | ||
164 | BackendResponse ret; | ||
165 | |||
166 | if (activeGestures.TryGetValue(owner, out gestures)) | ||
167 | ret = BackendResponse.Success; | ||
168 | else | ||
169 | ret = BackendResponse.NotFound; | ||
170 | |||
171 | server.MetricsProvider.LogInventoryFetchActiveGestures(EXTENSION_NAME, ret, owner, DateTime.Now); | ||
172 | return ret; | ||
173 | } | ||
174 | |||
175 | public BackendResponse TryCreateItem(Uri owner, InventoryItemBase item) | ||
176 | { | ||
177 | BackendResponse ret; | ||
178 | |||
179 | InventoryCollection collection; | ||
180 | if (inventories.TryGetValue(owner, out collection)) | ||
181 | { | ||
182 | // Delete this item first if it already exists | ||
183 | InventoryItemBase oldItem; | ||
184 | if (collection.Items.TryGetValue(item.ID, out oldItem)) | ||
185 | TryDeleteItem(owner, item.ID); | ||
186 | |||
187 | try | ||
188 | { | ||
189 | // Create the file | ||
190 | SaveItem(item); | ||
191 | |||
192 | // Add the item to the collection | ||
193 | lock (collection) collection.Items[item.ID] = item; | ||
194 | |||
195 | // Add the item to its parent folder | ||
196 | InventoryFolderWithChildren parent; | ||
197 | if (collection.Folders.TryGetValue(item.Folder, out parent)) | ||
198 | lock (parent.Children) parent.Children.Add(item.ID, item); | ||
199 | |||
200 | // Add active gestures to our list | ||
201 | if (item.InvType == (int)InventoryType.Gesture && item.Flags == 1) | ||
202 | { | ||
203 | lock (activeGestures) | ||
204 | activeGestures[owner].Add(item); | ||
205 | } | ||
206 | |||
207 | ret = BackendResponse.Success; | ||
208 | } | ||
209 | catch (Exception ex) | ||
210 | { | ||
211 | m_log.Error("[SIMPLEINVENTORYSTORAGE]: " + ex.Message); | ||
212 | ret = BackendResponse.Failure; | ||
213 | } | ||
214 | } | ||
215 | else | ||
216 | { | ||
217 | return BackendResponse.NotFound; | ||
218 | } | ||
219 | |||
220 | server.MetricsProvider.LogInventoryCreate(EXTENSION_NAME, ret, owner, false, DateTime.Now); | ||
221 | return ret; | ||
222 | } | ||
223 | |||
224 | public BackendResponse TryCreateFolder(Uri owner, InventoryFolderWithChildren folder) | ||
225 | { | ||
226 | BackendResponse ret; | ||
227 | |||
228 | InventoryCollection collection; | ||
229 | if (inventories.TryGetValue(owner, out collection)) | ||
230 | { | ||
231 | // Delete this folder first if it already exists | ||
232 | InventoryFolderWithChildren oldFolder; | ||
233 | if (collection.Folders.TryGetValue(folder.ID, out oldFolder)) | ||
234 | TryDeleteFolder(owner, folder.ID); | ||
235 | |||
236 | try | ||
237 | { | ||
238 | // Create the file | ||
239 | SaveFolder(folder); | ||
240 | |||
241 | // Add the folder to the collection | ||
242 | lock (collection) collection.Folders[folder.ID] = folder; | ||
243 | |||
244 | // Add the folder to its parent folder | ||
245 | InventoryFolderWithChildren parent; | ||
246 | if (collection.Folders.TryGetValue(folder.ParentID, out parent)) | ||
247 | lock (parent.Children) parent.Children.Add(folder.ID, folder); | ||
248 | |||
249 | ret = BackendResponse.Success; | ||
250 | } | ||
251 | catch (Exception ex) | ||
252 | { | ||
253 | m_log.Error("[SIMPLEINVENTORYSTORAGE]: " + ex.Message); | ||
254 | ret = BackendResponse.Failure; | ||
255 | } | ||
256 | } | ||
257 | else | ||
258 | { | ||
259 | ret = BackendResponse.NotFound; | ||
260 | } | ||
261 | |||
262 | server.MetricsProvider.LogInventoryCreate(EXTENSION_NAME, ret, owner, true, DateTime.Now); | ||
263 | return ret; | ||
264 | } | ||
265 | |||
266 | public BackendResponse TryCreateInventory(Uri owner, InventoryFolderWithChildren rootFolder) | ||
267 | { | ||
268 | BackendResponse ret; | ||
269 | |||
270 | lock (inventories) | ||
271 | { | ||
272 | if (!inventories.ContainsKey(owner)) | ||
273 | { | ||
274 | InventoryCollection collection = new InventoryCollection(); | ||
275 | collection.UserID = rootFolder.Owner; | ||
276 | collection.Folders = new Dictionary<UUID, InventoryFolderWithChildren>(); | ||
277 | collection.Folders.Add(rootFolder.ID, rootFolder); | ||
278 | collection.Items = new Dictionary<UUID, InventoryItemBase>(); | ||
279 | |||
280 | inventories.Add(owner, collection); | ||
281 | |||
282 | ret = BackendResponse.Success; | ||
283 | } | ||
284 | else | ||
285 | { | ||
286 | ret = BackendResponse.Failure; | ||
287 | } | ||
288 | } | ||
289 | |||
290 | if (ret == BackendResponse.Success) | ||
291 | { | ||
292 | string path = Path.Combine(DEFAULT_INVENTORY_DIR, rootFolder.Owner.ToString()); | ||
293 | try | ||
294 | { | ||
295 | // Create the directory for this agent | ||
296 | Directory.CreateDirectory(path); | ||
297 | |||
298 | // Create an index.txt containing the UUID and URI for this agent | ||
299 | string[] index = new string[] { rootFolder.Owner.ToString(), owner.ToString() }; | ||
300 | File.WriteAllLines(Path.Combine(path, "index.txt"), index); | ||
301 | |||
302 | // Create the root folder file | ||
303 | SaveFolder(rootFolder); | ||
304 | } | ||
305 | catch (Exception ex) | ||
306 | { | ||
307 | m_log.Error("[SIMPLEINVENTORYSTORAGE]: " + ex.Message); | ||
308 | ret = BackendResponse.Failure; | ||
309 | } | ||
310 | } | ||
311 | |||
312 | server.MetricsProvider.LogInventoryCreateInventory(EXTENSION_NAME, ret, DateTime.Now); | ||
313 | return ret; | ||
314 | } | ||
315 | |||
316 | public BackendResponse TryDeleteItem(Uri owner, UUID itemID) | ||
317 | { | ||
318 | BackendResponse ret; | ||
319 | |||
320 | InventoryCollection collection; | ||
321 | InventoryItemBase item; | ||
322 | if (inventories.TryGetValue(owner, out collection) && collection.Items.TryGetValue(itemID, out item)) | ||
323 | { | ||
324 | // Remove the item from its parent folder | ||
325 | InventoryFolderWithChildren parent; | ||
326 | if (collection.Folders.TryGetValue(item.Folder, out parent)) | ||
327 | lock (parent.Children) parent.Children.Remove(itemID); | ||
328 | |||
329 | // Remove the item from the collection | ||
330 | lock (collection) collection.Items.Remove(itemID); | ||
331 | |||
332 | // Remove from the active gestures list if applicable | ||
333 | if (item.InvType == (int)InventoryType.Gesture) | ||
334 | { | ||
335 | lock (activeGestures) | ||
336 | { | ||
337 | for (int i = 0; i < activeGestures[owner].Count; i++) | ||
338 | { | ||
339 | if (activeGestures[owner][i].ID == itemID) | ||
340 | { | ||
341 | activeGestures[owner].RemoveAt(i); | ||
342 | break; | ||
343 | } | ||
344 | } | ||
345 | } | ||
346 | } | ||
347 | |||
348 | // Delete the file. We don't know exactly what the file name is, | ||
349 | // so search for it | ||
350 | string path = PathFromURI(owner); | ||
351 | string[] matches = Directory.GetFiles(path, String.Format("*{0}.item", itemID), SearchOption.TopDirectoryOnly); | ||
352 | foreach (string match in matches) | ||
353 | { | ||
354 | try { File.Delete(match); } | ||
355 | catch (Exception ex) { m_log.ErrorFormat("[SIMPLEINVENTORYSTORAGE]: Failed to delete file {0}: {1}", match, ex.Message); } | ||
356 | } | ||
357 | |||
358 | ret = BackendResponse.Success; | ||
359 | } | ||
360 | else | ||
361 | { | ||
362 | ret = BackendResponse.NotFound; | ||
363 | } | ||
364 | |||
365 | server.MetricsProvider.LogInventoryDelete(EXTENSION_NAME, ret, owner, itemID, false, DateTime.Now); | ||
366 | return ret; | ||
367 | } | ||
368 | |||
369 | public BackendResponse TryDeleteFolder(Uri owner, UUID folderID) | ||
370 | { | ||
371 | BackendResponse ret; | ||
372 | |||
373 | InventoryCollection collection; | ||
374 | InventoryFolderWithChildren folder; | ||
375 | if (inventories.TryGetValue(owner, out collection) && collection.Folders.TryGetValue(folderID, out folder)) | ||
376 | { | ||
377 | // Remove the folder from its parent folder | ||
378 | InventoryFolderWithChildren parent; | ||
379 | if (collection.Folders.TryGetValue(folder.ParentID, out parent)) | ||
380 | lock (parent.Children) parent.Children.Remove(folderID); | ||
381 | |||
382 | // Remove the folder from the collection | ||
383 | lock (collection) collection.Items.Remove(folderID); | ||
384 | |||
385 | // Delete the folder file. We don't know exactly what the file name is, | ||
386 | // so search for it | ||
387 | string path = PathFromURI(owner); | ||
388 | string[] matches = Directory.GetFiles(path, String.Format("*{0}.folder", folderID), SearchOption.TopDirectoryOnly); | ||
389 | foreach (string match in matches) | ||
390 | { | ||
391 | try { File.Delete(match); } | ||
392 | catch (Exception ex) { m_log.ErrorFormat("[SIMPLEINVENTORYSTORAGE]: Failed to delete folder file {0}: {1}", match, ex.Message); } | ||
393 | } | ||
394 | |||
395 | ret = BackendResponse.Success; | ||
396 | } | ||
397 | else | ||
398 | { | ||
399 | ret = BackendResponse.NotFound; | ||
400 | } | ||
401 | |||
402 | server.MetricsProvider.LogInventoryDelete(EXTENSION_NAME, ret, owner, folderID, true, DateTime.Now); | ||
403 | return ret; | ||
404 | } | ||
405 | |||
406 | public BackendResponse TryPurgeFolder(Uri owner, UUID folderID) | ||
407 | { | ||
408 | BackendResponse ret; | ||
409 | |||
410 | InventoryCollection collection; | ||
411 | InventoryFolderWithChildren folder; | ||
412 | if (inventories.TryGetValue(owner, out collection) && collection.Folders.TryGetValue(folderID, out folder)) | ||
413 | { | ||
414 | // Delete all of the folder children | ||
415 | foreach (InventoryNodeBase obj in new List<InventoryNodeBase>(folder.Children.Values)) | ||
416 | { | ||
417 | if (obj is InventoryItemBase) | ||
418 | { | ||
419 | TryDeleteItem(owner, (obj as InventoryItemBase).ID); | ||
420 | } | ||
421 | else | ||
422 | { | ||
423 | InventoryFolderWithChildren childFolder = obj as InventoryFolderWithChildren; | ||
424 | TryPurgeFolder(owner, childFolder.ID); | ||
425 | TryDeleteFolder(owner, childFolder.ID); | ||
426 | } | ||
427 | } | ||
428 | |||
429 | ret = BackendResponse.Success; | ||
430 | } | ||
431 | else | ||
432 | { | ||
433 | ret = BackendResponse.NotFound; | ||
434 | } | ||
435 | |||
436 | server.MetricsProvider.LogInventoryPurgeFolder(EXTENSION_NAME, ret, owner, folderID, DateTime.Now); | ||
437 | return ret; | ||
438 | } | ||
439 | |||
440 | #endregion Required Interfaces | ||
441 | |||
442 | void SaveItem(InventoryItemBase item) | ||
443 | { | ||
444 | string filename = String.Format("{0}-{1}.item", SanitizeFilename(item.Name), item.ID); | ||
445 | |||
446 | string path = Path.Combine(DEFAULT_INVENTORY_DIR, item.Owner.ToString()); | ||
447 | path = Path.Combine(path, filename); | ||
448 | |||
449 | using (FileStream stream = new FileStream(path, FileMode.Create, FileAccess.Write)) | ||
450 | { | ||
451 | itemSerializer.Serialize(stream, item); | ||
452 | stream.Flush(); | ||
453 | } | ||
454 | } | ||
455 | |||
456 | void SaveFolder(InventoryFolderWithChildren folder) | ||
457 | { | ||
458 | string filename = String.Format("{0}-{1}.folder", SanitizeFilename(folder.Name), folder.ID); | ||
459 | |||
460 | string path = Path.Combine(DEFAULT_INVENTORY_DIR, folder.Owner.ToString()); | ||
461 | path = Path.Combine(path, filename); | ||
462 | |||
463 | using (FileStream stream = new FileStream(path, FileMode.Create, FileAccess.Write)) | ||
464 | { | ||
465 | folderSerializer.Serialize(stream, folder); | ||
466 | stream.Flush(); | ||
467 | } | ||
468 | } | ||
469 | |||
470 | string SanitizeFilename(string filename) | ||
471 | { | ||
472 | string output = filename; | ||
473 | |||
474 | if (output.Length > 64) | ||
475 | output = output.Substring(0, 64); | ||
476 | |||
477 | foreach (char i in Path.GetInvalidFileNameChars()) | ||
478 | output = output.Replace(i, '_'); | ||
479 | |||
480 | return output; | ||
481 | } | ||
482 | |||
483 | static string PathFromURI(Uri uri) | ||
484 | { | ||
485 | byte[] hash = OpenMetaverse.Utils.SHA1(Encoding.UTF8.GetBytes(uri.ToString())); | ||
486 | StringBuilder digest = new StringBuilder(40); | ||
487 | |||
488 | // Convert the hash to a hex string | ||
489 | foreach (byte b in hash) | ||
490 | digest.AppendFormat(OpenMetaverse.Utils.EnUsCulture, "{0:x2}", b); | ||
491 | |||
492 | return Path.Combine(DEFAULT_INVENTORY_DIR, digest.ToString()); | ||
493 | } | ||
494 | |||
495 | void LoadFiles(string folder) | ||
496 | { | ||
497 | // Try to create the directory if it doesn't already exist | ||
498 | if (!Directory.Exists(folder)) | ||
499 | { | ||
500 | try { Directory.CreateDirectory(folder); } | ||
501 | catch (Exception ex) | ||
502 | { | ||
503 | m_log.Warn("[SIMPLEINVENTORYSTORAGE]: " + ex.Message); | ||
504 | return; | ||
505 | } | ||
506 | } | ||
507 | |||
508 | try | ||
509 | { | ||
510 | string[] agentFolders = Directory.GetDirectories(DEFAULT_INVENTORY_DIR); | ||
511 | |||
512 | for (int i = 0; i < agentFolders.Length; i++) | ||
513 | { | ||
514 | string foldername = agentFolders[i]; | ||
515 | string indexPath = Path.Combine(foldername, "index.txt"); | ||
516 | UUID ownerID = UUID.Zero; | ||
517 | Uri owner = null; | ||
518 | |||
519 | try | ||
520 | { | ||
521 | string[] index = File.ReadAllLines(indexPath); | ||
522 | ownerID = UUID.Parse(index[0]); | ||
523 | owner = new Uri(index[1]); | ||
524 | } | ||
525 | catch (Exception ex) | ||
526 | { | ||
527 | m_log.WarnFormat("[SIMPLEINVENTORYSTORAGE]: Failed loading the index file {0}: {1}", indexPath, ex.Message); | ||
528 | } | ||
529 | |||
530 | if (ownerID != UUID.Zero && owner != null) | ||
531 | { | ||
532 | // Initialize the active gestures list for this agent | ||
533 | activeGestures.Add(owner, new List<InventoryItemBase>()); | ||
534 | |||
535 | InventoryCollection collection = new InventoryCollection(); | ||
536 | collection.UserID = ownerID; | ||
537 | |||
538 | // Load all of the folders for this agent | ||
539 | string[] folders = Directory.GetFiles(foldername, "*.folder", SearchOption.TopDirectoryOnly); | ||
540 | collection.Folders = new Dictionary<UUID,InventoryFolderWithChildren>(folders.Length); | ||
541 | |||
542 | for (int j = 0; j < folders.Length; j++) | ||
543 | { | ||
544 | InventoryFolderWithChildren invFolder = (InventoryFolderWithChildren)folderSerializer.Deserialize( | ||
545 | new FileStream(folders[j], FileMode.Open, FileAccess.Read)); | ||
546 | collection.Folders[invFolder.ID] = invFolder; | ||
547 | } | ||
548 | |||
549 | // Iterate over the folders collection, adding children to their parents | ||
550 | foreach (InventoryFolderWithChildren invFolder in collection.Folders.Values) | ||
551 | { | ||
552 | InventoryFolderWithChildren parent; | ||
553 | if (collection.Folders.TryGetValue(invFolder.ParentID, out parent)) | ||
554 | parent.Children[invFolder.ID] = invFolder; | ||
555 | } | ||
556 | |||
557 | // Load all of the items for this agent | ||
558 | string[] files = Directory.GetFiles(foldername, "*.item", SearchOption.TopDirectoryOnly); | ||
559 | collection.Items = new Dictionary<UUID, InventoryItemBase>(files.Length); | ||
560 | |||
561 | for (int j = 0; j < files.Length; j++) | ||
562 | { | ||
563 | InventoryItemBase invItem = (InventoryItemBase)itemSerializer.Deserialize( | ||
564 | new FileStream(files[j], FileMode.Open, FileAccess.Read)); | ||
565 | collection.Items[invItem.ID] = invItem; | ||
566 | |||
567 | // Add items to their parent folders | ||
568 | InventoryFolderWithChildren parent; | ||
569 | if (collection.Folders.TryGetValue(invItem.Folder, out parent)) | ||
570 | parent.Children[invItem.ID] = invItem; | ||
571 | |||
572 | // Add active gestures to our list | ||
573 | if (invItem.InvType == (int)InventoryType.Gesture && invItem.Flags != 0) | ||
574 | activeGestures[owner].Add(invItem); | ||
575 | } | ||
576 | |||
577 | inventories.Add(owner, collection); | ||
578 | } | ||
579 | } | ||
580 | } | ||
581 | catch (Exception ex) | ||
582 | { | ||
583 | m_log.ErrorFormat("[SIMPLEINVENTORYSTORAGE]: Failed loading inventory from {0}: {1}", folder, ex.Message); | ||
584 | } | ||
585 | } | ||
586 | |||
587 | #region IPlugin implementation | ||
588 | |||
589 | public void Initialise(AssetInventoryServer server) | ||
590 | { | ||
591 | this.server = server; | ||
592 | |||
593 | LoadFiles(DEFAULT_INVENTORY_DIR); | ||
594 | |||
595 | m_log.InfoFormat("[SIMPLEINVENTORYSTORAGE]: Initialized the inventory index with data for {0} avatars", | ||
596 | inventories.Count); | ||
597 | } | ||
598 | |||
599 | /// <summary> | ||
600 | /// <para>Initialises asset interface</para> | ||
601 | /// </summary> | ||
602 | public void Initialise() | ||
603 | { | ||
604 | m_log.InfoFormat("[SIMPLEINVENTORYSTORAGE]: {0} cannot be default-initialized!", Name); | ||
605 | throw new PluginNotInitialisedException(Name); | ||
606 | } | ||
607 | |||
608 | public void Dispose() | ||
609 | { | ||
610 | } | ||
611 | |||
612 | public string Version | ||
613 | { | ||
614 | // TODO: this should be something meaningful and not hardcoded? | ||
615 | get { return "0.1"; } | ||
616 | } | ||
617 | |||
618 | public string Name | ||
619 | { | ||
620 | get { return "SimpleInventoryStorage"; } | ||
621 | } | ||
622 | |||
623 | #endregion IPlugin implementation | ||
624 | } | ||
625 | } | ||
diff --git a/OpenSim/Grid/AssetInventoryServer/Plugins/Simple/SimpleUtils.cs b/OpenSim/Grid/AssetInventoryServer/Plugins/Simple/SimpleUtils.cs deleted file mode 100644 index 0d5c53a..0000000 --- a/OpenSim/Grid/AssetInventoryServer/Plugins/Simple/SimpleUtils.cs +++ /dev/null | |||
@@ -1,71 +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 OpenMetaverse; | ||
31 | |||
32 | namespace OpenSim.Grid.AssetInventoryServer.Plugins.Simple | ||
33 | { | ||
34 | public static class SimpleUtils | ||
35 | { | ||
36 | public static string ParseNameFromFilename(string filename) | ||
37 | { | ||
38 | filename = Path.GetFileName(filename); | ||
39 | |||
40 | int dot = filename.LastIndexOf('.'); | ||
41 | int firstDash = filename.IndexOf('-'); | ||
42 | |||
43 | if (dot - 37 > 0 && firstDash > 0) | ||
44 | return filename.Substring(0, firstDash); | ||
45 | else | ||
46 | return String.Empty; | ||
47 | } | ||
48 | |||
49 | public static UUID ParseUUIDFromFilename(string filename) | ||
50 | { | ||
51 | int dot = filename.LastIndexOf('.'); | ||
52 | |||
53 | if (dot > 35) | ||
54 | { | ||
55 | // Grab the last 36 characters of the filename | ||
56 | string uuidString = filename.Substring(dot - 36, 36); | ||
57 | UUID uuid; | ||
58 | UUID.TryParse(uuidString, out uuid); | ||
59 | return uuid; | ||
60 | } | ||
61 | else | ||
62 | { | ||
63 | UUID uuid; | ||
64 | if (UUID.TryParse(Path.GetFileName(filename), out uuid)) | ||
65 | return uuid; | ||
66 | else | ||
67 | return UUID.Zero; | ||
68 | } | ||
69 | } | ||
70 | } | ||
71 | } | ||
diff --git a/OpenSim/Grid/AssetInventoryServer/Utils.cs b/OpenSim/Grid/AssetInventoryServer/Utils.cs deleted file mode 100644 index 9bbc0bc..0000000 --- a/OpenSim/Grid/AssetInventoryServer/Utils.cs +++ /dev/null | |||
@@ -1,1031 +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.Globalization; | ||
30 | using System.Xml; | ||
31 | using System.Xml.Serialization; | ||
32 | using OpenMetaverse; | ||
33 | using OpenSim.Framework; | ||
34 | using OpenSim.Framework.Servers; | ||
35 | using OpenSim.Framework.Servers.HttpServer; | ||
36 | |||
37 | namespace OpenSim.Grid.AssetInventoryServer | ||
38 | { | ||
39 | public static class Utils | ||
40 | { | ||
41 | public static UUID GetAuthToken(OSHttpRequest request) | ||
42 | { | ||
43 | UUID authToken = UUID.Zero; | ||
44 | |||
45 | string[] authHeader = request.Headers.GetValues("Authorization"); | ||
46 | if (authHeader != null && authHeader.Length == 1) | ||
47 | { | ||
48 | // Example header: | ||
49 | // Authorization: OpenGrid 65fda0b5-4446-42f5-b828-aaf644293646 | ||
50 | string[] authHeaderParts = authHeader[0].Split(' '); | ||
51 | if (authHeaderParts.Length == 2 && authHeaderParts[0] == "OpenGrid") | ||
52 | UUID.TryParse(authHeaderParts[1], out authToken); | ||
53 | } | ||
54 | |||
55 | //if (authToken == UUID.Zero && request.Cookies != null) | ||
56 | //{ | ||
57 | // // Check for an authToken cookie to make logins browser-compatible | ||
58 | // RequestCookie authCookie = request.Cookies["authToken"]; | ||
59 | // if (authCookie != null) | ||
60 | // UUID.TryParse(authCookie.Value, out authToken); | ||
61 | //} | ||
62 | |||
63 | return authToken; | ||
64 | } | ||
65 | |||
66 | public static Uri GetOpenSimUri(UUID avatarID) | ||
67 | { | ||
68 | return new Uri("http://opensim/" + avatarID.ToString()); | ||
69 | } | ||
70 | |||
71 | public static bool TryGetOpenSimUUID(Uri avatarUri, out UUID avatarID) | ||
72 | { | ||
73 | string[] parts = avatarUri.Segments; | ||
74 | return UUID.TryParse(parts[parts.Length - 1], out avatarID); | ||
75 | } | ||
76 | |||
77 | #region SL / file extension / content-type conversions | ||
78 | |||
79 | public static string SLAssetTypeToContentType(int assetType) | ||
80 | { | ||
81 | switch (assetType) | ||
82 | { | ||
83 | case 0: | ||
84 | return "image/jp2"; | ||
85 | case 1: | ||
86 | return "application/ogg"; | ||
87 | case 2: | ||
88 | return "application/x-metaverse-callingcard"; | ||
89 | case 3: | ||
90 | return "application/x-metaverse-landmark"; | ||
91 | case 5: | ||
92 | return "application/x-metaverse-clothing"; | ||
93 | case 6: | ||
94 | return "application/x-metaverse-primitive"; | ||
95 | case 7: | ||
96 | return "application/x-metaverse-notecard"; | ||
97 | case 8: | ||
98 | return "application/x-metaverse-folder"; | ||
99 | case 10: | ||
100 | return "application/x-metaverse-lsl"; | ||
101 | case 11: | ||
102 | return "application/x-metaverse-lso"; | ||
103 | case 12: | ||
104 | return "image/tga"; | ||
105 | case 13: | ||
106 | return "application/x-metaverse-bodypart"; | ||
107 | case 17: | ||
108 | return "audio/x-wav"; | ||
109 | case 19: | ||
110 | return "image/jpeg"; | ||
111 | case 20: | ||
112 | return "application/x-metaverse-animation"; | ||
113 | case 21: | ||
114 | return "application/x-metaverse-gesture"; | ||
115 | case 22: | ||
116 | return "application/x-metaverse-simstate"; | ||
117 | default: | ||
118 | return "application/octet-stream"; | ||
119 | } | ||
120 | } | ||
121 | |||
122 | public static int ContentTypeToSLAssetType(string contentType) | ||
123 | { | ||
124 | switch (contentType) | ||
125 | { | ||
126 | case "image/jp2": | ||
127 | return 0; | ||
128 | case "application/ogg": | ||
129 | return 1; | ||
130 | case "application/x-metaverse-callingcard": | ||
131 | return 2; | ||
132 | case "application/x-metaverse-landmark": | ||
133 | return 3; | ||
134 | case "application/x-metaverse-clothing": | ||
135 | return 5; | ||
136 | case "application/x-metaverse-primitive": | ||
137 | return 6; | ||
138 | case "application/x-metaverse-notecard": | ||
139 | return 7; | ||
140 | case "application/x-metaverse-lsl": | ||
141 | return 10; | ||
142 | case "application/x-metaverse-lso": | ||
143 | return 11; | ||
144 | case "image/tga": | ||
145 | return 12; | ||
146 | case "application/x-metaverse-bodypart": | ||
147 | return 13; | ||
148 | case "audio/x-wav": | ||
149 | return 17; | ||
150 | case "image/jpeg": | ||
151 | return 19; | ||
152 | case "application/x-metaverse-animation": | ||
153 | return 20; | ||
154 | case "application/x-metaverse-gesture": | ||
155 | return 21; | ||
156 | case "application/x-metaverse-simstate": | ||
157 | return 22; | ||
158 | default: | ||
159 | return -1; | ||
160 | } | ||
161 | } | ||
162 | |||
163 | public static string ContentTypeToExtension(string contentType) | ||
164 | { | ||
165 | switch (contentType) | ||
166 | { | ||
167 | case "image/jp2": | ||
168 | return "texture"; | ||
169 | case "application/ogg": | ||
170 | return "ogg"; | ||
171 | case "application/x-metaverse-callingcard": | ||
172 | return "callingcard"; | ||
173 | case "application/x-metaverse-landmark": | ||
174 | return "landmark"; | ||
175 | case "application/x-metaverse-clothing": | ||
176 | return "clothing"; | ||
177 | case "application/x-metaverse-primitive": | ||
178 | return "primitive"; | ||
179 | case "application/x-metaverse-notecard": | ||
180 | return "notecard"; | ||
181 | case "application/x-metaverse-lsl": | ||
182 | return "lsl"; | ||
183 | case "application/x-metaverse-lso": | ||
184 | return "lso"; | ||
185 | case "image/tga": | ||
186 | return "tga"; | ||
187 | case "application/x-metaverse-bodypart": | ||
188 | return "bodypart"; | ||
189 | case "audio/x-wav": | ||
190 | return "wav"; | ||
191 | case "image/jpeg": | ||
192 | return "jpg"; | ||
193 | case "application/x-metaverse-animation": | ||
194 | return "animation"; | ||
195 | case "application/x-metaverse-gesture": | ||
196 | return "gesture"; | ||
197 | case "application/x-metaverse-simstate": | ||
198 | return "simstate"; | ||
199 | default: | ||
200 | return "bin"; | ||
201 | } | ||
202 | } | ||
203 | |||
204 | public static string ExtensionToContentType(string extension) | ||
205 | { | ||
206 | switch (extension) | ||
207 | { | ||
208 | case "texture": | ||
209 | case "jp2": | ||
210 | case "j2c": | ||
211 | return "image/jp2"; | ||
212 | case "sound": | ||
213 | case "ogg": | ||
214 | return "application/ogg"; | ||
215 | case "callingcard": | ||
216 | return "application/x-metaverse-callingcard"; | ||
217 | case "landmark": | ||
218 | return "application/x-metaverse-landmark"; | ||
219 | case "clothing": | ||
220 | return "application/x-metaverse-clothing"; | ||
221 | case "primitive": | ||
222 | return "application/x-metaverse-primitive"; | ||
223 | case "notecard": | ||
224 | return "application/x-metaverse-notecard"; | ||
225 | case "lsl": | ||
226 | return "application/x-metaverse-lsl"; | ||
227 | case "lso": | ||
228 | return "application/x-metaverse-lso"; | ||
229 | case "tga": | ||
230 | return "image/tga"; | ||
231 | case "bodypart": | ||
232 | return "application/x-metaverse-bodypart"; | ||
233 | case "wav": | ||
234 | return "audio/x-wav"; | ||
235 | case "jpg": | ||
236 | case "jpeg": | ||
237 | return "image/jpeg"; | ||
238 | case "animation": | ||
239 | return "application/x-metaverse-animation"; | ||
240 | case "gesture": | ||
241 | return "application/x-metaverse-gesture"; | ||
242 | case "simstate": | ||
243 | return "application/x-metaverse-simstate"; | ||
244 | case "txt": | ||
245 | return "text/plain"; | ||
246 | case "xml": | ||
247 | return "application/xml"; | ||
248 | default: | ||
249 | return "application/octet-stream"; | ||
250 | } | ||
251 | } | ||
252 | |||
253 | #endregion SL / file extension / content-type conversions | ||
254 | |||
255 | #region XML Serialization | ||
256 | |||
257 | public class GeneratedReader : XmlSerializationReader | ||
258 | { | ||
259 | public object ReadRoot_InventoryFolderBase() | ||
260 | { | ||
261 | Reader.MoveToContent(); | ||
262 | if (Reader.LocalName != "InventoryFolderBase" || Reader.NamespaceURI != "") | ||
263 | throw CreateUnknownNodeException(); | ||
264 | return ReadObject_InventoryFolder(true, true); | ||
265 | } | ||
266 | |||
267 | public object ReadRoot_InventoryItemBase() | ||
268 | { | ||
269 | Reader.MoveToContent(); | ||
270 | if (Reader.LocalName != "InventoryItemBase" || Reader.NamespaceURI != "") | ||
271 | throw CreateUnknownNodeException(); | ||
272 | return ReadObject_InventoryItem(true, true); | ||
273 | } | ||
274 | |||
275 | public object ReadRoot_InventoryCollection() | ||
276 | { | ||
277 | Reader.MoveToContent(); | ||
278 | if (Reader.LocalName != "InventoryCollection" || Reader.NamespaceURI != "") | ||
279 | throw CreateUnknownNodeException(); | ||
280 | return ReadObject_InventoryCollection(true, true); | ||
281 | } | ||
282 | |||
283 | public InventoryFolderWithChildren ReadObject_InventoryFolder(bool isNullable, bool checkType) | ||
284 | { | ||
285 | InventoryFolderWithChildren ob = null; | ||
286 | if (isNullable && ReadNull()) return null; | ||
287 | |||
288 | if (checkType) | ||
289 | { | ||
290 | System.Xml.XmlQualifiedName t = GetXsiType(); | ||
291 | if (t == null) | ||
292 | { } | ||
293 | else if (t.Name != "InventoryFolderBase" || t.Namespace != "") | ||
294 | throw CreateUnknownTypeException(t); | ||
295 | } | ||
296 | |||
297 | ob = (InventoryFolderWithChildren)Activator.CreateInstance(typeof(InventoryFolderWithChildren), true); | ||
298 | |||
299 | Reader.MoveToElement(); | ||
300 | |||
301 | while (Reader.MoveToNextAttribute()) | ||
302 | { | ||
303 | if (IsXmlnsAttribute(Reader.Name)) | ||
304 | { | ||
305 | } | ||
306 | else | ||
307 | { | ||
308 | UnknownNode(ob); | ||
309 | } | ||
310 | } | ||
311 | |||
312 | Reader.MoveToElement(); | ||
313 | Reader.MoveToElement(); | ||
314 | if (Reader.IsEmptyElement) | ||
315 | { | ||
316 | Reader.Skip(); | ||
317 | return ob; | ||
318 | } | ||
319 | |||
320 | Reader.ReadStartElement(); | ||
321 | Reader.MoveToContent(); | ||
322 | |||
323 | bool b0 = false, b1 = false, b2 = false, b3 = false, b4 = false, b5 = false; | ||
324 | |||
325 | while (Reader.NodeType != System.Xml.XmlNodeType.EndElement) | ||
326 | { | ||
327 | if (Reader.NodeType == System.Xml.XmlNodeType.Element) | ||
328 | { | ||
329 | if (Reader.LocalName == "Owner" && Reader.NamespaceURI == "" && !b1) | ||
330 | { | ||
331 | b1 = true; | ||
332 | ob.@Owner = ReadObject_UUID(false, true); | ||
333 | } | ||
334 | else if (Reader.LocalName == "Version" && Reader.NamespaceURI == "" && !b5) | ||
335 | { | ||
336 | b5 = true; | ||
337 | string s6 = Reader.ReadElementString(); | ||
338 | ob.@Version = UInt16.Parse(s6, CultureInfo.InvariantCulture); | ||
339 | } | ||
340 | else if (Reader.LocalName == "ID" && Reader.NamespaceURI == "" && !b3) | ||
341 | { | ||
342 | b3 = true; | ||
343 | ob.@ID = ReadObject_UUID(false, true); | ||
344 | } | ||
345 | else if (Reader.LocalName == "Type" && Reader.NamespaceURI == "" && !b4) | ||
346 | { | ||
347 | b4 = true; | ||
348 | string s7 = Reader.ReadElementString(); | ||
349 | ob.@Type = Int16.Parse(s7, CultureInfo.InvariantCulture); | ||
350 | } | ||
351 | else if (Reader.LocalName == "Name" && Reader.NamespaceURI == "" && !b0) | ||
352 | { | ||
353 | b0 = true; | ||
354 | string s8 = Reader.ReadElementString(); | ||
355 | ob.@Name = s8; | ||
356 | } | ||
357 | else if (Reader.LocalName == "ParentID" && Reader.NamespaceURI == "" && !b2) | ||
358 | { | ||
359 | b2 = true; | ||
360 | ob.@ParentID = ReadObject_UUID(false, true); | ||
361 | } | ||
362 | else | ||
363 | { | ||
364 | UnknownNode(ob); | ||
365 | } | ||
366 | } | ||
367 | else | ||
368 | UnknownNode(ob); | ||
369 | |||
370 | Reader.MoveToContent(); | ||
371 | } | ||
372 | |||
373 | ReadEndElement(); | ||
374 | |||
375 | return ob; | ||
376 | } | ||
377 | |||
378 | public InventoryItemBase ReadObject_InventoryItem(bool isNullable, bool checkType) | ||
379 | { | ||
380 | InventoryItemBase ob = null; | ||
381 | if (isNullable && ReadNull()) return null; | ||
382 | |||
383 | if (checkType) | ||
384 | { | ||
385 | System.Xml.XmlQualifiedName t = GetXsiType(); | ||
386 | if (t == null) | ||
387 | { } | ||
388 | else if (t.Name != "InventoryItemBase" || t.Namespace != "") | ||
389 | throw CreateUnknownTypeException(t); | ||
390 | } | ||
391 | |||
392 | ob = (InventoryItemBase)Activator.CreateInstance(typeof(InventoryItemBase), true); | ||
393 | |||
394 | Reader.MoveToElement(); | ||
395 | |||
396 | while (Reader.MoveToNextAttribute()) | ||
397 | { | ||
398 | if (IsXmlnsAttribute(Reader.Name)) | ||
399 | { | ||
400 | } | ||
401 | else | ||
402 | { | ||
403 | UnknownNode(ob); | ||
404 | } | ||
405 | } | ||
406 | |||
407 | Reader.MoveToElement(); | ||
408 | Reader.MoveToElement(); | ||
409 | if (Reader.IsEmptyElement) | ||
410 | { | ||
411 | Reader.Skip(); | ||
412 | return ob; | ||
413 | } | ||
414 | |||
415 | Reader.ReadStartElement(); | ||
416 | Reader.MoveToContent(); | ||
417 | |||
418 | bool b9 = false, b10 = false, b11 = false, b12 = false, b13 = false, b14 = false, b15 = false, b16 = false, b17 = false, b18 = false, b19 = false, b20 = false, b21 = false, b22 = false, b23 = false, b24 = false, b25 = false, b26 = false, b27 = false, b28 = false; | ||
419 | |||
420 | while (Reader.NodeType != System.Xml.XmlNodeType.EndElement) | ||
421 | { | ||
422 | if (Reader.NodeType == System.Xml.XmlNodeType.Element) | ||
423 | { | ||
424 | if (Reader.LocalName == "GroupPermissions" && Reader.NamespaceURI == "" && !b20) | ||
425 | { | ||
426 | b20 = true; | ||
427 | string s29 = Reader.ReadElementString(); | ||
428 | ob.@GroupPermissions = UInt32.Parse(s29, CultureInfo.InvariantCulture); | ||
429 | } | ||
430 | else if (Reader.LocalName == "AssetType" && Reader.NamespaceURI == "" && !b21) | ||
431 | { | ||
432 | b21 = true; | ||
433 | string s30 = Reader.ReadElementString(); | ||
434 | ob.@AssetType = Int32.Parse(s30, CultureInfo.InvariantCulture); | ||
435 | } | ||
436 | else if (Reader.LocalName == "SalePrice" && Reader.NamespaceURI == "" && !b25) | ||
437 | { | ||
438 | b25 = true; | ||
439 | string s31 = Reader.ReadElementString(); | ||
440 | ob.@SalePrice = Int32.Parse(s31, CultureInfo.InvariantCulture); | ||
441 | } | ||
442 | else if (Reader.LocalName == "AssetID" && Reader.NamespaceURI == "" && !b22) | ||
443 | { | ||
444 | b22 = true; | ||
445 | ob.@AssetID = ReadObject_UUID(false, true); | ||
446 | } | ||
447 | else if (Reader.LocalName == "Folder" && Reader.NamespaceURI == "" && !b11) | ||
448 | { | ||
449 | b11 = true; | ||
450 | ob.@Folder = ReadObject_UUID(false, true); | ||
451 | } | ||
452 | else if (Reader.LocalName == "Name" && Reader.NamespaceURI == "" && !b14) | ||
453 | { | ||
454 | b14 = true; | ||
455 | string s32 = Reader.ReadElementString(); | ||
456 | ob.@Name = s32; | ||
457 | } | ||
458 | else if (Reader.LocalName == "NextPermissions" && Reader.NamespaceURI == "" && !b16) | ||
459 | { | ||
460 | b16 = true; | ||
461 | string s33 = Reader.ReadElementString(); | ||
462 | ob.@NextPermissions = UInt32.Parse(s33, CultureInfo.InvariantCulture); | ||
463 | } | ||
464 | else if (Reader.LocalName == "BasePermissions" && Reader.NamespaceURI == "" && !b18) | ||
465 | { | ||
466 | b18 = true; | ||
467 | string s34 = Reader.ReadElementString(); | ||
468 | ob.@BasePermissions = UInt32.Parse(s34, CultureInfo.InvariantCulture); | ||
469 | } | ||
470 | else if (Reader.LocalName == "ID" && Reader.NamespaceURI == "" && !b9) | ||
471 | { | ||
472 | b9 = true; | ||
473 | ob.@ID = ReadObject_UUID(false, true); | ||
474 | } | ||
475 | else if (Reader.LocalName == "Flags" && Reader.NamespaceURI == "" && !b27) | ||
476 | { | ||
477 | b27 = true; | ||
478 | string s35 = Reader.ReadElementString(); | ||
479 | ob.@Flags = UInt32.Parse(s35, CultureInfo.InvariantCulture); | ||
480 | } | ||
481 | else if (Reader.LocalName == "GroupOwned" && Reader.NamespaceURI == "" && !b24) | ||
482 | { | ||
483 | b24 = true; | ||
484 | string s36 = Reader.ReadElementString(); | ||
485 | ob.@GroupOwned = XmlConvert.ToBoolean(s36); | ||
486 | } | ||
487 | else if (Reader.LocalName == "InvType" && Reader.NamespaceURI == "" && !b10) | ||
488 | { | ||
489 | b10 = true; | ||
490 | string s37 = Reader.ReadElementString(); | ||
491 | ob.@InvType = Int32.Parse(s37, CultureInfo.InvariantCulture); | ||
492 | } | ||
493 | else if (Reader.LocalName == "GroupID" && Reader.NamespaceURI == "" && !b23) | ||
494 | { | ||
495 | b23 = true; | ||
496 | ob.@GroupID = ReadObject_UUID(false, true); | ||
497 | } | ||
498 | else if (Reader.LocalName == "Description" && Reader.NamespaceURI == "" && !b15) | ||
499 | { | ||
500 | b15 = true; | ||
501 | string s38 = Reader.ReadElementString(); | ||
502 | ob.@Description = s38; | ||
503 | } | ||
504 | else if (Reader.LocalName == "CreationDate" && Reader.NamespaceURI == "" && !b28) | ||
505 | { | ||
506 | b28 = true; | ||
507 | string s39 = Reader.ReadElementString(); | ||
508 | ob.@CreationDate = Int32.Parse(s39, CultureInfo.InvariantCulture); | ||
509 | } | ||
510 | else if (Reader.LocalName == "EveryOnePermissions" && Reader.NamespaceURI == "" && !b19) | ||
511 | { | ||
512 | b19 = true; | ||
513 | string s40 = Reader.ReadElementString(); | ||
514 | ob.@EveryOnePermissions = UInt32.Parse(s40, CultureInfo.InvariantCulture); | ||
515 | } | ||
516 | else if (Reader.LocalName == "Creator" && Reader.NamespaceURI == "" && !b13) | ||
517 | { | ||
518 | b13 = true; | ||
519 | ob.@CreatorId = Reader.ReadElementString(); | ||
520 | } | ||
521 | else if (Reader.LocalName == "Owner" && Reader.NamespaceURI == "" && !b12) | ||
522 | { | ||
523 | b12 = true; | ||
524 | ob.@Owner = ReadObject_UUID(false, true); | ||
525 | } | ||
526 | else if (Reader.LocalName == "SaleType" && Reader.NamespaceURI == "" && !b26) | ||
527 | { | ||
528 | b26 = true; | ||
529 | string s41 = Reader.ReadElementString(); | ||
530 | ob.@SaleType = byte.Parse(s41, CultureInfo.InvariantCulture); | ||
531 | } | ||
532 | else if (Reader.LocalName == "CurrentPermissions" && Reader.NamespaceURI == "" && !b17) | ||
533 | { | ||
534 | b17 = true; | ||
535 | string s42 = Reader.ReadElementString(); | ||
536 | ob.@CurrentPermissions = UInt32.Parse(s42, CultureInfo.InvariantCulture); | ||
537 | } | ||
538 | else | ||
539 | { | ||
540 | UnknownNode(ob); | ||
541 | } | ||
542 | } | ||
543 | else | ||
544 | UnknownNode(ob); | ||
545 | |||
546 | Reader.MoveToContent(); | ||
547 | } | ||
548 | |||
549 | ReadEndElement(); | ||
550 | |||
551 | return ob; | ||
552 | } | ||
553 | |||
554 | public InventoryCollection ReadObject_InventoryCollection(bool isNullable, bool checkType) | ||
555 | { | ||
556 | InventoryCollection ob = null; | ||
557 | if (isNullable && ReadNull()) return null; | ||
558 | |||
559 | if (checkType) | ||
560 | { | ||
561 | System.Xml.XmlQualifiedName t = GetXsiType(); | ||
562 | if (t == null) | ||
563 | { } | ||
564 | else if (t.Name != "InventoryCollection" || t.Namespace != "") | ||
565 | throw CreateUnknownTypeException(t); | ||
566 | } | ||
567 | |||
568 | ob = (InventoryCollection)Activator.CreateInstance(typeof(InventoryCollection), true); | ||
569 | |||
570 | Reader.MoveToElement(); | ||
571 | |||
572 | while (Reader.MoveToNextAttribute()) | ||
573 | { | ||
574 | if (IsXmlnsAttribute(Reader.Name)) | ||
575 | { | ||
576 | } | ||
577 | else | ||
578 | { | ||
579 | UnknownNode(ob); | ||
580 | } | ||
581 | } | ||
582 | |||
583 | Reader.MoveToElement(); | ||
584 | Reader.MoveToElement(); | ||
585 | if (Reader.IsEmptyElement) | ||
586 | { | ||
587 | Reader.Skip(); | ||
588 | if (ob.@Folders == null) | ||
589 | { | ||
590 | ob.@Folders = new System.Collections.Generic.Dictionary<UUID, InventoryFolderWithChildren>(); | ||
591 | } | ||
592 | if (ob.@Items == null) | ||
593 | { | ||
594 | ob.@Items = new System.Collections.Generic.Dictionary<UUID, InventoryItemBase>(); | ||
595 | } | ||
596 | return ob; | ||
597 | } | ||
598 | |||
599 | Reader.ReadStartElement(); | ||
600 | Reader.MoveToContent(); | ||
601 | |||
602 | bool b43 = false, b44 = false, b45 = false; | ||
603 | |||
604 | while (Reader.NodeType != System.Xml.XmlNodeType.EndElement) | ||
605 | { | ||
606 | if (Reader.NodeType == System.Xml.XmlNodeType.Element) | ||
607 | { | ||
608 | if (Reader.LocalName == "UserID" && Reader.NamespaceURI == "" && !b45) | ||
609 | { | ||
610 | b45 = true; | ||
611 | ob.@UserID = ReadObject_UUID(false, true); | ||
612 | } | ||
613 | else if (Reader.LocalName == "Items" && Reader.NamespaceURI == "" && !b44) | ||
614 | { | ||
615 | System.Collections.Generic.Dictionary<UUID, InventoryItemBase> o46 = ob.@Items; | ||
616 | if (((object)o46) == null) | ||
617 | { | ||
618 | o46 = new System.Collections.Generic.Dictionary<UUID, InventoryItemBase>(); | ||
619 | ob.@Items = o46; | ||
620 | } | ||
621 | if (Reader.IsEmptyElement) | ||
622 | { | ||
623 | Reader.Skip(); | ||
624 | } | ||
625 | else | ||
626 | { | ||
627 | int n47 = 0; | ||
628 | Reader.ReadStartElement(); | ||
629 | Reader.MoveToContent(); | ||
630 | |||
631 | while (Reader.NodeType != System.Xml.XmlNodeType.EndElement) | ||
632 | { | ||
633 | if (Reader.NodeType == System.Xml.XmlNodeType.Element) | ||
634 | { | ||
635 | if (Reader.LocalName == "InventoryItemBase" && Reader.NamespaceURI == "") | ||
636 | { | ||
637 | if (((object)o46) == null) | ||
638 | throw CreateReadOnlyCollectionException("System.Collections.Generic.List<InventoryItemBase>"); | ||
639 | InventoryItemBase item = ReadObject_InventoryItem(true, true); | ||
640 | o46.Add(item.ID, item); | ||
641 | n47++; | ||
642 | } | ||
643 | else UnknownNode(null); | ||
644 | } | ||
645 | else UnknownNode(null); | ||
646 | |||
647 | Reader.MoveToContent(); | ||
648 | } | ||
649 | ReadEndElement(); | ||
650 | } | ||
651 | b44 = true; | ||
652 | } | ||
653 | else if (Reader.LocalName == "Folders" && Reader.NamespaceURI == "" && !b43) | ||
654 | { | ||
655 | System.Collections.Generic.Dictionary<UUID, InventoryFolderWithChildren> o48 = ob.@Folders; | ||
656 | if (((object)o48) == null) | ||
657 | { | ||
658 | o48 = new System.Collections.Generic.Dictionary<UUID, InventoryFolderWithChildren>(); | ||
659 | ob.@Folders = o48; | ||
660 | } | ||
661 | if (Reader.IsEmptyElement) | ||
662 | { | ||
663 | Reader.Skip(); | ||
664 | } | ||
665 | else | ||
666 | { | ||
667 | int n49 = 0; | ||
668 | Reader.ReadStartElement(); | ||
669 | Reader.MoveToContent(); | ||
670 | |||
671 | while (Reader.NodeType != System.Xml.XmlNodeType.EndElement) | ||
672 | { | ||
673 | if (Reader.NodeType == System.Xml.XmlNodeType.Element) | ||
674 | { | ||
675 | if (Reader.LocalName == "InventoryFolderBase" && Reader.NamespaceURI == "") | ||
676 | { | ||
677 | if (((object)o48) == null) | ||
678 | throw CreateReadOnlyCollectionException("System.Collections.Generic.List<InventoryFolderBase>"); | ||
679 | InventoryFolderWithChildren folder = ReadObject_InventoryFolder(true, true); | ||
680 | o48.Add(folder.ID, folder); | ||
681 | n49++; | ||
682 | } | ||
683 | else UnknownNode(null); | ||
684 | } | ||
685 | else UnknownNode(null); | ||
686 | |||
687 | Reader.MoveToContent(); | ||
688 | } | ||
689 | ReadEndElement(); | ||
690 | } | ||
691 | b43 = true; | ||
692 | } | ||
693 | else | ||
694 | { | ||
695 | UnknownNode(ob); | ||
696 | } | ||
697 | } | ||
698 | else | ||
699 | UnknownNode(ob); | ||
700 | |||
701 | Reader.MoveToContent(); | ||
702 | } | ||
703 | if (ob.@Folders == null) | ||
704 | { | ||
705 | ob.@Folders = new System.Collections.Generic.Dictionary<UUID, InventoryFolderWithChildren>(); | ||
706 | } | ||
707 | if (ob.@Items == null) | ||
708 | { | ||
709 | ob.@Items = new System.Collections.Generic.Dictionary<UUID, InventoryItemBase>(); | ||
710 | } | ||
711 | |||
712 | ReadEndElement(); | ||
713 | |||
714 | return ob; | ||
715 | } | ||
716 | |||
717 | public OpenMetaverse.UUID ReadObject_UUID(bool isNullable, bool checkType) | ||
718 | { | ||
719 | OpenMetaverse.UUID ob = (OpenMetaverse.UUID)Activator.CreateInstance(typeof(OpenMetaverse.UUID), true); | ||
720 | System.Xml.XmlQualifiedName t = GetXsiType(); | ||
721 | if (t == null) | ||
722 | { } | ||
723 | else if (t.Name != "UUID" || t.Namespace != "") | ||
724 | throw CreateUnknownTypeException(t); | ||
725 | |||
726 | Reader.MoveToElement(); | ||
727 | |||
728 | while (Reader.MoveToNextAttribute()) | ||
729 | { | ||
730 | if (IsXmlnsAttribute(Reader.Name)) | ||
731 | { | ||
732 | } | ||
733 | else | ||
734 | { | ||
735 | UnknownNode(ob); | ||
736 | } | ||
737 | } | ||
738 | |||
739 | Reader.MoveToElement(); | ||
740 | Reader.MoveToElement(); | ||
741 | if (Reader.IsEmptyElement) | ||
742 | { | ||
743 | Reader.Skip(); | ||
744 | return ob; | ||
745 | } | ||
746 | |||
747 | Reader.ReadStartElement(); | ||
748 | Reader.MoveToContent(); | ||
749 | |||
750 | bool b52 = false; | ||
751 | |||
752 | while (Reader.NodeType != System.Xml.XmlNodeType.EndElement) | ||
753 | { | ||
754 | if (Reader.NodeType == System.Xml.XmlNodeType.Element) | ||
755 | { | ||
756 | if (Reader.LocalName == "Guid" && Reader.NamespaceURI == "" && !b52) | ||
757 | { | ||
758 | b52 = true; | ||
759 | string s53 = Reader.ReadElementString(); | ||
760 | ob.@Guid = XmlConvert.ToGuid(s53); | ||
761 | } | ||
762 | else | ||
763 | { | ||
764 | UnknownNode(ob); | ||
765 | } | ||
766 | } | ||
767 | else | ||
768 | UnknownNode(ob); | ||
769 | |||
770 | Reader.MoveToContent(); | ||
771 | } | ||
772 | |||
773 | ReadEndElement(); | ||
774 | |||
775 | return ob; | ||
776 | } | ||
777 | |||
778 | protected override void InitCallbacks() | ||
779 | { | ||
780 | } | ||
781 | |||
782 | protected override void InitIDs() | ||
783 | { | ||
784 | } | ||
785 | } | ||
786 | |||
787 | public class GeneratedWriter : XmlSerializationWriter | ||
788 | { | ||
789 | const string xmlNamespace = "http://www.w3.org/2000/xmlns/"; | ||
790 | //static readonly System.Reflection.MethodInfo toBinHexStringMethod = typeof(XmlConvert).GetMethod("ToBinHexString", System.Reflection.BindingFlags.Static | System.Reflection.BindingFlags.NonPublic, null, new Type[] { typeof(byte[]) }, null); | ||
791 | //static string ToBinHexString(byte[] input) | ||
792 | //{ | ||
793 | // return input == null ? null : (string)toBinHexStringMethod.Invoke(null, new object[] { input }); | ||
794 | //} | ||
795 | public void WriteRoot_InventoryFolder(object o) | ||
796 | { | ||
797 | WriteStartDocument(); | ||
798 | InventoryFolderWithChildren ob = (InventoryFolderWithChildren)o; | ||
799 | TopLevelElement(); | ||
800 | WriteObject_InventoryFolder(ob, "InventoryFolderBase", "", true, false, true); | ||
801 | } | ||
802 | |||
803 | public void WriteRoot_InventoryItem(object o) | ||
804 | { | ||
805 | WriteStartDocument(); | ||
806 | InventoryItemBase ob = (InventoryItemBase)o; | ||
807 | TopLevelElement(); | ||
808 | WriteObject_InventoryItem(ob, "InventoryItemBase", "", true, false, true); | ||
809 | } | ||
810 | |||
811 | public void WriteRoot_InventoryCollection(object o) | ||
812 | { | ||
813 | WriteStartDocument(); | ||
814 | InventoryCollection ob = (InventoryCollection)o; | ||
815 | TopLevelElement(); | ||
816 | WriteObject_InventoryCollection(ob, "InventoryCollection", "", true, false, true); | ||
817 | } | ||
818 | |||
819 | void WriteObject_InventoryFolder(InventoryFolderWithChildren ob, string element, string namesp, bool isNullable, bool needType, bool writeWrappingElem) | ||
820 | { | ||
821 | if (((object)ob) == null) | ||
822 | { | ||
823 | if (isNullable) | ||
824 | WriteNullTagLiteral(element, namesp); | ||
825 | return; | ||
826 | } | ||
827 | |||
828 | System.Type type = ob.GetType(); | ||
829 | if (type == typeof(InventoryFolderWithChildren)) | ||
830 | { } | ||
831 | else | ||
832 | { | ||
833 | throw CreateUnknownTypeException(ob); | ||
834 | } | ||
835 | |||
836 | if (writeWrappingElem) | ||
837 | { | ||
838 | WriteStartElement(element, namesp, ob); | ||
839 | } | ||
840 | |||
841 | if (needType) WriteXsiType("InventoryFolderBase", ""); | ||
842 | |||
843 | WriteElementString("Name", "", ob.@Name); | ||
844 | WriteObject_UUID(ob.@Owner, "Owner", "", false, false, true); | ||
845 | WriteObject_UUID(ob.@ParentID, "ParentID", "", false, false, true); | ||
846 | WriteObject_UUID(ob.@ID, "ID", "", false, false, true); | ||
847 | WriteElementString("Type", "", ob.@Type.ToString(CultureInfo.InvariantCulture)); | ||
848 | WriteElementString("Version", "", ob.@Version.ToString(CultureInfo.InvariantCulture)); | ||
849 | if (writeWrappingElem) WriteEndElement(ob); | ||
850 | } | ||
851 | |||
852 | void WriteObject_InventoryItem(InventoryItemBase ob, string element, string namesp, bool isNullable, bool needType, bool writeWrappingElem) | ||
853 | { | ||
854 | if (((object)ob) == null) | ||
855 | { | ||
856 | if (isNullable) | ||
857 | WriteNullTagLiteral(element, namesp); | ||
858 | return; | ||
859 | } | ||
860 | |||
861 | System.Type type = ob.GetType(); | ||
862 | if (type == typeof(InventoryItemBase)) | ||
863 | { } | ||
864 | else | ||
865 | { | ||
866 | throw CreateUnknownTypeException(ob); | ||
867 | } | ||
868 | |||
869 | if (writeWrappingElem) | ||
870 | { | ||
871 | WriteStartElement(element, namesp, ob); | ||
872 | } | ||
873 | |||
874 | if (needType) WriteXsiType("InventoryItemBase", ""); | ||
875 | |||
876 | WriteObject_UUID(ob.@ID, "ID", "", false, false, true); | ||
877 | WriteElementString("InvType", "", ob.@InvType.ToString(CultureInfo.InvariantCulture)); | ||
878 | WriteObject_UUID(ob.@Folder, "Folder", "", false, false, true); | ||
879 | WriteObject_UUID(ob.@Owner, "Owner", "", false, false, true); | ||
880 | WriteElementString("Creator", "", ob.@CreatorId); | ||
881 | WriteElementString("Name", "", ob.@Name); | ||
882 | WriteElementString("Description", "", ob.@Description); | ||
883 | WriteElementString("NextPermissions", "", ob.@NextPermissions.ToString(CultureInfo.InvariantCulture)); | ||
884 | WriteElementString("CurrentPermissions", "", ob.@CurrentPermissions.ToString(CultureInfo.InvariantCulture)); | ||
885 | WriteElementString("BasePermissions", "", ob.@BasePermissions.ToString(CultureInfo.InvariantCulture)); | ||
886 | WriteElementString("EveryOnePermissions", "", ob.@EveryOnePermissions.ToString(CultureInfo.InvariantCulture)); | ||
887 | WriteElementString("GroupPermissions", "", ob.@GroupPermissions.ToString(CultureInfo.InvariantCulture)); | ||
888 | WriteElementString("AssetType", "", ob.@AssetType.ToString(CultureInfo.InvariantCulture)); | ||
889 | WriteObject_UUID(ob.@AssetID, "AssetID", "", false, false, true); | ||
890 | WriteObject_UUID(ob.@GroupID, "GroupID", "", false, false, true); | ||
891 | WriteElementString("GroupOwned", "", (ob.@GroupOwned ? "true" : "false")); | ||
892 | WriteElementString("SalePrice", "", ob.@SalePrice.ToString(CultureInfo.InvariantCulture)); | ||
893 | WriteElementString("SaleType", "", ob.@SaleType.ToString(CultureInfo.InvariantCulture)); | ||
894 | WriteElementString("Flags", "", ob.@Flags.ToString(CultureInfo.InvariantCulture)); | ||
895 | WriteElementString("CreationDate", "", ob.@CreationDate.ToString(CultureInfo.InvariantCulture)); | ||
896 | if (writeWrappingElem) WriteEndElement(ob); | ||
897 | } | ||
898 | |||
899 | void WriteObject_InventoryCollection(InventoryCollection ob, string element, string namesp, bool isNullable, bool needType, bool writeWrappingElem) | ||
900 | { | ||
901 | if (((object)ob) == null) | ||
902 | { | ||
903 | if (isNullable) | ||
904 | WriteNullTagLiteral(element, namesp); | ||
905 | return; | ||
906 | } | ||
907 | |||
908 | System.Type type = ob.GetType(); | ||
909 | if (type == typeof(InventoryCollection)) | ||
910 | { } | ||
911 | else | ||
912 | { | ||
913 | throw CreateUnknownTypeException(ob); | ||
914 | } | ||
915 | |||
916 | if (writeWrappingElem) | ||
917 | { | ||
918 | WriteStartElement(element, namesp, ob); | ||
919 | } | ||
920 | |||
921 | if (needType) WriteXsiType("InventoryCollection", ""); | ||
922 | |||
923 | if (ob.@Folders != null) | ||
924 | { | ||
925 | WriteStartElement("Folders", "", ob.@Folders); | ||
926 | foreach (InventoryFolderWithChildren folder in ob.Folders.Values) | ||
927 | { | ||
928 | WriteObject_InventoryFolder(folder, "InventoryFolderBase", "", true, false, true); | ||
929 | } | ||
930 | WriteEndElement(ob.@Folders); | ||
931 | } | ||
932 | if (ob.@Items != null) | ||
933 | { | ||
934 | WriteStartElement("Items", "", ob.@Items); | ||
935 | foreach (InventoryItemBase item in ob.Items.Values) | ||
936 | { | ||
937 | WriteObject_InventoryItem(item, "InventoryItemBase", "", true, false, true); | ||
938 | } | ||
939 | WriteEndElement(ob.@Items); | ||
940 | } | ||
941 | WriteObject_UUID(ob.@UserID, "UserID", "", false, false, true); | ||
942 | if (writeWrappingElem) WriteEndElement(ob); | ||
943 | } | ||
944 | |||
945 | void WriteObject_UUID(OpenMetaverse.UUID ob, string element, string namesp, bool isNullable, bool needType, bool writeWrappingElem) | ||
946 | { | ||
947 | System.Type type = ob.GetType(); | ||
948 | if (type == typeof(OpenMetaverse.UUID)) | ||
949 | { } | ||
950 | else | ||
951 | { | ||
952 | throw CreateUnknownTypeException(ob); | ||
953 | } | ||
954 | |||
955 | if (writeWrappingElem) | ||
956 | { | ||
957 | WriteStartElement(element, namesp, ob); | ||
958 | } | ||
959 | |||
960 | if (needType) WriteXsiType("UUID", ""); | ||
961 | |||
962 | WriteElementString("Guid", "", XmlConvert.ToString(ob.@Guid)); | ||
963 | if (writeWrappingElem) WriteEndElement(ob); | ||
964 | } | ||
965 | |||
966 | protected override void InitCallbacks() | ||
967 | { | ||
968 | } | ||
969 | |||
970 | } | ||
971 | |||
972 | public class BaseXmlSerializer : System.Xml.Serialization.XmlSerializer | ||
973 | { | ||
974 | protected override System.Xml.Serialization.XmlSerializationReader CreateReader() | ||
975 | { | ||
976 | return new GeneratedReader(); | ||
977 | } | ||
978 | |||
979 | protected override System.Xml.Serialization.XmlSerializationWriter CreateWriter() | ||
980 | { | ||
981 | return new GeneratedWriter(); | ||
982 | } | ||
983 | |||
984 | public override bool CanDeserialize(System.Xml.XmlReader xmlReader) | ||
985 | { | ||
986 | return true; | ||
987 | } | ||
988 | } | ||
989 | |||
990 | public sealed class InventoryFolderSerializer : BaseXmlSerializer | ||
991 | { | ||
992 | protected override void Serialize(object obj, System.Xml.Serialization.XmlSerializationWriter writer) | ||
993 | { | ||
994 | ((GeneratedWriter)writer).WriteRoot_InventoryFolder(obj); | ||
995 | } | ||
996 | |||
997 | protected override object Deserialize(System.Xml.Serialization.XmlSerializationReader reader) | ||
998 | { | ||
999 | return ((GeneratedReader)reader).ReadRoot_InventoryFolderBase(); | ||
1000 | } | ||
1001 | } | ||
1002 | |||
1003 | public sealed class InventoryItemSerializer : BaseXmlSerializer | ||
1004 | { | ||
1005 | protected override void Serialize(object obj, System.Xml.Serialization.XmlSerializationWriter writer) | ||
1006 | { | ||
1007 | ((GeneratedWriter)writer).WriteRoot_InventoryItem(obj); | ||
1008 | } | ||
1009 | |||
1010 | protected override object Deserialize(System.Xml.Serialization.XmlSerializationReader reader) | ||
1011 | { | ||
1012 | return ((GeneratedReader)reader).ReadRoot_InventoryItemBase(); | ||
1013 | } | ||
1014 | } | ||
1015 | |||
1016 | public sealed class InventoryCollectionSerializer : BaseXmlSerializer | ||
1017 | { | ||
1018 | protected override void Serialize(object obj, System.Xml.Serialization.XmlSerializationWriter writer) | ||
1019 | { | ||
1020 | ((GeneratedWriter)writer).WriteRoot_InventoryCollection(obj); | ||
1021 | } | ||
1022 | |||
1023 | protected override object Deserialize(System.Xml.Serialization.XmlSerializationReader reader) | ||
1024 | { | ||
1025 | return ((GeneratedReader)reader).ReadRoot_InventoryCollection(); | ||
1026 | } | ||
1027 | } | ||
1028 | |||
1029 | #endregion XML Serialization | ||
1030 | } | ||
1031 | } | ||
diff --git a/prebuild.xml b/prebuild.xml index ebe5c62..0cf88c3 100644 --- a/prebuild.xml +++ b/prebuild.xml | |||
@@ -987,128 +987,6 @@ | |||
987 | </Files> | 987 | </Files> |
988 | </Project> | 988 | </Project> |
989 | 989 | ||
990 | <Project frameworkVersion="v3_5" name="OpenSim.Grid.AssetInventoryServer" path="OpenSim/Grid/AssetInventoryServer" type="Exe"> | ||
991 | <Configuration name="Debug"> | ||
992 | <Options> | ||
993 | <OutputPath>../../../bin/</OutputPath> | ||
994 | </Options> | ||
995 | </Configuration> | ||
996 | <Configuration name="Release"> | ||
997 | <Options> | ||
998 | <OutputPath>../../../bin/</OutputPath> | ||
999 | </Options> | ||
1000 | </Configuration> | ||
1001 | |||
1002 | <ReferencePath>../../../bin/</ReferencePath> | ||
1003 | <Reference name="System"/> | ||
1004 | <Reference name="System.Xml"/> | ||
1005 | <Reference name="OpenMetaverseTypes"/> | ||
1006 | <Reference name="OpenMetaverse.StructuredData"/> | ||
1007 | <Reference name="OpenSim.Framework"/> | ||
1008 | <Reference name="OpenSim.Framework.Servers"/> | ||
1009 | <Reference name="OpenSim.Framework.Servers.HttpServer"/> | ||
1010 | <Reference name="OpenSim.Framework.Console"/> | ||
1011 | <Reference name="OpenSim.Framework.AssetLoader.Filesystem"/> | ||
1012 | <Reference name="Nini.dll" /> | ||
1013 | <Reference name="log4net"/> | ||
1014 | |||
1015 | <Files> | ||
1016 | <Match pattern="*.cs" recurse="false"/> | ||
1017 | </Files> | ||
1018 | </Project> | ||
1019 | |||
1020 | <Project frameworkVersion="v3_5" name="OpenSim.Grid.AssetInventoryServer.Plugins" path="OpenSim/Grid/AssetInventoryServer/Plugins" type="Library"> | ||
1021 | <Configuration name="Debug"> | ||
1022 | <Options> | ||
1023 | <OutputPath>../../../../bin/</OutputPath> | ||
1024 | </Options> | ||
1025 | </Configuration> | ||
1026 | <Configuration name="Release"> | ||
1027 | <Options> | ||
1028 | <OutputPath>../../../../bin/</OutputPath> | ||
1029 | </Options> | ||
1030 | </Configuration> | ||
1031 | |||
1032 | <ReferencePath>../../../../bin/</ReferencePath> | ||
1033 | <Reference name="System"/> | ||
1034 | <Reference name="System.Xml"/> | ||
1035 | <Reference name="System.Web"/> | ||
1036 | <Reference name="OpenMetaverseTypes"/> | ||
1037 | <Reference name="OpenMetaverse.StructuredData"/> | ||
1038 | <Reference name="OpenSim.Framework"/> | ||
1039 | <Reference name="OpenSim.Framework.Serialization"/> | ||
1040 | <Reference name="OpenSim.Framework.Servers"/> | ||
1041 | <Reference name="OpenSim.Framework.Servers.HttpServer"/> | ||
1042 | <Reference name="OpenSim.Grid.AssetInventoryServer" /> | ||
1043 | <Reference name="log4net"/> | ||
1044 | |||
1045 | <Files> | ||
1046 | <Match pattern="*.cs" recurse="false" /> | ||
1047 | <Match path="Resources" pattern="*.addin.xml" buildAction="EmbeddedResource" recurse="true" /> | ||
1048 | </Files> | ||
1049 | </Project> | ||
1050 | |||
1051 | <Project frameworkVersion="v3_5" name="OpenSim.Grid.AssetInventoryServer.Plugins.Simple" path="OpenSim/Grid/AssetInventoryServer/Plugins/Simple" type="Library"> | ||
1052 | <Configuration name="Debug"> | ||
1053 | <Options> | ||
1054 | <OutputPath>../../../../../bin/</OutputPath> | ||
1055 | </Options> | ||
1056 | </Configuration> | ||
1057 | <Configuration name="Release"> | ||
1058 | <Options> | ||
1059 | <OutputPath>../../../../../bin/</OutputPath> | ||
1060 | </Options> | ||
1061 | </Configuration> | ||
1062 | |||
1063 | <ReferencePath>../../../../../bin/</ReferencePath> | ||
1064 | <Reference name="System"/> | ||
1065 | <Reference name="System.Xml" /> | ||
1066 | <Reference name="OpenMetaverse"/> | ||
1067 | <Reference name="OpenMetaverseTypes"/> | ||
1068 | <Reference name="OpenSim.Framework" /> | ||
1069 | <Reference name="OpenSim.Framework.Servers"/> | ||
1070 | <Reference name="OpenSim.Framework.Servers.HttpServer"/> | ||
1071 | <Reference name="OpenSim.Grid.AssetInventoryServer" /> | ||
1072 | <Reference name="log4net"/> | ||
1073 | |||
1074 | <Files> | ||
1075 | <Match pattern="*.cs" recurse="false" /> | ||
1076 | <Match path="Resources" pattern="*.addin.xml" buildAction="EmbeddedResource" recurse="true" /> | ||
1077 | </Files> | ||
1078 | </Project> | ||
1079 | |||
1080 | <Project frameworkVersion="v3_5" name="OpenSim.Grid.AssetInventoryServer.Plugins.OpenSim" path="OpenSim/Grid/AssetInventoryServer/Plugins/OpenSim" type="Library"> | ||
1081 | <Configuration name="Debug"> | ||
1082 | <Options> | ||
1083 | <OutputPath>../../../../../bin/</OutputPath> | ||
1084 | </Options> | ||
1085 | </Configuration> | ||
1086 | <Configuration name="Release"> | ||
1087 | <Options> | ||
1088 | <OutputPath>../../../../../bin/</OutputPath> | ||
1089 | </Options> | ||
1090 | </Configuration> | ||
1091 | |||
1092 | <ReferencePath>../../../../../bin/</ReferencePath> | ||
1093 | <Reference name="System"/> | ||
1094 | <Reference name="System.Xml" /> | ||
1095 | <Reference name="System.Data" /> | ||
1096 | <Reference name="OpenMetaverseTypes"/> | ||
1097 | <Reference name="OpenSim.Data" /> | ||
1098 | <Reference name="OpenSim.Framework" /> | ||
1099 | <Reference name="OpenSim.Framework.Communications" /> | ||
1100 | <Reference name="OpenSim.Grid.AssetInventoryServer" /> | ||
1101 | <Reference name="OpenSim.Framework.Servers"/> | ||
1102 | <Reference name="OpenSim.Framework.Servers.HttpServer"/> | ||
1103 | <Reference name="log4net"/> | ||
1104 | <Reference name="Nini.dll" /> | ||
1105 | |||
1106 | <Files> | ||
1107 | <Match pattern="*.cs" recurse="false" /> | ||
1108 | <Match path="Resources" pattern="*.addin.xml" buildAction="EmbeddedResource" recurse="true" /> | ||
1109 | </Files> | ||
1110 | </Project> | ||
1111 | |||
1112 | <Project frameworkVersion="v3_5" name="OpenSim.Grid.UserServer.Modules" path="OpenSim/Grid/UserServer.Modules" type="Library"> | 990 | <Project frameworkVersion="v3_5" name="OpenSim.Grid.UserServer.Modules" path="OpenSim/Grid/UserServer.Modules" type="Library"> |
1113 | <Configuration name="Debug"> | 991 | <Configuration name="Debug"> |
1114 | <Options> | 992 | <Options> |