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