Creator information preserved upon HG transfers.

viewer-2-initial-appearance
Diva Canto 2010-11-26 22:06:34 -08:00
parent 1cbd2842d5
commit 3292a22558
5 changed files with 97 additions and 9 deletions

View File

@ -27,8 +27,11 @@
using System; using System;
using System.Collections.Generic; using System.Collections.Generic;
using System.IO;
using System.Reflection; using System.Reflection;
using System.Threading; using System.Threading;
using System.Xml;
using log4net; using log4net;
using OpenMetaverse; using OpenMetaverse;
using OpenSim.Framework; using OpenSim.Framework;
@ -52,14 +55,16 @@ namespace OpenSim.Region.CoreModules.Framework.InventoryAccess
// private Dictionary<string, InventoryClient> m_inventoryServers = new Dictionary<string, InventoryClient>(); // private Dictionary<string, InventoryClient> m_inventoryServers = new Dictionary<string, InventoryClient>();
private Scene m_scene; private Scene m_scene;
private string m_ProfileServerURI;
#endregion #endregion
#region Constructor #region Constructor
public HGAssetMapper(Scene scene) public HGAssetMapper(Scene scene, string profileURL)
{ {
m_scene = scene; m_scene = scene;
m_ProfileServerURI = profileURL;
} }
#endregion #endregion
@ -95,16 +100,18 @@ namespace OpenSim.Region.CoreModules.Framework.InventoryAccess
try try
{ {
asset1.ID = url + "/" + asset.ID; asset1.ID = url + "/" + asset.ID;
// UUID temp = UUID.Zero;
// TODO: if the creator is local, stick this grid's URL in front
//if (UUID.TryParse(asset.Metadata.CreatorID, out temp))
// asset1.Metadata.CreatorID = ??? + "/" + asset.Metadata.CreatorID;
} }
catch catch
{ {
m_log.Warn("[HG ASSET MAPPER]: Oops."); m_log.Warn("[HG ASSET MAPPER]: Oops.");
} }
AdjustIdentifiers(asset1.Metadata);
if (asset1.Metadata.Type == (sbyte)AssetType.Object)
asset1.Data = AdjustIdentifiers(asset.Data);
else
asset1.Data = asset.Data;
m_scene.AssetService.Store(asset1); m_scene.AssetService.Store(asset1);
m_log.DebugFormat("[HG ASSET MAPPER]: Posted copy of asset {0} from local asset server to {1}", asset1.ID, url); m_log.DebugFormat("[HG ASSET MAPPER]: Posted copy of asset {0} from local asset server to {1}", asset1.ID, url);
} }
@ -118,7 +125,7 @@ namespace OpenSim.Region.CoreModules.Framework.InventoryAccess
private void Copy(AssetBase from, AssetBase to) private void Copy(AssetBase from, AssetBase to)
{ {
to.Data = from.Data; //to.Data = from.Data; // don't copy this, it's copied elsewhere
to.Description = from.Description; to.Description = from.Description;
to.FullID = from.FullID; to.FullID = from.FullID;
to.ID = from.ID; to.ID = from.ID;
@ -129,6 +136,70 @@ namespace OpenSim.Region.CoreModules.Framework.InventoryAccess
} }
private void AdjustIdentifiers(AssetMetadata meta)
{
if (meta.CreatorID != null && meta.CreatorID != string.Empty)
{
UUID uuid = UUID.Zero;
UUID.TryParse(meta.CreatorID, out uuid);
UserAccount creator = m_scene.UserAccountService.GetUserAccount(m_scene.RegionInfo.ScopeID, uuid);
if (creator != null)
meta.CreatorID = m_ProfileServerURI + "/" + meta.CreatorID + ";" + creator.FirstName + " " + creator.LastName;
}
}
protected byte[] AdjustIdentifiers(byte[] data)
{
string xml = Utils.BytesToString(data);
return Utils.StringToBytes(RewriteSOP(xml));
}
protected string RewriteSOP(string xml)
{
XmlDocument doc = new XmlDocument();
doc.LoadXml(xml);
XmlNodeList sops = doc.GetElementsByTagName("SceneObjectPart");
foreach (XmlNode sop in sops)
{
UserAccount creator = null;
bool hasCreatorData = false;
XmlNodeList nodes = sop.ChildNodes;
foreach (XmlNode node in nodes)
{
if (node.Name == "CreatorID")
{
UUID uuid = UUID.Zero;
UUID.TryParse(node.InnerText, out uuid);
creator = m_scene.UserAccountService.GetUserAccount(m_scene.RegionInfo.ScopeID, uuid);
}
if (node.Name == "CreatorData" && node.InnerText != null && node.InnerText != string.Empty)
hasCreatorData = true;
//if (node.Name == "OwnerID")
//{
// UserAccount owner = GetUser(node.InnerText);
// if (owner != null)
// node.InnerText = m_ProfileServiceURL + "/" + node.InnerText + "/" + owner.FirstName + " " + owner.LastName;
//}
}
if (!hasCreatorData && creator != null)
{
XmlElement creatorData = doc.CreateElement("CreatorData");
creatorData.InnerText = m_ProfileServerURI + "/" + creator.PrincipalID + ";" + creator.FirstName + " " + creator.LastName;
sop.AppendChild(creatorData);
}
}
using (StringWriter wr = new StringWriter())
{
doc.Save(wr);
return wr.ToString();
}
}
// TODO: unused // TODO: unused
// private void Dump(Dictionary<UUID, bool> lst) // private void Dump(Dictionary<UUID, bool> lst)
// { // {

