aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/OpenSim/Framework/Servers/GetAssetStreamHandler.cs
diff options
context:
space:
mode:
authorJeff Ames2009-02-21 03:00:17 +0000
committerJeff Ames2009-02-21 03:00:17 +0000
commitb515645151b1e0b5ac93862a41792914cd86ec82 (patch)
tree40e71bd95f60346ee57dc2674eabbe65cbdcc79c /OpenSim/Framework/Servers/GetAssetStreamHandler.cs
parentThank you, robsmart, for a patch that allows the shard to be set. (diff)
downloadopensim-SC_OLD-b515645151b1e0b5ac93862a41792914cd86ec82.zip
opensim-SC_OLD-b515645151b1e0b5ac93862a41792914cd86ec82.tar.gz
opensim-SC_OLD-b515645151b1e0b5ac93862a41792914cd86ec82.tar.bz2
opensim-SC_OLD-b515645151b1e0b5ac93862a41792914cd86ec82.tar.xz
Update svn properties.
Diffstat (limited to 'OpenSim/Framework/Servers/GetAssetStreamHandler.cs')
-rw-r--r--OpenSim/Framework/Servers/GetAssetStreamHandler.cs188
1 files changed, 94 insertions, 94 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