diff options
Diffstat (limited to 'OpenSim/Framework')
5 files changed, 2 insertions, 179 deletions
diff --git a/OpenSim/Framework/Communications/Cache/AssetServerBase.cs b/OpenSim/Framework/Communications/Cache/AssetServerBase.cs index 91e8720..7bb2ab9 100644 --- a/OpenSim/Framework/Communications/Cache/AssetServerBase.cs +++ b/OpenSim/Framework/Communications/Cache/AssetServerBase.cs | |||
@@ -30,6 +30,7 @@ using System.Reflection; | |||
30 | using System.Threading; | 30 | using System.Threading; |
31 | using log4net; | 31 | using log4net; |
32 | using OpenMetaverse; | 32 | using OpenMetaverse; |
33 | using OpenSim.Data; | ||
33 | using OpenSim.Framework.AssetLoader.Filesystem; | 34 | using OpenSim.Framework.AssetLoader.Filesystem; |
34 | using OpenSim.Framework.Statistics; | 35 | using OpenSim.Framework.Statistics; |
35 | 36 | ||
diff --git a/OpenSim/Framework/Communications/Cache/SQLAssetServer.cs b/OpenSim/Framework/Communications/Cache/SQLAssetServer.cs index 1306ef4..5274288 100644 --- a/OpenSim/Framework/Communications/Cache/SQLAssetServer.cs +++ b/OpenSim/Framework/Communications/Cache/SQLAssetServer.cs | |||
@@ -28,6 +28,7 @@ | |||
28 | using System; | 28 | using System; |
29 | using System.Reflection; | 29 | using System.Reflection; |
30 | using log4net; | 30 | using log4net; |
31 | using OpenSim.Data; | ||
31 | 32 | ||
32 | namespace OpenSim.Framework.Communications.Cache | 33 | namespace OpenSim.Framework.Communications.Cache |
33 | { | 34 | { |
diff --git a/OpenSim/Framework/IAssetDataPlugin.cs b/OpenSim/Framework/IAssetDataPlugin.cs deleted file mode 100644 index 6bb8574..0000000 --- a/OpenSim/Framework/IAssetDataPlugin.cs +++ /dev/null | |||
@@ -1,41 +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 OpenSim 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 | |||
31 | namespace OpenSim.Framework | ||
32 | { | ||
33 | public interface IAssetDataPlugin : IPlugin | ||
34 | { | ||
35 | AssetBase FetchAsset(UUID uuid); | ||
36 | void CreateAsset(AssetBase asset); | ||
37 | void UpdateAsset(AssetBase asset); | ||
38 | bool ExistsAsset(UUID uuid); | ||
39 | void Initialise(string connect); | ||
40 | } | ||
41 | } \ No newline at end of file | ||
diff --git a/OpenSim/Framework/Servers/GetAssetStreamHandler.cs b/OpenSim/Framework/Servers/GetAssetStreamHandler.cs deleted file mode 100644 index 093461d..0000000 --- a/OpenSim/Framework/Servers/GetAssetStreamHandler.cs +++ /dev/null | |||
@@ -1,94 +0,0 @@ | |||
1 | using System; | ||
2 | using System.IO; | ||
3 | using System.Reflection; | ||
4 | using System.Text; | ||
5 | using System.Xml; | ||
6 | using System.Xml.Serialization; | ||
7 | using log4net; | ||
8 | using OpenMetaverse; | ||
9 | using OpenSim.Framework; | ||
10 | using OpenSim.Framework.Servers; | ||
11 | using OpenSim.Framework.Statistics; | ||
12 | |||
13 | namespace OpenSim.Framework.Servers | ||
14 | { | ||
15 | public class GetAssetStreamHandler : BaseStreamHandler | ||
16 | { | ||
17 | private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); | ||
18 | |||
19 | // private OpenAsset_Main m_assetManager; | ||
20 | private IAssetDataPlugin m_assetProvider; | ||
21 | |||
22 | /// <summary> | ||
23 | /// Constructor. | ||
24 | /// </summary> | ||
25 | /// <param name="assetManager"></param> | ||
26 | /// <param name="assetProvider"></param> | ||
27 | public GetAssetStreamHandler(IAssetDataPlugin assetProvider) | ||
28 | : base("GET", "/assets") | ||
29 | { | ||
30 | m_log.Info("[REST]: In Get Request"); | ||
31 | // m_assetManager = assetManager; | ||
32 | m_assetProvider = assetProvider; | ||
33 | } | ||
34 | |||
35 | public override byte[] Handle(string path, Stream request, | ||
36 | OSHttpRequest httpRequest, OSHttpResponse httpResponse) | ||
37 | { | ||
38 | string param = GetParam(path); | ||
39 | byte[] result = new byte[] {}; | ||
40 | |||
41 | string[] p = param.Split(new char[] {'/', '?', '&'}, StringSplitOptions.RemoveEmptyEntries); | ||
42 | |||
43 | if (p.Length > 0) | ||
44 | { | ||
45 | UUID assetID = UUID.Zero; | ||
46 | |||
47 | if (!UUID.TryParse(p[0], out assetID)) | ||
48 | { | ||
49 | m_log.InfoFormat( | ||
50 | "[REST]: GET:/asset ignoring request with malformed UUID {0}", p[0]); | ||
51 | return result; | ||
52 | } | ||
53 | |||
54 | if (StatsManager.AssetStats != null) | ||
55 | StatsManager.AssetStats.AddRequest(); | ||
56 | |||
57 | AssetBase asset = m_assetProvider.FetchAsset(assetID); | ||
58 | if (asset != null) | ||
59 | { | ||
60 | XmlSerializer xs = new XmlSerializer(typeof (AssetBase)); | ||
61 | MemoryStream ms = new MemoryStream(); | ||
62 | XmlTextWriter xw = new XmlTextWriter(ms, Encoding.UTF8); | ||
63 | xw.Formatting = Formatting.Indented; | ||
64 | xs.Serialize(xw, asset); | ||
65 | xw.Flush(); | ||
66 | |||
67 | ms.Seek(0, SeekOrigin.Begin); | ||
68 | //StreamReader sr = new StreamReader(ms); | ||
69 | |||
70 | result = ms.GetBuffer(); | ||
71 | |||
72 | //Ckrinke 1/11/09 Commenting out the succesful REST message as under heavy use there | ||
73 | //are multiple messages in a second and that is usually (in my experience) meaning | ||
74 | //the logging itself is slowing down the program. Leaving the unsuccesful message | ||
75 | //as we need to know about that path. | ||
76 | // m_log.InfoFormat( | ||
77 | // "[REST]: GET:/asset found {0} with name {1}, size {2} bytes", | ||
78 | // assetID, asset.Name, result.Length); | ||
79 | |||
80 | Array.Resize<byte>(ref result, (int) ms.Length); | ||
81 | } | ||
82 | else | ||
83 | { | ||
84 | if (StatsManager.AssetStats != null) | ||
85 | StatsManager.AssetStats.AddNotFoundRequest(); | ||
86 | |||
87 | m_log.InfoFormat("[REST]: GET:/asset failed to find {0}", assetID); | ||
88 | } | ||
89 | } | ||
90 | |||
91 | return result; | ||
92 | } | ||
93 | } | ||
94 | } \ No newline at end of file | ||
diff --git a/OpenSim/Framework/Servers/PostAssetStreamHandler.cs b/OpenSim/Framework/Servers/PostAssetStreamHandler.cs deleted file mode 100644 index a62f2b0..0000000 --- a/OpenSim/Framework/Servers/PostAssetStreamHandler.cs +++ /dev/null | |||
@@ -1,44 +0,0 @@ | |||
1 | using System.IO; | ||
2 | using System.Reflection; | ||
3 | using System.Xml.Serialization; | ||
4 | using log4net; | ||
5 | using OpenMetaverse; | ||
6 | using OpenSim.Framework; | ||
7 | using OpenSim.Framework.Servers; | ||
8 | |||
9 | namespace OpenSim.Framework.Servers | ||
10 | { | ||
11 | public class PostAssetStreamHandler : BaseStreamHandler | ||
12 | { | ||
13 | private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); | ||
14 | |||
15 | // private OpenAsset_Main m_assetManager; | ||
16 | private IAssetDataPlugin m_assetProvider; | ||
17 | |||
18 | public override byte[] Handle(string path, Stream request, | ||
19 | OSHttpRequest httpRequest, OSHttpResponse httpResponse) | ||
20 | { | ||
21 | string param = GetParam(path); | ||
22 | |||
23 | UUID assetId; | ||
24 | if (param.Length > 0) | ||
25 | UUID.TryParse(param, out assetId); | ||
26 | // byte[] txBuffer = new byte[4096]; | ||
27 | |||
28 | XmlSerializer xs = new XmlSerializer(typeof (AssetBase)); | ||
29 | AssetBase asset = (AssetBase) xs.Deserialize(request); | ||
30 | |||
31 | m_log.InfoFormat("[REST]: Creating asset {0}", asset.FullID); | ||
32 | m_assetProvider.CreateAsset(asset); | ||
33 | |||
34 | return new byte[] {}; | ||
35 | } | ||
36 | |||
37 | public PostAssetStreamHandler(IAssetDataPlugin assetProvider) | ||
38 | : base("POST", "/assets") | ||
39 | { | ||
40 | // m_assetManager = assetManager; | ||
41 | m_assetProvider = assetProvider; | ||
42 | } | ||
43 | } | ||
44 | } \ No newline at end of file | ||