aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/OpenSim/Framework/Servers
diff options
context:
space:
mode:
authorlbsa712009-04-13 20:04:18 +0000
committerlbsa712009-04-13 20:04:18 +0000
commit29355de6ee01b1f44f32ea45b9c06f636ae9a241 (patch)
tree677fb0c71117a6feaa5891f5c7ceacdd8d2069a6 /OpenSim/Framework/Servers
parent* Remove null reference exception in the J2KDecoderModule's J2K repair routin... (diff)
downloadopensim-SC-29355de6ee01b1f44f32ea45b9c06f636ae9a241.zip
opensim-SC-29355de6ee01b1f44f32ea45b9c06f636ae9a241.tar.gz
opensim-SC-29355de6ee01b1f44f32ea45b9c06f636ae9a241.tar.bz2
opensim-SC-29355de6ee01b1f44f32ea45b9c06f636ae9a241.tar.xz
* Some more experimental work on distributed assets. Nothing hotwired yet.
* Introduced preprocess step in FetchAsset (Might revert this later) * Some minor CCC * Added actual implementation of GetUserProfile( uri ) and the corresponding handler to OGS1. * Introduced non-functioning GetUserUri( userProfile) awaiting user server wireup (this might move elsewhere)
Diffstat (limited to 'OpenSim/Framework/Servers')
-rw-r--r--OpenSim/Framework/Servers/GetAssetStreamHandler.cs67
1 files changed, 55 insertions, 12 deletions
diff --git a/OpenSim/Framework/Servers/GetAssetStreamHandler.cs b/OpenSim/Framework/Servers/GetAssetStreamHandler.cs
index 91d1a28..ffd7ef4 100644
--- a/OpenSim/Framework/Servers/GetAssetStreamHandler.cs
+++ b/OpenSim/Framework/Servers/GetAssetStreamHandler.cs
@@ -29,6 +29,7 @@ using System;
29using System.IO; 29using System.IO;
30using System.Reflection; 30using System.Reflection;
31using System.Text; 31using System.Text;
32using System.Text.RegularExpressions;
32using System.Xml; 33using System.Xml;
33using System.Xml.Serialization; 34using System.Xml.Serialization;
34using log4net; 35using log4net;
@@ -64,9 +65,9 @@ namespace OpenSim.Framework.Servers
64 OSHttpRequest httpRequest, OSHttpResponse httpResponse) 65 OSHttpRequest httpRequest, OSHttpResponse httpResponse)
65 { 66 {
66 string param = GetParam(path); 67 string param = GetParam(path);
67 byte[] result = new byte[] {}; 68 byte[] result = new byte[] { };
68 69
69 string[] p = param.Split(new char[] {'/', '?', '&'}, StringSplitOptions.RemoveEmptyEntries); 70 string[] p = param.Split(new char[] { '/', '?', '&' }, StringSplitOptions.RemoveEmptyEntries);
70 71
71 if (p.Length > 0) 72 if (p.Length > 0)
72 { 73 {
@@ -85,7 +86,12 @@ namespace OpenSim.Framework.Servers
85 AssetBase asset = m_assetProvider.FetchAsset(assetID); 86 AssetBase asset = m_assetProvider.FetchAsset(assetID);
86 if (asset != null) 87 if (asset != null)
87 { 88 {
88 XmlSerializer xs = new XmlSerializer(typeof (AssetBase)); 89 if (asset.ContainsReferences && false)
90 {
91 asset.Data = ProcessOutgoingAssetData(asset.Data);
92 }
93
94 XmlSerializer xs = new XmlSerializer(typeof(AssetBase));
89 MemoryStream ms = new MemoryStream(); 95 MemoryStream ms = new MemoryStream();
90 XmlTextWriter xw = new XmlTextWriter(ms, Encoding.UTF8); 96 XmlTextWriter xw = new XmlTextWriter(ms, Encoding.UTF8);
91 xw.Formatting = Formatting.Indented; 97 xw.Formatting = Formatting.Indented;
@@ -97,15 +103,7 @@ namespace OpenSim.Framework.Servers
97 103
98 result = ms.GetBuffer(); 104 result = ms.GetBuffer();
99 105
100//Ckrinke 1/11/09 Commenting out the succesful REST message as under heavy use there 106 Array.Resize<byte>(ref result, (int)ms.Length);
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 } 107 }
110 else 108 else
111 { 109 {
@@ -118,5 +116,50 @@ namespace OpenSim.Framework.Servers
118 116
119 return result; 117 return result;
120 } 118 }
119
120 private byte[] ProcessOutgoingAssetData(byte[] assetData)
121 {
122 string data = Encoding.ASCII.GetString(assetData);
123
124 data = ProcessAssetDataString(data);
125
126 return Encoding.ASCII.GetBytes(data);
127 }
128
129 public string ProcessAssetDataString(string data)
130 {
131 Regex regex = new Regex("(creator_id|owner_id)\\s+(\\S+)");
132
133 // IUserService userService = null;
134
135 data = regex.Replace(data, delegate(Match m)
136 {
137 string result = String.Empty;
138
139 string key = m.Groups[1].Captures[0].Value;
140
141 string value = m.Groups[2].Captures[0].Value;
142
143 Guid userUri;
144
145 switch (key)
146 {
147 case "creator_id":
148 userUri = new Guid(value);
149 // result = "creator_url " + userService(userService, userUri);
150 break;
151
152 case "owner_id":
153 userUri = new Guid(value);
154 // result = "owner_url " + ResolveUserUri(userService, userUri);
155 break;
156 }
157
158 return result;
159 });
160
161 return data;
162 }
163
121 } 164 }
122} \ No newline at end of file 165} \ No newline at end of file