diff options
Diffstat (limited to 'OpenSim/Framework')
5 files changed, 73 insertions, 19 deletions
diff --git a/OpenSim/Framework/Communications/Cache/AssetCache.cs b/OpenSim/Framework/Communications/Cache/AssetCache.cs index cbb2a5a..4d2db17 100644 --- a/OpenSim/Framework/Communications/Cache/AssetCache.cs +++ b/OpenSim/Framework/Communications/Cache/AssetCache.cs | |||
@@ -336,7 +336,7 @@ namespace OpenSim.Framework.Communications.Cache | |||
336 | { | 336 | { |
337 | AssetInfo assetInf = new AssetInfo(asset); | 337 | AssetInfo assetInf = new AssetInfo(asset); |
338 | 338 | ||
339 | ProcessReceivedAsset(IsTexture, assetInf); | 339 | ProcessReceivedAsset(IsTexture, assetInf, null); |
340 | 340 | ||
341 | if (!m_memcache.Contains(assetInf.FullID)) | 341 | if (!m_memcache.Contains(assetInf.FullID)) |
342 | { | 342 | { |
@@ -391,11 +391,11 @@ namespace OpenSim.Framework.Communications.Cache | |||
391 | } | 391 | } |
392 | } | 392 | } |
393 | 393 | ||
394 | protected void ProcessReceivedAsset(bool IsTexture, AssetInfo assetInf) | 394 | protected void ProcessReceivedAsset(bool IsTexture, AssetInfo assetInf, IUserService userService) |
395 | { | 395 | { |
396 | if(!IsTexture && assetInf.ContainsReferences && false ) | 396 | if(!IsTexture && assetInf.ContainsReferences && false ) |
397 | { | 397 | { |
398 | assetInf.Data = ProcessAssetData(assetInf.Data); | 398 | assetInf.Data = ProcessAssetData(assetInf.Data, userService ); |
399 | } | 399 | } |
400 | } | 400 | } |
401 | 401 | ||
@@ -554,11 +554,11 @@ namespace OpenSim.Framework.Communications.Cache | |||
554 | } | 554 | } |
555 | } | 555 | } |
556 | 556 | ||
557 | public byte[] ProcessAssetData(byte[] assetData) | 557 | public byte[] ProcessAssetData(byte[] assetData, IUserService userService) |
558 | { | 558 | { |
559 | string data = Encoding.ASCII.GetString(assetData); | 559 | string data = Encoding.ASCII.GetString(assetData); |
560 | 560 | ||
561 | data = ProcessAssetDataString(data, null); | 561 | data = ProcessAssetDataString(data, userService ); |
562 | 562 | ||
563 | return Encoding.ASCII.GetBytes( data ); | 563 | return Encoding.ASCII.GetBytes( data ); |
564 | } | 564 | } |
diff --git a/OpenSim/Framework/Communications/IUserService.cs b/OpenSim/Framework/Communications/IUserService.cs index 38c360a..3c09b40 100644 --- a/OpenSim/Framework/Communications/IUserService.cs +++ b/OpenSim/Framework/Communications/IUserService.cs | |||
@@ -50,6 +50,8 @@ namespace OpenSim.Framework.Communications | |||
50 | 50 | ||
51 | UserProfileData GetUserProfile(Uri uri); | 51 | UserProfileData GetUserProfile(Uri uri); |
52 | 52 | ||
53 | Uri GetUserUri(UserProfileData userProfile); | ||
54 | |||
53 | UserAgentData GetAgentByUUID(UUID userId); | 55 | UserAgentData GetAgentByUUID(UUID userId); |
54 | 56 | ||
55 | void ClearUserAgent(UUID avatarID); | 57 | void ClearUserAgent(UUID avatarID); |
diff --git a/OpenSim/Framework/Communications/Tests/Cache/AssetCacheTests.cs b/OpenSim/Framework/Communications/Tests/Cache/AssetCacheTests.cs index 3779f55..9d9810b 100644 --- a/OpenSim/Framework/Communications/Tests/Cache/AssetCacheTests.cs +++ b/OpenSim/Framework/Communications/Tests/Cache/AssetCacheTests.cs | |||
@@ -108,6 +108,11 @@ namespace OpenSim.Framework.Communications.Tests | |||
108 | return userProfile; | 108 | return userProfile; |
109 | } | 109 | } |
110 | 110 | ||
111 | public Uri GetUserUri(UserProfileData userProfile) | ||
112 | { | ||
113 | throw new NotImplementedException(); | ||
114 | } | ||
115 | |||
111 | public UserAgentData GetAgentByUUID(UUID userId) | 116 | public UserAgentData GetAgentByUUID(UUID userId) |
112 | { | 117 | { |
113 | throw new NotImplementedException(); | 118 | throw new NotImplementedException(); |
diff --git a/OpenSim/Framework/Communications/UserManagerBase.cs b/OpenSim/Framework/Communications/UserManagerBase.cs index b7280d3..155f5cd 100644 --- a/OpenSim/Framework/Communications/UserManagerBase.cs +++ b/OpenSim/Framework/Communications/UserManagerBase.cs | |||
@@ -124,7 +124,7 @@ namespace OpenSim.Framework.Communications | |||
124 | 124 | ||
125 | public UserProfileData GetUserProfile(Uri uri) | 125 | public UserProfileData GetUserProfile(Uri uri) |
126 | { | 126 | { |
127 | throw new System.NotImplementedException(); | 127 | throw new NotImplementedException(); |
128 | } | 128 | } |
129 | 129 | ||
130 | public UserAgentData GetAgentByUUID(UUID userId) | 130 | public UserAgentData GetAgentByUUID(UUID userId) |
@@ -142,6 +142,11 @@ namespace OpenSim.Framework.Communications | |||
142 | return null; | 142 | return null; |
143 | } | 143 | } |
144 | 144 | ||
145 | public Uri GetUserUri(UserProfileData userProfile) | ||
146 | { | ||
147 | throw new NotImplementedException(); | ||
148 | } | ||
149 | |||
145 | // see IUserService | 150 | // see IUserService |
146 | public virtual UserProfileData GetUserProfile(UUID uuid) | 151 | public virtual UserProfileData GetUserProfile(UUID uuid) |
147 | { | 152 | { |
@@ -835,6 +840,5 @@ namespace OpenSim.Framework.Communications | |||
835 | } | 840 | } |
836 | 841 | ||
837 | #endregion | 842 | #endregion |
838 | |||
839 | } | 843 | } |
840 | } | 844 | } |
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; | |||
29 | using System.IO; | 29 | using System.IO; |
30 | using System.Reflection; | 30 | using System.Reflection; |
31 | using System.Text; | 31 | using System.Text; |
32 | using System.Text.RegularExpressions; | ||
32 | using System.Xml; | 33 | using System.Xml; |
33 | using System.Xml.Serialization; | 34 | using System.Xml.Serialization; |
34 | using log4net; | 35 | using 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 |