aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/OpenSim
diff options
context:
space:
mode:
authorlbsa712009-02-19 19:32:53 +0000
committerlbsa712009-02-19 19:32:53 +0000
commitb99d9bdeb1d5177a3dfff1d402d374fbd079ebaa (patch)
treeaa38818eb01549179f0f90322b8cd5c0a249c5d1 /OpenSim
parent* Moved the AssetStreamHandlers to OpenSim.Framework.Servers (diff)
downloadopensim-SC-b99d9bdeb1d5177a3dfff1d402d374fbd079ebaa.zip
opensim-SC-b99d9bdeb1d5177a3dfff1d402d374fbd079ebaa.tar.gz
opensim-SC-b99d9bdeb1d5177a3dfff1d402d374fbd079ebaa.tar.bz2
opensim-SC-b99d9bdeb1d5177a3dfff1d402d374fbd079ebaa.tar.xz
* Reverted the AssetServer fix, apparently something was dependent on IAssetDataPlugin being in OpenSim.Data
Diffstat (limited to 'OpenSim')
-rw-r--r--OpenSim/Data/IAssetData.cs9
-rw-r--r--OpenSim/Framework/Communications/Cache/AssetServerBase.cs1
-rw-r--r--OpenSim/Framework/Communications/Cache/SQLAssetServer.cs1
-rw-r--r--OpenSim/Framework/IAssetDataPlugin.cs41
-rw-r--r--OpenSim/Framework/Servers/PostAssetStreamHandler.cs44
-rw-r--r--OpenSim/Grid/AssetServer/RestService.cs (renamed from OpenSim/Framework/Servers/GetAssetStreamHandler.cs)250
-rw-r--r--OpenSim/Region/CoreModules/Hypergrid/HGStandaloneAssetService.cs2
-rw-r--r--OpenSim/Tests/Common/Mock/TestAssetDataPlugin.cs1
8 files changed, 170 insertions, 179 deletions
diff --git a/OpenSim/Data/IAssetData.cs b/OpenSim/Data/IAssetData.cs
index 0fd5143..47e25f3 100644
--- a/OpenSim/Data/IAssetData.cs
+++ b/OpenSim/Data/IAssetData.cs
@@ -30,6 +30,15 @@ using OpenSim.Framework;
30 30
31namespace OpenSim.Data 31namespace OpenSim.Data
32{ 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
33 public class AssetDataInitialiser : PluginInitialiserBase 42 public class AssetDataInitialiser : PluginInitialiserBase
34 { 43 {
35 private string connect; 44 private string connect;
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;
30using System.Threading; 30using System.Threading;
31using log4net; 31using log4net;
32using OpenMetaverse; 32using OpenMetaverse;
33using OpenSim.Data;
33using OpenSim.Framework.AssetLoader.Filesystem; 34using OpenSim.Framework.AssetLoader.Filesystem;
34using OpenSim.Framework.Statistics; 35using 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 @@
28using System; 28using System;
29using System.Reflection; 29using System.Reflection;
30using log4net; 30using log4net;
31using OpenSim.Data;
31 32
32namespace OpenSim.Framework.Communications.Cache 33namespace 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
28using OpenMetaverse;
29using OpenSim.Framework;
30
31namespace 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/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 @@
1using System.IO;
2using System.Reflection;
3using System.Xml.Serialization;
4using log4net;
5using OpenMetaverse;
6using OpenSim.Framework;
7using OpenSim.Framework.Servers;
8
9namespace 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
diff --git a/OpenSim/Framework/Servers/GetAssetStreamHandler.cs b/OpenSim/Grid/AssetServer/RestService.cs
index 093461d..1e01c44 100644
--- a/OpenSim/Framework/Servers/GetAssetStreamHandler.cs
+++ b/OpenSim/Grid/AssetServer/RestService.cs
@@ -1,94 +1,156 @@
1using System; 1/*
2using System.IO; 2 * Copyright (c) Contributors, http://opensimulator.org/
3using System.Reflection; 3 * See CONTRIBUTORS.TXT for a full list of copyright holders.
4using System.Text; 4 *
5using System.Xml; 5 * Redistribution and use in source and binary forms, with or without
6using System.Xml.Serialization; 6 * modification, are permitted provided that the following conditions are met:
7using log4net; 7 * * Redistributions of source code must retain the above copyright
8using OpenMetaverse; 8 * notice, this list of conditions and the following disclaimer.
9using OpenSim.Framework; 9 * * Redistributions in binary form must reproduce the above copyright
10using OpenSim.Framework.Servers; 10 * notice, this list of conditions and the following disclaimer in the
11using OpenSim.Framework.Statistics; 11 * documentation and/or other materials provided with the distribution.
12 12 * * Neither the name of the OpenSim Project nor the
13namespace OpenSim.Framework.Servers 13 * names of its contributors may be used to endorse or promote products
14{ 14 * derived from this software without specific prior written permission.
15 public class GetAssetStreamHandler : BaseStreamHandler 15 *
16 { 16 * THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS'' AND ANY
17 private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); 17 * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
18 18 * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
19 // private OpenAsset_Main m_assetManager; 19 * DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY
20 private IAssetDataPlugin m_assetProvider; 20 * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
21 21 * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
22 /// <summary> 22 * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
23 /// Constructor. 23 * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
24 /// </summary> 24 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
25 /// <param name="assetManager"></param> 25 * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
26 /// <param name="assetProvider"></param> 26 */
27 public GetAssetStreamHandler(IAssetDataPlugin assetProvider) 27
28 : base("GET", "/assets") 28using System;
29 { 29using System.IO;
30 m_log.Info("[REST]: In Get Request"); 30using System.Reflection;
31 // m_assetManager = assetManager; 31using System.Text;
32 m_assetProvider = assetProvider; 32using System.Xml;
33 } 33using System.Xml.Serialization;
34 34using log4net;
35 public override byte[] Handle(string path, Stream request, 35using OpenMetaverse;
36 OSHttpRequest httpRequest, OSHttpResponse httpResponse) 36using OpenSim.Data;
37 { 37using OpenSim.Framework;
38 string param = GetParam(path); 38using OpenSim.Framework.Servers;
39 byte[] result = new byte[] {}; 39using OpenSim.Framework.Statistics;
40 40
41 string[] p = param.Split(new char[] {'/', '?', '&'}, StringSplitOptions.RemoveEmptyEntries); 41namespace OpenSim.Grid.AssetServer
42 42{
43 if (p.Length > 0) 43 public class GetAssetStreamHandler : BaseStreamHandler
44 { 44 {
45 UUID assetID = UUID.Zero; 45 private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType);
46 46
47 if (!UUID.TryParse(p[0], out assetID)) 47 // private OpenAsset_Main m_assetManager;
48 { 48 private IAssetDataPlugin m_assetProvider;
49 m_log.InfoFormat( 49
50 "[REST]: GET:/asset ignoring request with malformed UUID {0}", p[0]); 50 /// <summary>
51 return result; 51 /// Constructor.
52 } 52 /// </summary>
53 53 /// <param name="assetManager"></param>
54 if (StatsManager.AssetStats != null) 54 /// <param name="assetProvider"></param>
55 StatsManager.AssetStats.AddRequest(); 55 public GetAssetStreamHandler(IAssetDataPlugin assetProvider)
56 56 : base("GET", "/assets")
57 AssetBase asset = m_assetProvider.FetchAsset(assetID); 57 {
58 if (asset != null) 58 m_log.Info("[REST]: In Get Request");
59 { 59 // m_assetManager = assetManager;
60 XmlSerializer xs = new XmlSerializer(typeof (AssetBase)); 60 m_assetProvider = assetProvider;
61 MemoryStream ms = new MemoryStream(); 61 }
62 XmlTextWriter xw = new XmlTextWriter(ms, Encoding.UTF8); 62
63 xw.Formatting = Formatting.Indented; 63 public override byte[] Handle(string path, Stream request,
64 xs.Serialize(xw, asset); 64 OSHttpRequest httpRequest, OSHttpResponse httpResponse)
65 xw.Flush(); 65 {
66 66 string param = GetParam(path);
67 ms.Seek(0, SeekOrigin.Begin); 67 byte[] result = new byte[] {};
68 //StreamReader sr = new StreamReader(ms); 68
69 69 string[] p = param.Split(new char[] {'/', '?', '&'}, StringSplitOptions.RemoveEmptyEntries);
70 result = ms.GetBuffer(); 70
71 71 if (p.Length > 0)
72//Ckrinke 1/11/09 Commenting out the succesful REST message as under heavy use there 72 {
73//are multiple messages in a second and that is usually (in my experience) meaning 73 UUID assetID = UUID.Zero;
74//the logging itself is slowing down the program. Leaving the unsuccesful message 74
75//as we need to know about that path. 75 if (!UUID.TryParse(p[0], out assetID))
76// m_log.InfoFormat( 76 {
77// "[REST]: GET:/asset found {0} with name {1}, size {2} bytes", 77 m_log.InfoFormat(
78// assetID, asset.Name, result.Length); 78 "[REST]: GET:/asset ignoring request with malformed UUID {0}", p[0]);
79 79 return result;
80 Array.Resize<byte>(ref result, (int) ms.Length); 80 }
81 } 81
82 else 82 if (StatsManager.AssetStats != null)
83 { 83 StatsManager.AssetStats.AddRequest();
84 if (StatsManager.AssetStats != null) 84
85 StatsManager.AssetStats.AddNotFoundRequest(); 85 AssetBase asset = m_assetProvider.FetchAsset(assetID);
86 86 if (asset != null)
87 m_log.InfoFormat("[REST]: GET:/asset failed to find {0}", assetID); 87 {
88 } 88 XmlSerializer xs = new XmlSerializer(typeof (AssetBase));
89 } 89 MemoryStream ms = new MemoryStream();
90 90 XmlTextWriter xw = new XmlTextWriter(ms, Encoding.UTF8);
91 return result; 91 xw.Formatting = Formatting.Indented;
92 } 92 xs.Serialize(xw, asset);
93 } 93 xw.Flush();
94} \ No newline at end of file 94
95 ms.Seek(0, SeekOrigin.Begin);
96 //StreamReader sr = new StreamReader(ms);
97
98 result = ms.GetBuffer();
99
100//Ckrinke 1/11/09 Commenting out the succesful REST message as under heavy use there
101//are multiple messages in a second and that is usually (in my experience) meaning
102//the logging itself is slowing down the program. Leaving the unsuccesful message
103//as we need to know about that path.
104// m_log.InfoFormat(
105// "[REST]: GET:/asset found {0} with name {1}, size {2} bytes",
106// assetID, asset.Name, result.Length);
107
108 Array.Resize<byte>(ref result, (int) ms.Length);
109 }
110 else
111 {
112 if (StatsManager.AssetStats != null)
113 StatsManager.AssetStats.AddNotFoundRequest();
114
115 m_log.InfoFormat("[REST]: GET:/asset failed to find {0}", assetID);
116 }
117 }
118
119 return result;
120 }
121 }
122
123 public class PostAssetStreamHandler : BaseStreamHandler
124 {
125 private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType);
126
127 // private OpenAsset_Main m_assetManager;
128 private IAssetDataPlugin m_assetProvider;
129
130 public override byte[] Handle(string path, Stream request,
131 OSHttpRequest httpRequest, OSHttpResponse httpResponse)
132 {
133 string param = GetParam(path);
134
135 UUID assetId;
136 if (param.Length > 0)
137 UUID.TryParse(param, out assetId);
138 // byte[] txBuffer = new byte[4096];
139
140 XmlSerializer xs = new XmlSerializer(typeof (AssetBase));
141 AssetBase asset = (AssetBase) xs.Deserialize(request);
142
143 m_log.InfoFormat("[REST]: Creating asset {0}", asset.FullID);
144 m_assetProvider.CreateAsset(asset);
145
146 return new byte[] {};
147 }
148
149 public PostAssetStreamHandler(IAssetDataPlugin assetProvider)
150 : base("POST", "/assets")
151 {
152 // m_assetManager = assetManager;
153 m_assetProvider = assetProvider;
154 }
155 }
156}
diff --git a/OpenSim/Region/CoreModules/Hypergrid/HGStandaloneAssetService.cs b/OpenSim/Region/CoreModules/Hypergrid/HGStandaloneAssetService.cs
index 369052c..7caa786 100644
--- a/OpenSim/Region/CoreModules/Hypergrid/HGStandaloneAssetService.cs
+++ b/OpenSim/Region/CoreModules/Hypergrid/HGStandaloneAssetService.cs
@@ -30,10 +30,12 @@ using System.Reflection;
30using log4net; 30using log4net;
31using Nini.Config; 31using Nini.Config;
32using OpenMetaverse; 32using OpenMetaverse;
33using OpenSim.Data;
33using OpenSim.Framework; 34using OpenSim.Framework;
34using OpenSim.Framework.Communications; 35using OpenSim.Framework.Communications;
35using OpenSim.Framework.Communications.Cache; 36using OpenSim.Framework.Communications.Cache;
36using OpenSim.Framework.Servers; 37using OpenSim.Framework.Servers;
38using OpenSim.Grid.AssetServer;
37using OpenSim.Region.Framework.Interfaces; 39using OpenSim.Region.Framework.Interfaces;
38using OpenSim.Region.Framework.Scenes; 40using OpenSim.Region.Framework.Scenes;
39 41
diff --git a/OpenSim/Tests/Common/Mock/TestAssetDataPlugin.cs b/OpenSim/Tests/Common/Mock/TestAssetDataPlugin.cs
index 94604d2..fc84eac 100644
--- a/OpenSim/Tests/Common/Mock/TestAssetDataPlugin.cs
+++ b/OpenSim/Tests/Common/Mock/TestAssetDataPlugin.cs
@@ -27,6 +27,7 @@
27 27
28using OpenMetaverse; 28using OpenMetaverse;
29using OpenSim.Framework; 29using OpenSim.Framework;
30using OpenSim.Data;
30 31
31namespace OpenSim.Tests.Common.Mock 32namespace OpenSim.Tests.Common.Mock
32{ 33{