diff options
author | Melanie | 2010-04-19 07:00:40 +0100 |
---|---|---|
committer | Melanie | 2010-04-19 07:00:40 +0100 |
commit | 98cb4f74b265dfb8ca3eb8c8d3ad604249398df1 (patch) | |
tree | 1339d3707430a20662bdcd3eb4e9ef86abc6a4fd /OpenSim/Services/Connectors/SimianGrid | |
parent | Merge branch 'master' into careminster-presence-refactor (diff) | |
parent | All scripts are now created suspended and are only unsuspended when the object (diff) | |
download | opensim-SC-98cb4f74b265dfb8ca3eb8c8d3ad604249398df1.zip opensim-SC-98cb4f74b265dfb8ca3eb8c8d3ad604249398df1.tar.gz opensim-SC-98cb4f74b265dfb8ca3eb8c8d3ad604249398df1.tar.bz2 opensim-SC-98cb4f74b265dfb8ca3eb8c8d3ad604249398df1.tar.xz |
Merge branch 'master' into careminster-presence-refactor
Diffstat (limited to 'OpenSim/Services/Connectors/SimianGrid')
-rw-r--r-- | OpenSim/Services/Connectors/SimianGrid/SimianAssetServiceConnector.cs | 113 | ||||
-rw-r--r-- | OpenSim/Services/Connectors/SimianGrid/SimianInventoryServiceConnector.cs | 12 |
2 files changed, 76 insertions, 49 deletions
diff --git a/OpenSim/Services/Connectors/SimianGrid/SimianAssetServiceConnector.cs b/OpenSim/Services/Connectors/SimianGrid/SimianAssetServiceConnector.cs index 17febf9..79e49a1 100644 --- a/OpenSim/Services/Connectors/SimianGrid/SimianAssetServiceConnector.cs +++ b/OpenSim/Services/Connectors/SimianGrid/SimianAssetServiceConnector.cs | |||
@@ -112,59 +112,23 @@ namespace OpenSim.Services.Connectors.SimianGrid | |||
112 | 112 | ||
113 | public AssetBase Get(string id) | 113 | public AssetBase Get(string id) |
114 | { | 114 | { |
115 | AssetBase asset = null; | ||
116 | |||
117 | // Cache fetch | 115 | // Cache fetch |
118 | if (m_cache != null) | 116 | if (m_cache != null) |
119 | { | 117 | { |
120 | asset = m_cache.Get(id); | 118 | AssetBase asset = m_cache.Get(id); |
121 | if (asset != null) | 119 | if (asset != null) |
122 | return asset; | 120 | return asset; |
123 | } | 121 | } |
124 | 122 | ||
125 | Uri url; | 123 | return GetRemote(id); |
126 | 124 | } | |
127 | // Determine if id is an absolute URL or a grid-relative UUID | ||
128 | if (!Uri.TryCreate(id, UriKind.Absolute, out url)) | ||
129 | url = new Uri(m_serverUrl + id); | ||
130 | |||
131 | try | ||
132 | { | ||
133 | HttpWebRequest request = UntrustedHttpWebRequest.Create(url); | ||
134 | |||
135 | using (WebResponse response = request.GetResponse()) | ||
136 | { | ||
137 | using (Stream responseStream = response.GetResponseStream()) | ||
138 | { | ||
139 | string creatorID = response.Headers.GetOne("X-Asset-Creator-Id") ?? String.Empty; | ||
140 | |||
141 | // Create the asset object | ||
142 | asset = new AssetBase(id, String.Empty, SLUtil.ContentTypeToSLAssetType(response.ContentType), creatorID); | ||
143 | |||
144 | UUID assetID; | ||
145 | if (UUID.TryParse(id, out assetID)) | ||
146 | asset.FullID = assetID; | ||
147 | |||
148 | // Grab the asset data from the response stream | ||
149 | using (MemoryStream stream = new MemoryStream()) | ||
150 | { | ||
151 | responseStream.CopyTo(stream, Int32.MaxValue); | ||
152 | asset.Data = stream.ToArray(); | ||
153 | } | ||
154 | } | ||
155 | } | ||
156 | 125 | ||
157 | // Cache store | 126 | public AssetBase GetCached(string id) |
158 | if (m_cache != null && asset != null) | 127 | { |
159 | m_cache.Cache(asset); | 128 | if (m_cache != null) |
129 | return m_cache.Get(id); | ||
160 | 130 | ||
161 | return asset; | 131 | return null; |
162 | } | ||
163 | catch (Exception ex) | ||
164 | { | ||
165 | m_log.Warn("[SIMIAN ASSET CONNECTOR]: Asset GET from " + url + " failed: " + ex.Message); | ||
166 | return null; | ||
167 | } | ||
168 | } | 132 | } |
169 | 133 | ||
170 | /// <summary> | 134 | /// <summary> |
@@ -245,10 +209,21 @@ namespace OpenSim.Services.Connectors.SimianGrid | |||
245 | /// <returns>True if the id was parseable, false otherwise</returns> | 209 | /// <returns>True if the id was parseable, false otherwise</returns> |
246 | public bool Get(string id, Object sender, AssetRetrieved handler) | 210 | public bool Get(string id, Object sender, AssetRetrieved handler) |
247 | { | 211 | { |
212 | // Cache fetch | ||
213 | if (m_cache != null) | ||
214 | { | ||
215 | AssetBase asset = m_cache.Get(id); | ||
216 | if (asset != null) | ||
217 | { | ||
218 | handler(id, sender, asset); | ||
219 | return true; | ||
220 | } | ||
221 | } | ||
222 | |||
248 | Util.FireAndForget( | 223 | Util.FireAndForget( |
249 | delegate(object o) | 224 | delegate(object o) |
250 | { | 225 | { |
251 | AssetBase asset = Get(id); | 226 | AssetBase asset = GetRemote(id); |
252 | handler(id, sender, asset); | 227 | handler(id, sender, asset); |
253 | } | 228 | } |
254 | ); | 229 | ); |
@@ -407,12 +382,52 @@ namespace OpenSim.Services.Connectors.SimianGrid | |||
407 | 382 | ||
408 | #endregion IAssetService | 383 | #endregion IAssetService |
409 | 384 | ||
410 | public AssetBase GetCached(string id) | 385 | private AssetBase GetRemote(string id) |
411 | { | 386 | { |
412 | if (m_cache != null) | 387 | AssetBase asset = null; |
413 | return m_cache.Get(id); | 388 | Uri url; |
414 | 389 | ||
415 | return null; | 390 | // Determine if id is an absolute URL or a grid-relative UUID |
391 | if (!Uri.TryCreate(id, UriKind.Absolute, out url)) | ||
392 | url = new Uri(m_serverUrl + id); | ||
393 | |||
394 | try | ||
395 | { | ||
396 | HttpWebRequest request = UntrustedHttpWebRequest.Create(url); | ||
397 | |||
398 | using (WebResponse response = request.GetResponse()) | ||
399 | { | ||
400 | using (Stream responseStream = response.GetResponseStream()) | ||
401 | { | ||
402 | string creatorID = response.Headers.GetOne("X-Asset-Creator-Id") ?? String.Empty; | ||
403 | |||
404 | // Create the asset object | ||
405 | asset = new AssetBase(id, String.Empty, SLUtil.ContentTypeToSLAssetType(response.ContentType), creatorID); | ||
406 | |||
407 | UUID assetID; | ||
408 | if (UUID.TryParse(id, out assetID)) | ||
409 | asset.FullID = assetID; | ||
410 | |||
411 | // Grab the asset data from the response stream | ||
412 | using (MemoryStream stream = new MemoryStream()) | ||
413 | { | ||
414 | responseStream.CopyTo(stream, Int32.MaxValue); | ||
415 | asset.Data = stream.ToArray(); | ||
416 | } | ||
417 | } | ||
418 | } | ||
419 | |||
420 | // Cache store | ||
421 | if (m_cache != null && asset != null) | ||
422 | m_cache.Cache(asset); | ||
423 | |||
424 | return asset; | ||
425 | } | ||
426 | catch (Exception ex) | ||
427 | { | ||
428 | m_log.Warn("[SIMIAN ASSET CONNECTOR]: Asset GET from " + url + " failed: " + ex.Message); | ||
429 | return null; | ||
430 | } | ||
416 | } | 431 | } |
417 | } | 432 | } |
418 | } | 433 | } |
diff --git a/OpenSim/Services/Connectors/SimianGrid/SimianInventoryServiceConnector.cs b/OpenSim/Services/Connectors/SimianGrid/SimianInventoryServiceConnector.cs index 56e7475..dc68259 100644 --- a/OpenSim/Services/Connectors/SimianGrid/SimianInventoryServiceConnector.cs +++ b/OpenSim/Services/Connectors/SimianGrid/SimianInventoryServiceConnector.cs | |||
@@ -583,6 +583,14 @@ namespace OpenSim.Services.Connectors.SimianGrid | |||
583 | { "Permissions", permissions } | 583 | { "Permissions", permissions } |
584 | }; | 584 | }; |
585 | 585 | ||
586 | // Add different asset type only if it differs from inventory type | ||
587 | // (needed for links) | ||
588 | string invContentType = SLUtil.SLInvTypeToContentType(item.InvType); | ||
589 | string assetContentType = SLUtil.SLAssetTypeToContentType(item.AssetType); | ||
590 | |||
591 | if (invContentType != assetContentType) | ||
592 | extraData["LinkedItemType"] = OSD.FromString(assetContentType); | ||
593 | |||
586 | NameValueCollection requestArgs = new NameValueCollection | 594 | NameValueCollection requestArgs = new NameValueCollection |
587 | { | 595 | { |
588 | { "RequestMethod", "AddInventoryItem" }, | 596 | { "RequestMethod", "AddInventoryItem" }, |
@@ -593,6 +601,7 @@ namespace OpenSim.Services.Connectors.SimianGrid | |||
593 | { "Name", item.Name }, | 601 | { "Name", item.Name }, |
594 | { "Description", item.Description }, | 602 | { "Description", item.Description }, |
595 | { "CreatorID", item.CreatorId }, | 603 | { "CreatorID", item.CreatorId }, |
604 | { "ContentType", invContentType }, | ||
596 | { "ExtraData", OSDParser.SerializeJsonString(extraData) } | 605 | { "ExtraData", OSDParser.SerializeJsonString(extraData) } |
597 | }; | 606 | }; |
598 | 607 | ||
@@ -781,6 +790,9 @@ namespace OpenSim.Services.Connectors.SimianGrid | |||
781 | invItem.GroupPermissions = perms["GroupMask"].AsUInteger(); | 790 | invItem.GroupPermissions = perms["GroupMask"].AsUInteger(); |
782 | invItem.NextPermissions = perms["NextOwnerMask"].AsUInteger(); | 791 | invItem.NextPermissions = perms["NextOwnerMask"].AsUInteger(); |
783 | } | 792 | } |
793 | |||
794 | if (extraData.ContainsKey("LinkedItemType")) | ||
795 | invItem.AssetType = SLUtil.ContentTypeToSLAssetType(extraData["LinkedItemType"].AsString()); | ||
784 | } | 796 | } |
785 | 797 | ||
786 | if (invItem.BasePermissions == 0) | 798 | if (invItem.BasePermissions == 0) |