diff options
Diffstat (limited to '')
-rw-r--r-- | OpenSim/Region/CoreModules/Framework/InventoryAccess/HGAssetMapper.cs | 79 |
1 files changed, 43 insertions, 36 deletions
diff --git a/OpenSim/Region/CoreModules/Framework/InventoryAccess/HGAssetMapper.cs b/OpenSim/Region/CoreModules/Framework/InventoryAccess/HGAssetMapper.cs index f8ec6de..eaadc1b 100644 --- a/OpenSim/Region/CoreModules/Framework/InventoryAccess/HGAssetMapper.cs +++ b/OpenSim/Region/CoreModules/Framework/InventoryAccess/HGAssetMapper.cs | |||
@@ -71,19 +71,19 @@ namespace OpenSim.Region.CoreModules.Framework.InventoryAccess | |||
71 | 71 | ||
72 | #region Internal functions | 72 | #region Internal functions |
73 | 73 | ||
74 | public AssetMetadata FetchMetadata(string url, UUID assetID) | 74 | public AssetBase FetchAsset(string url, UUID assetID) |
75 | { | 75 | { |
76 | if (!url.EndsWith("/") && !url.EndsWith("=")) | 76 | if (!url.EndsWith("/") && !url.EndsWith("=")) |
77 | url = url + "/"; | 77 | url = url + "/"; |
78 | 78 | ||
79 | AssetMetadata meta = m_scene.AssetService.GetMetadata(url + assetID.ToString()); | 79 | AssetBase asset = m_scene.AssetService.Get(url + assetID.ToString()); |
80 | 80 | ||
81 | if (meta != null) | 81 | if (asset != null) |
82 | m_log.DebugFormat("[HG ASSET MAPPER]: Fetched metadata for asset {0} of type {1} from {2} ", assetID, meta.Type, url); | 82 | { |
83 | else | 83 | m_log.DebugFormat("[HG ASSET MAPPER]: Copied asset {0} from {1} to local asset server. ", asset.ID, url); |
84 | m_log.DebugFormat("[HG ASSET MAPPER]: Unable to fetched metadata for asset {0} from {1} ", assetID, url); | 84 | return asset; |
85 | 85 | } | |
86 | return meta; | 86 | return null; |
87 | } | 87 | } |
88 | 88 | ||
89 | public bool PostAsset(string url, AssetBase asset) | 89 | public bool PostAsset(string url, AssetBase asset) |
@@ -93,7 +93,6 @@ namespace OpenSim.Region.CoreModules.Framework.InventoryAccess | |||
93 | if (!url.EndsWith("/") && !url.EndsWith("=")) | 93 | if (!url.EndsWith("/") && !url.EndsWith("=")) |
94 | url = url + "/"; | 94 | url = url + "/"; |
95 | 95 | ||
96 | bool success = true; | ||
97 | // See long comment in AssetCache.AddAsset | 96 | // See long comment in AssetCache.AddAsset |
98 | if (!asset.Temporary || asset.Local) | 97 | if (!asset.Temporary || asset.Local) |
99 | { | 98 | { |
@@ -104,7 +103,14 @@ namespace OpenSim.Region.CoreModules.Framework.InventoryAccess | |||
104 | // not having a global naming infrastructure | 103 | // not having a global naming infrastructure |
105 | AssetBase asset1 = new AssetBase(asset.FullID, asset.Name, asset.Type, asset.Metadata.CreatorID); | 104 | AssetBase asset1 = new AssetBase(asset.FullID, asset.Name, asset.Type, asset.Metadata.CreatorID); |
106 | Copy(asset, asset1); | 105 | Copy(asset, asset1); |
107 | asset1.ID = url + asset.ID; | 106 | try |
107 | { | ||
108 | asset1.ID = url + asset.ID; | ||
109 | } | ||
110 | catch | ||
111 | { | ||
112 | m_log.Warn("[HG ASSET MAPPER]: Oops."); | ||
113 | } | ||
108 | 114 | ||
109 | AdjustIdentifiers(asset1.Metadata); | 115 | AdjustIdentifiers(asset1.Metadata); |
110 | if (asset1.Metadata.Type == (sbyte)AssetType.Object) | 116 | if (asset1.Metadata.Type == (sbyte)AssetType.Object) |
@@ -112,17 +118,11 @@ namespace OpenSim.Region.CoreModules.Framework.InventoryAccess | |||
112 | else | 118 | else |
113 | asset1.Data = asset.Data; | 119 | asset1.Data = asset.Data; |
114 | 120 | ||
115 | string id = m_scene.AssetService.Store(asset1); | 121 | m_scene.AssetService.Store(asset1); |
116 | if (id == string.Empty) | 122 | m_log.DebugFormat("[HG ASSET MAPPER]: Posted copy of asset {0} from local asset server to {1}", asset1.ID, url); |
117 | { | ||
118 | m_log.DebugFormat("[HG ASSET MAPPER]: Asset server {0} did not accept {1}", url, asset.ID); | ||
119 | success = false; | ||
120 | } | ||
121 | else | ||
122 | m_log.DebugFormat("[HG ASSET MAPPER]: Posted copy of asset {0} from local asset server to {1}", asset1.ID, url); | ||
123 | } | 123 | } |
124 | return success; | 124 | return true; |
125 | } | 125 | } |
126 | else | 126 | else |
127 | m_log.Warn("[HG ASSET MAPPER]: Tried to post asset to remote server, but asset not in local cache."); | 127 | m_log.Warn("[HG ASSET MAPPER]: Tried to post asset to remote server, but asset not in local cache."); |
128 | 128 | ||
@@ -222,17 +222,28 @@ namespace OpenSim.Region.CoreModules.Framework.InventoryAccess | |||
222 | 222 | ||
223 | public void Get(UUID assetID, UUID ownerID, string userAssetURL) | 223 | public void Get(UUID assetID, UUID ownerID, string userAssetURL) |
224 | { | 224 | { |
225 | // Get the item from the remote asset server onto the local AssetService | 225 | // Get the item from the remote asset server onto the local AssetCache |
226 | // and place an entry in m_assetMap | ||
227 | |||
228 | m_log.Debug("[HG ASSET MAPPER]: Fetching object " + assetID + " from asset server " + userAssetURL); | ||
229 | AssetBase asset = FetchAsset(userAssetURL, assetID); | ||
226 | 230 | ||
227 | AssetMetadata meta = FetchMetadata(userAssetURL, assetID); | 231 | if (asset != null) |
228 | if (meta == null) | 232 | { |
229 | return; | 233 | // OK, now fetch the inside. |
234 | Dictionary<UUID, AssetType> ids = new Dictionary<UUID, AssetType>(); | ||
235 | HGUuidGatherer uuidGatherer = new HGUuidGatherer(this, m_scene.AssetService, userAssetURL); | ||
236 | uuidGatherer.GatherAssetUuids(asset.FullID, (AssetType)asset.Type, ids); | ||
237 | if (ids.ContainsKey(assetID)) | ||
238 | ids.Remove(assetID); | ||
239 | foreach (UUID uuid in ids.Keys) | ||
240 | FetchAsset(userAssetURL, uuid); | ||
230 | 241 | ||
231 | // The act of gathering UUIDs downloads the assets from the remote server | 242 | m_log.DebugFormat("[HG ASSET MAPPER]: Successfully fetched asset {0} from asset server {1}", asset.ID, userAssetURL); |
232 | Dictionary<UUID, AssetType> ids = new Dictionary<UUID, AssetType>(); | ||
233 | HGUuidGatherer uuidGatherer = new HGUuidGatherer(m_scene.AssetService, userAssetURL); | ||
234 | uuidGatherer.GatherAssetUuids(assetID, (AssetType)meta.Type, ids); | ||
235 | 243 | ||
244 | } | ||
245 | else | ||
246 | m_log.Warn("[HG ASSET MAPPER]: Could not fetch asset from remote asset server " + userAssetURL); | ||
236 | } | 247 | } |
237 | 248 | ||
238 | 249 | ||
@@ -246,23 +257,19 @@ namespace OpenSim.Region.CoreModules.Framework.InventoryAccess | |||
246 | if (asset != null) | 257 | if (asset != null) |
247 | { | 258 | { |
248 | Dictionary<UUID, AssetType> ids = new Dictionary<UUID, AssetType>(); | 259 | Dictionary<UUID, AssetType> ids = new Dictionary<UUID, AssetType>(); |
249 | HGUuidGatherer uuidGatherer = new HGUuidGatherer(m_scene.AssetService, string.Empty); | 260 | HGUuidGatherer uuidGatherer = new HGUuidGatherer(this, m_scene.AssetService, string.Empty); |
250 | uuidGatherer.GatherAssetUuids(asset.FullID, (AssetType)asset.Type, ids); | 261 | uuidGatherer.GatherAssetUuids(asset.FullID, (AssetType)asset.Type, ids); |
251 | bool success = false; | ||
252 | foreach (UUID uuid in ids.Keys) | 262 | foreach (UUID uuid in ids.Keys) |
253 | { | 263 | { |
254 | asset = m_scene.AssetService.Get(uuid.ToString()); | 264 | asset = m_scene.AssetService.Get(uuid.ToString()); |
255 | if (asset == null) | 265 | if (asset == null) |
256 | m_log.DebugFormat("[HG ASSET MAPPER]: Could not find asset {0}", uuid); | 266 | m_log.DebugFormat("[HG ASSET MAPPER]: Could not find asset {0}", uuid); |
257 | else | 267 | else |
258 | success = PostAsset(userAssetURL, asset); | 268 | PostAsset(userAssetURL, asset); |
259 | } | 269 | } |
260 | 270 | ||
261 | // maybe all pieces got there... | 271 | // maybe all pieces got there... |
262 | if (!success) | 272 | m_log.DebugFormat("[HG ASSET MAPPER]: Successfully posted item {0} to asset server {1}", assetID, userAssetURL); |
263 | m_log.DebugFormat("[HG ASSET MAPPER]: Problems posting item {0} to asset server {1}", assetID, userAssetURL); | ||
264 | else | ||
265 | m_log.DebugFormat("[HG ASSET MAPPER]: Successfully posted item {0} to asset server {1}", assetID, userAssetURL); | ||
266 | 273 | ||
267 | } | 274 | } |
268 | else | 275 | else |