diff options
author | Melanie | 2009-09-17 23:39:58 +0100 |
---|---|---|
committer | Melanie | 2009-09-17 23:39:58 +0100 |
commit | 6779abf7f59e518b0cd18e52dd91a500049dfda6 (patch) | |
tree | 16b33fae811359c5e80f1c2630fba4deb3066006 /OpenSim/Framework/Servers | |
parent | While running a test case I had written to pursue problems with (diff) | |
download | opensim-SC_OLD-6779abf7f59e518b0cd18e52dd91a500049dfda6.zip opensim-SC_OLD-6779abf7f59e518b0cd18e52dd91a500049dfda6.tar.gz opensim-SC_OLD-6779abf7f59e518b0cd18e52dd91a500049dfda6.tar.bz2 opensim-SC_OLD-6779abf7f59e518b0cd18e52dd91a500049dfda6.tar.xz |
Remove The legacy inventory and asset servers. Bump interface version to 6
Diffstat (limited to 'OpenSim/Framework/Servers')
-rw-r--r-- | OpenSim/Framework/Servers/BaseGetAssetStreamHandler.cs | 205 | ||||
-rw-r--r-- | OpenSim/Framework/Servers/GetAssetStreamHandler.cs | 63 | ||||
-rw-r--r-- | OpenSim/Framework/Servers/PostAssetStreamHandler.cs | 72 | ||||
-rw-r--r-- | OpenSim/Framework/Servers/VersionInfo.cs | 2 |
4 files changed, 1 insertions, 341 deletions
diff --git a/OpenSim/Framework/Servers/BaseGetAssetStreamHandler.cs b/OpenSim/Framework/Servers/BaseGetAssetStreamHandler.cs deleted file mode 100644 index 8372ae7..0000000 --- a/OpenSim/Framework/Servers/BaseGetAssetStreamHandler.cs +++ /dev/null | |||
@@ -1,205 +0,0 @@ | |||
1 | /* | ||
2 | * Copyright (c) Contributors, http://opensimulator.org/ | ||
3 | * See CONTRIBUTORS.TXT for a full list of copyright holders. | ||
4 | * | ||
5 | * Redistribution and use in source and binary forms, with or without | ||
6 | * modification, are permitted provided that the following conditions are met: | ||
7 | * * Redistributions of source code must retain the above copyright | ||
8 | * notice, this list of conditions and the following disclaimer. | ||
9 | * * Redistributions in binary form must reproduce the above copyright | ||
10 | * notice, this list of conditions and the following disclaimer in the | ||
11 | * documentation and/or other materials provided with the distribution. | ||
12 | * * Neither the name of the OpenSimulator Project nor the | ||
13 | * names of its contributors may be used to endorse or promote products | ||
14 | * derived from this software without specific prior written permission. | ||
15 | * | ||
16 | * THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS'' AND ANY | ||
17 | * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED | ||
18 | * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE | ||
19 | * DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY | ||
20 | * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES | ||
21 | * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; | ||
22 | * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND | ||
23 | * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT | ||
24 | * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS | ||
25 | * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | ||
26 | */ | ||
27 | |||
28 | using System; | ||
29 | using System.Collections.Generic; | ||
30 | using System.IO; | ||
31 | using System.Net; | ||
32 | using System.Reflection; | ||
33 | using System.Text; | ||
34 | using System.Text.RegularExpressions; | ||
35 | using System.Xml; | ||
36 | using System.Xml.Serialization; | ||
37 | using log4net; | ||
38 | using OpenMetaverse; | ||
39 | using OpenSim.Framework.Servers.HttpServer; | ||
40 | using OpenSim.Framework.Statistics; | ||
41 | |||
42 | namespace OpenSim.Framework.Servers | ||
43 | { | ||
44 | public abstract class BaseGetAssetStreamHandler : BaseStreamHandler | ||
45 | { | ||
46 | private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); | ||
47 | |||
48 | protected BaseGetAssetStreamHandler(string httpMethod, string path) : base(httpMethod, path) | ||
49 | { | ||
50 | } | ||
51 | |||
52 | protected abstract AssetBase GetAsset(UUID assetID); | ||
53 | |||
54 | public override byte[] Handle(string path, Stream request, | ||
55 | OSHttpRequest httpRequest, OSHttpResponse httpResponse) | ||
56 | { | ||
57 | byte[] result = new byte[] { }; | ||
58 | |||
59 | string[] p = SplitParams(path); | ||
60 | |||
61 | if (p.Length > 0) | ||
62 | { | ||
63 | UUID assetID; | ||
64 | |||
65 | if (!UUID.TryParse(p[0], out assetID)) | ||
66 | { | ||
67 | m_log.DebugFormat( | ||
68 | "[REST]: GET:/asset ignoring request with malformed UUID {0}", p[0]); | ||
69 | return result; | ||
70 | } | ||
71 | |||
72 | if (StatsManager.AssetStats != null) | ||
73 | { | ||
74 | StatsManager.AssetStats.AddRequest(); | ||
75 | } | ||
76 | |||
77 | AssetBase asset = GetAsset(assetID); | ||
78 | |||
79 | if (asset != null) | ||
80 | { | ||
81 | if (p.Length > 1 && p[1] == "data") | ||
82 | { | ||
83 | httpResponse.StatusCode = (int)HttpStatusCode.OK; | ||
84 | httpResponse.ContentType = SLAssetTypeToContentType(asset.Type); | ||
85 | result = asset.Data; | ||
86 | } | ||
87 | else | ||
88 | { | ||
89 | result = GetXml(asset); | ||
90 | } | ||
91 | } | ||
92 | else | ||
93 | { | ||
94 | m_log.DebugFormat("[REST]: GET:/asset failed to find {0}", assetID); | ||
95 | |||
96 | httpResponse.StatusCode = (int)HttpStatusCode.NotFound; | ||
97 | |||
98 | if (StatsManager.AssetStats != null) | ||
99 | { | ||
100 | StatsManager.AssetStats.AddNotFoundRequest(); | ||
101 | } | ||
102 | } | ||
103 | } | ||
104 | |||
105 | return result; | ||
106 | } | ||
107 | |||
108 | public static byte[] GetXml(AssetBase asset) | ||
109 | { | ||
110 | byte[] result; | ||
111 | XmlSerializer xs = new XmlSerializer(typeof(AssetBase)); | ||
112 | MemoryStream ms = new MemoryStream(); | ||
113 | XmlTextWriter xw = new XmlTextWriter(ms, Encoding.UTF8); | ||
114 | xw.Formatting = Formatting.Indented; | ||
115 | xs.Serialize(xw, asset); | ||
116 | xw.Flush(); | ||
117 | |||
118 | ms.Seek(0, SeekOrigin.Begin); | ||
119 | //StreamReader sr = new StreamReader(ms); | ||
120 | |||
121 | result = ms.GetBuffer(); | ||
122 | |||
123 | Array.Resize<byte>(ref result, (int)ms.Length); | ||
124 | return result; | ||
125 | } | ||
126 | |||
127 | public string ProcessAssetDataString(string data) | ||
128 | { | ||
129 | Regex regex = new Regex("(creator_id|owner_id)\\s+(\\S+)"); | ||
130 | |||
131 | // IUserService userService = null; | ||
132 | |||
133 | data = regex.Replace(data, delegate(Match m) | ||
134 | { | ||
135 | string result = String.Empty; | ||
136 | |||
137 | // string key = m.Groups[1].Captures[0].Value; | ||
138 | // | ||
139 | // string value = m.Groups[2].Captures[0].Value; | ||
140 | // | ||
141 | // Guid userUri; | ||
142 | // | ||
143 | // switch (key) | ||
144 | // { | ||
145 | // case "creator_id": | ||
146 | // userUri = new Guid(value); | ||
147 | // // result = "creator_url " + userService(userService, userUri); | ||
148 | // break; | ||
149 | // | ||
150 | // case "owner_id": | ||
151 | // userUri = new Guid(value); | ||
152 | // // result = "owner_url " + ResolveUserUri(userService, userUri); | ||
153 | // break; | ||
154 | // } | ||
155 | |||
156 | return result; | ||
157 | }); | ||
158 | |||
159 | return data; | ||
160 | } | ||
161 | |||
162 | private string SLAssetTypeToContentType(int assetType) | ||
163 | { | ||
164 | switch (assetType) | ||
165 | { | ||
166 | case 0: | ||
167 | return "image/jp2"; | ||
168 | case 1: | ||
169 | return "application/ogg"; | ||
170 | case 2: | ||
171 | return "application/x-metaverse-callingcard"; | ||
172 | case 3: | ||
173 | return "application/x-metaverse-landmark"; | ||
174 | case 5: | ||
175 | return "application/x-metaverse-clothing"; | ||
176 | case 6: | ||
177 | return "application/x-metaverse-primitive"; | ||
178 | case 7: | ||
179 | return "application/x-metaverse-notecard"; | ||
180 | case 8: | ||
181 | return "application/x-metaverse-folder"; | ||
182 | case 10: | ||
183 | return "application/x-metaverse-lsl"; | ||
184 | case 11: | ||
185 | return "application/x-metaverse-lso"; | ||
186 | case 12: | ||
187 | return "image/tga"; | ||
188 | case 13: | ||
189 | return "application/x-metaverse-bodypart"; | ||
190 | case 17: | ||
191 | return "audio/x-wav"; | ||
192 | case 19: | ||
193 | return "image/jpeg"; | ||
194 | case 20: | ||
195 | return "application/x-metaverse-animation"; | ||
196 | case 21: | ||
197 | return "application/x-metaverse-gesture"; | ||
198 | case 22: | ||
199 | return "application/x-metaverse-simstate"; | ||
200 | default: | ||
201 | return "application/octet-stream"; | ||
202 | } | ||
203 | } | ||
204 | } | ||
205 | } | ||
diff --git a/OpenSim/Framework/Servers/GetAssetStreamHandler.cs b/OpenSim/Framework/Servers/GetAssetStreamHandler.cs deleted file mode 100644 index c6958de..0000000 --- a/OpenSim/Framework/Servers/GetAssetStreamHandler.cs +++ /dev/null | |||
@@ -1,63 +0,0 @@ | |||
1 | /* | ||
2 | * Copyright (c) Contributors, http://opensimulator.org/ | ||
3 | * See CONTRIBUTORS.TXT for a full list of copyright holders. | ||
4 | * | ||
5 | * Redistribution and use in source and binary forms, with or without | ||
6 | * modification, are permitted provided that the following conditions are met: | ||
7 | * * Redistributions of source code must retain the above copyright | ||
8 | * notice, this list of conditions and the following disclaimer. | ||
9 | * * Redistributions in binary form must reproduce the above copyright | ||
10 | * notice, this list of conditions and the following disclaimer in the | ||
11 | * documentation and/or other materials provided with the distribution. | ||
12 | * * Neither the name of the OpenSimulator Project nor the | ||
13 | * names of its contributors may be used to endorse or promote products | ||
14 | * derived from this software without specific prior written permission. | ||
15 | * | ||
16 | * THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS'' AND ANY | ||
17 | * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED | ||
18 | * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE | ||
19 | * DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY | ||
20 | * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES | ||
21 | * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; | ||
22 | * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND | ||
23 | * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT | ||
24 | * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS | ||
25 | * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | ||
26 | */ | ||
27 | |||
28 | using System; | ||
29 | using System.IO; | ||
30 | using System.Reflection; | ||
31 | using System.Text; | ||
32 | using System.Text.RegularExpressions; | ||
33 | using System.Xml; | ||
34 | using System.Xml.Serialization; | ||
35 | using log4net; | ||
36 | using OpenMetaverse; | ||
37 | using OpenSim.Data; | ||
38 | using OpenSim.Framework; | ||
39 | using OpenSim.Framework.Servers; | ||
40 | using OpenSim.Framework.Servers.HttpServer; | ||
41 | using OpenSim.Framework.Statistics; | ||
42 | using System.Net; | ||
43 | |||
44 | namespace OpenSim.Framework.Servers | ||
45 | { | ||
46 | public class GetAssetStreamHandler : BaseGetAssetStreamHandler | ||
47 | { | ||
48 | // private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); | ||
49 | |||
50 | private readonly IAssetDataPlugin m_assetProvider; | ||
51 | |||
52 | public GetAssetStreamHandler(IAssetDataPlugin assetProvider) | ||
53 | : base("GET", "/assets") | ||
54 | { | ||
55 | m_assetProvider = assetProvider; | ||
56 | } | ||
57 | |||
58 | protected override AssetBase GetAsset(UUID assetID) | ||
59 | { | ||
60 | return m_assetProvider.GetAsset(assetID); | ||
61 | } | ||
62 | } | ||
63 | } | ||
diff --git a/OpenSim/Framework/Servers/PostAssetStreamHandler.cs b/OpenSim/Framework/Servers/PostAssetStreamHandler.cs deleted file mode 100644 index 8bf406c..0000000 --- a/OpenSim/Framework/Servers/PostAssetStreamHandler.cs +++ /dev/null | |||
@@ -1,72 +0,0 @@ | |||
1 | /* | ||
2 | * Copyright (c) Contributors, http://opensimulator.org/ | ||
3 | * See CONTRIBUTORS.TXT for a full list of copyright holders. | ||
4 | * | ||
5 | * Redistribution and use in source and binary forms, with or without | ||
6 | * modification, are permitted provided that the following conditions are met: | ||
7 | * * Redistributions of source code must retain the above copyright | ||
8 | * notice, this list of conditions and the following disclaimer. | ||
9 | * * Redistributions in binary form must reproduce the above copyright | ||
10 | * notice, this list of conditions and the following disclaimer in the | ||
11 | * documentation and/or other materials provided with the distribution. | ||
12 | * * Neither the name of the OpenSimulator Project nor the | ||
13 | * names of its contributors may be used to endorse or promote products | ||
14 | * derived from this software without specific prior written permission. | ||
15 | * | ||
16 | * THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS'' AND ANY | ||
17 | * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED | ||
18 | * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE | ||
19 | * DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY | ||
20 | * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES | ||
21 | * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; | ||
22 | * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND | ||
23 | * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT | ||
24 | * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS | ||
25 | * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | ||
26 | */ | ||
27 | |||
28 | using System.IO; | ||
29 | using System.Reflection; | ||
30 | using System.Xml.Serialization; | ||
31 | using log4net; | ||
32 | using OpenMetaverse; | ||
33 | using OpenSim.Data; | ||
34 | using OpenSim.Framework; | ||
35 | using OpenSim.Framework.Servers.HttpServer; | ||
36 | |||
37 | namespace OpenSim.Framework.Servers | ||
38 | { | ||
39 | public class PostAssetStreamHandler : BaseStreamHandler | ||
40 | { | ||
41 | private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); | ||
42 | |||
43 | // private OpenAsset_Main m_assetManager; | ||
44 | private IAssetDataPlugin m_assetProvider; | ||
45 | |||
46 | public override byte[] Handle(string path, Stream request, | ||
47 | OSHttpRequest httpRequest, OSHttpResponse httpResponse) | ||
48 | { | ||
49 | string param = GetParam(path); | ||
50 | |||
51 | UUID assetId; | ||
52 | if (param.Length > 0) | ||
53 | UUID.TryParse(param, out assetId); | ||
54 | // byte[] txBuffer = new byte[4096]; | ||
55 | |||
56 | XmlSerializer xs = new XmlSerializer(typeof (AssetBase)); | ||
57 | AssetBase asset = (AssetBase) xs.Deserialize(request); | ||
58 | |||
59 | m_log.InfoFormat("[REST]: Creating asset {0}", asset.FullID); | ||
60 | m_assetProvider.StoreAsset(asset); | ||
61 | |||
62 | return new byte[] {}; | ||
63 | } | ||
64 | |||
65 | public PostAssetStreamHandler(IAssetDataPlugin assetProvider) | ||
66 | : base("POST", "/assets") | ||
67 | { | ||
68 | // m_assetManager = assetManager; | ||
69 | m_assetProvider = assetProvider; | ||
70 | } | ||
71 | } | ||
72 | } | ||
diff --git a/OpenSim/Framework/Servers/VersionInfo.cs b/OpenSim/Framework/Servers/VersionInfo.cs index 743ca69..6f9b00c 100644 --- a/OpenSim/Framework/Servers/VersionInfo.cs +++ b/OpenSim/Framework/Servers/VersionInfo.cs | |||
@@ -69,6 +69,6 @@ namespace OpenSim | |||
69 | /// of the code that is too old. | 69 | /// of the code that is too old. |
70 | /// | 70 | /// |
71 | /// </value> | 71 | /// </value> |
72 | public readonly static int MajorInterfaceVersion = 5; | 72 | public readonly static int MajorInterfaceVersion = 6; |
73 | } | 73 | } |
74 | } | 74 | } |