View File

@ -54,6 +54,8 @@ namespace OpenSim.Region.CoreModules.Framework.InventoryAccess
get { return m_assMapper; } get { return m_assMapper; }
} }
private string m_ProfileServerURI;
// private bool m_Initialized = false; // private bool m_Initialized = false;
#region INonSharedRegionModule #region INonSharedRegionModule
@ -73,6 +75,12 @@ namespace OpenSim.Region.CoreModules.Framework.InventoryAccess
{ {
m_Enabled = true; m_Enabled = true;
m_log.InfoFormat("[HG INVENTORY ACCESS MODULE]: {0} enabled.", Name); m_log.InfoFormat("[HG INVENTORY ACCESS MODULE]: {0} enabled.", Name);
IConfig thisModuleConfig = source.Configs["HGInventoryAccessModule"];
if (thisModuleConfig != null)
m_ProfileServerURI = thisModuleConfig.GetString("ProfileServerURI", string.Empty);
else
m_log.Warn("[HG INVENTORY ACCESS MODULE]: HGInventoryAccessModule configs not found. ProfileServerURI not set!");
} }
} }
} }
@ -83,7 +91,7 @@ namespace OpenSim.Region.CoreModules.Framework.InventoryAccess
return; return;
base.AddRegion(scene); base.AddRegion(scene);
m_assMapper = new HGAssetMapper(scene); m_assMapper = new HGAssetMapper(scene, m_ProfileServerURI);
scene.EventManager.OnNewInventoryItemUploadComplete += UploadInventoryItem; scene.EventManager.OnNewInventoryItemUploadComplete += UploadInventoryItem;
} }
@ -97,7 +105,7 @@ namespace OpenSim.Region.CoreModules.Framework.InventoryAccess
string userAssetServer = string.Empty; string userAssetServer = string.Empty;
if (IsForeignUser(avatarID, out userAssetServer)) if (IsForeignUser(avatarID, out userAssetServer))
{ {
m_assMapper.Post(assetID, avatarID, userAssetServer); Util.FireAndForget(delegate { m_assMapper.Post(assetID, avatarID, userAssetServer); });
} }
} }

View File

@ -126,7 +126,6 @@ namespace OpenSim.Services.HypergridService
UserAccount creator = m_Cache.GetUser(meta.CreatorID); UserAccount creator = m_Cache.GetUser(meta.CreatorID);
if (creator != null) if (creator != null)
meta.CreatorID = m_ProfileServiceURL + "/" + meta.CreatorID + ";" + creator.FirstName + " " + creator.LastName; meta.CreatorID = m_ProfileServiceURL + "/" + meta.CreatorID + ";" + creator.FirstName + " " + creator.LastName;
} }
protected byte[] AdjustIdentifiers(byte[] data) protected byte[] AdjustIdentifiers(byte[] data)

View File

@ -78,6 +78,14 @@
; ;
FriendsServerURI = "http://mygridserver.com:8003" FriendsServerURI = "http://mygridserver.com:8003"
[HGInventoryAccessModule]
;
; === HG ONLY ===
; Change this to your profile server
; accessible from other grids
;
ProfileServerURI = "http://mygridserver.com:8002/profiles"
[Modules] [Modules]
;; Choose 0 or 1 cache modules, and the corresponding config file, if it exists. ;; Choose 0 or 1 cache modules, and the corresponding config file, if it exists.
;; Copy the config .example file into your own .ini file and change configs there ;; Copy the config .example file into your own .ini file and change configs there

View File

@ -31,6 +31,8 @@
[HGAssetService] [HGAssetService]
ProfileServerURI = "http://127.0.0.1:9000/profiles" ProfileServerURI = "http://127.0.0.1:9000/profiles"
[HGInventoryAccessModule]
ProfileServerURI = "http://127.0.0.1:9000/profiles"
[Modules] [Modules]
;; Choose 0 or 1 cache modules, and the corresponding config file, if it exists. ;; Choose 0 or 1 cache modules, and the corresponding config file, if it exists.