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