From 13da5a9fbaa0c50a8a49da1a30b2cd6ce75a3648 Mon Sep 17 00:00:00 2001 From: diva Date: Mon, 18 May 2009 20:04:59 +0000 Subject: Finished HG Service Store. Not fully functional because of problems with asset.ID insisting on being a UUID string. --- .../Framework/Scenes/Hypergrid/HGAssetMapper.cs | 66 ++++++++++------------ 1 file changed, 30 insertions(+), 36 deletions(-) (limited to 'OpenSim/Region/Framework/Scenes/Hypergrid/HGAssetMapper.cs') diff --git a/OpenSim/Region/Framework/Scenes/Hypergrid/HGAssetMapper.cs b/OpenSim/Region/Framework/Scenes/Hypergrid/HGAssetMapper.cs index e659ad1..b6b2172 100644 --- a/OpenSim/Region/Framework/Scenes/Hypergrid/HGAssetMapper.cs +++ b/OpenSim/Region/Framework/Scenes/Hypergrid/HGAssetMapper.cs @@ -120,25 +120,30 @@ namespace OpenSim.Region.Framework.Scenes.Hypergrid return null; } - private bool PostAsset(GridAssetClient asscli, UUID assetID, bool isTexture) + private bool PostAsset(string url, AssetBase asset) { - AssetBase asset1; - //m_scene.CommsManager.AssetCache.TryGetCachedAsset(assetID, out asset1); - asset1 = m_scene.CommsManager.AssetCache.GetAsset(assetID, isTexture); - - if (asset1 != null) + if (asset != null) { // See long comment in AssetCache.AddAsset - if (!asset1.Temporary || asset1.Local) + if (!asset.Temporary || asset.Local) { - // The asset cache returns instances of subclasses of AssetBase: - // TextureImage or AssetInfo. So in passing them to the remote - // server we first need to convert this to instances of AssetBase, - // which is the serializable class for assets. - AssetBase asset = new AssetBase(); - Copy(asset1, asset); - - asscli.StoreAsset(asset); + // We need to copy the asset into a new asset, because + // we need to set its ID to be URL+UUID, so that the + // HGAssetService dispatches it to the remote grid. + // It's not pretty, but the best that can be done while + // not having a global naming infrastructure + AssetBase asset1 = new AssetBase(); + Copy(asset, asset1); + try + { + asset1.ID = url + "/" + asset.ID; + } + catch + { + m_log.Warn("[HGScene]: This won't work until Melanie kills a few more dragons"); + } + + m_scene.AssetService.Store(asset1); } return true; } @@ -315,46 +320,35 @@ namespace OpenSim.Region.Framework.Scenes.Hypergrid { if (!IsLocalUser(ownerID)) { - // Post the item from the local AssetCache ontp the remote asset server + // Post the item from the local AssetCache onto the remote asset server // and place an entry in m_assetMap - GridAssetClient asscli = null; string userAssetURL = UserAssetURL(ownerID); if (userAssetURL != null) { - m_assetServers.TryGetValue(userAssetURL, out asscli); - if (asscli == null) - { - m_log.Debug("[HGScene]: Starting new GridAssetClient for " + userAssetURL); - asscli = new GridAssetClient(userAssetURL); - asscli.SetReceiver(m_scene.CommsManager.AssetCache); // Straight to the asset cache! - m_assetServers.Add(userAssetURL, asscli); - } m_log.Debug("[HGScene]: Posting object " + assetID + " to asset server " + userAssetURL); - AssetBase ass1 = null; - m_scene.CommsManager.AssetCache.TryGetCachedAsset(assetID, out ass1); + AssetBase ass1 = m_scene.AssetService.Get(assetID.ToString()); if (ass1 != null) { - bool success = PostAsset(asscli, assetID, (ass1.Type == (sbyte)AssetType.Texture)); + bool success = PostAsset(userAssetURL, ass1); // Now the inside Dictionary ids = SniffUUIDs(assetID); Dump(ids); foreach (KeyValuePair kvp in ids) - PostAsset(asscli, kvp.Key, kvp.Value); - - if (success) { - m_log.Debug("[HGScene]: Successfully posted item to remote asset server " + userAssetURL); - if (!m_assetMap.ContainsKey(assetID)) - m_assetMap.Add(assetID, asscli); + ass1 = m_scene.AssetService.Get(kvp.Key.ToString()); + PostAsset(userAssetURL, ass1); } + + if (success) + m_log.DebugFormat("[HGScene]: Successfully posted item {0} to remote asset server {1}", assetID, userAssetURL); else - m_log.Warn("[HGScene]: Could not post asset to remote asset server " + userAssetURL); + m_log.WarnFormat("[HGScene]: Could not post asset {0} to remote asset server {1}", assetID, userAssetURL); } else - m_log.Debug("[HGScene]: Something wrong with asset"); + m_log.Debug("[HGScene]: Something wrong with asset, it could not be found"); } else m_log.Warn("[HGScene]: Unable to locate foreign user's asset server"); -- cgit v1.1