Creator information preserved upon HG transfers.
parent
1cbd2842d5
commit
3292a22558
|
@ -27,8 +27,11 @@
|
|||
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.IO;
|
||||
using System.Reflection;
|
||||
using System.Threading;
|
||||
using System.Xml;
|
||||
|
||||
using log4net;
|
||||
using OpenMetaverse;
|
||||
using OpenSim.Framework;
|
||||
|
@ -52,14 +55,16 @@ namespace OpenSim.Region.CoreModules.Framework.InventoryAccess
|
|||
// private Dictionary<string, InventoryClient> m_inventoryServers = new Dictionary<string, InventoryClient>();
|
||||
|
||||
private Scene m_scene;
|
||||
private string m_ProfileServerURI;
|
||||
|
||||
#endregion
|
||||
|
||||
#region Constructor
|
||||
|
||||
public HGAssetMapper(Scene scene)
|
||||
public HGAssetMapper(Scene scene, string profileURL)
|
||||
{
|
||||
m_scene = scene;
|
||||
m_ProfileServerURI = profileURL;
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
@ -95,16 +100,18 @@ namespace OpenSim.Region.CoreModules.Framework.InventoryAccess
|
|||
try
|
||||
{
|
||||
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
|
||||
{
|
||||
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_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)
|
||||
{
|
||||
to.Data = from.Data;
|
||||
//to.Data = from.Data; // don't copy this, it's copied elsewhere
|
||||
to.Description = from.Description;
|
||||
to.FullID = from.FullID;
|
||||
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
|
||||
// private void Dump(Dictionary<UUID, bool> lst)
|
||||
// {
|
||||
|
|
|
@ -54,6 +54,8 @@ namespace OpenSim.Region.CoreModules.Framework.InventoryAccess
|
|||
get { return m_assMapper; }
|
||||
}
|
||||
|
||||
private string m_ProfileServerURI;
|
||||
|
||||
// private bool m_Initialized = false;
|
||||
|
||||
#region INonSharedRegionModule
|
||||
|
@ -73,6 +75,12 @@ namespace OpenSim.Region.CoreModules.Framework.InventoryAccess
|
|||
{
|
||||
m_Enabled = true;
|
||||
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;
|
||||
|
||||
base.AddRegion(scene);
|
||||
m_assMapper = new HGAssetMapper(scene);
|
||||
m_assMapper = new HGAssetMapper(scene, m_ProfileServerURI);
|
||||
scene.EventManager.OnNewInventoryItemUploadComplete += UploadInventoryItem;
|
||||
|
||||
}
|
||||
|
@ -97,7 +105,7 @@ namespace OpenSim.Region.CoreModules.Framework.InventoryAccess
|
|||
string userAssetServer = string.Empty;
|
||||
if (IsForeignUser(avatarID, out userAssetServer))
|
||||
{
|
||||
m_assMapper.Post(assetID, avatarID, userAssetServer);
|
||||
Util.FireAndForget(delegate { m_assMapper.Post(assetID, avatarID, userAssetServer); });
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -126,7 +126,6 @@ namespace OpenSim.Services.HypergridService
|
|||
UserAccount creator = m_Cache.GetUser(meta.CreatorID);
|
||||
if (creator != null)
|
||||
meta.CreatorID = m_ProfileServiceURL + "/" + meta.CreatorID + ";" + creator.FirstName + " " + creator.LastName;
|
||||
|
||||
}
|
||||
|
||||
protected byte[] AdjustIdentifiers(byte[] data)
|
||||
|
|
|
@ -78,6 +78,14 @@
|
|||
;
|
||||
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]
|
||||
;; 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
|
||||
|
|
|
@ -31,6 +31,8 @@
|
|||
[HGAssetService]
|
||||
ProfileServerURI = "http://127.0.0.1:9000/profiles"
|
||||
|
||||
[HGInventoryAccessModule]
|
||||
ProfileServerURI = "http://127.0.0.1:9000/profiles"
|
||||
|
||||
[Modules]
|
||||
;; Choose 0 or 1 cache modules, and the corresponding config file, if it exists.
|
||||
|
|
Loading…
Reference in New Issue