mirror of
https://github.com/opensim/opensim.git
synced 2026-08-07 09:45:47 +08:00
Merge branch 'master' into careminster-presence-refactor
Also prevent god takes from ending up in Lost and Found
This commit is contained in:
@@ -37,12 +37,11 @@ using System.Xml.Linq;
|
||||
using log4net;
|
||||
using OpenMetaverse;
|
||||
using OpenSim.Framework;
|
||||
using OpenSim.Framework.Communications;
|
||||
using OpenSim.Framework.Communications.Osp;
|
||||
using OpenSim.Framework.Serialization;
|
||||
using OpenSim.Framework.Serialization.External;
|
||||
using OpenSim.Region.CoreModules.World.Archiver;
|
||||
using OpenSim.Region.Framework.Scenes;
|
||||
using OpenSim.Region.Framework.Interfaces;
|
||||
using OpenSim.Services.Interfaces;
|
||||
|
||||
namespace OpenSim.Region.CoreModules.Avatar.Inventory.Archiver
|
||||
@@ -398,20 +397,22 @@ namespace OpenSim.Region.CoreModules.Avatar.Inventory.Archiver
|
||||
// Don't use the item ID that's in the file
|
||||
item.ID = UUID.Random();
|
||||
|
||||
UUID ospResolvedId = OspResolver.ResolveOspa(item.CreatorId, m_scene.UserAccountService);
|
||||
if (UUID.Zero != ospResolvedId)
|
||||
UUID ospResolvedId = OspResolver.ResolveOspa(item.CreatorId, m_scene.UserAccountService);
|
||||
if (UUID.Zero != ospResolvedId) // The user exists in this grid
|
||||
{
|
||||
item.CreatorIdAsUuid = ospResolvedId;
|
||||
|
||||
// XXX: For now, don't preserve the OSPA in the creator id (which actually gets persisted to the
|
||||
// database). Instead, replace with the UUID that we found.
|
||||
item.CreatorId = ospResolvedId.ToString();
|
||||
|
||||
item.CreatorData = string.Empty;
|
||||
}
|
||||
else
|
||||
else if (item.CreatorData == null || item.CreatorData == String.Empty)
|
||||
{
|
||||
item.CreatorIdAsUuid = m_userInfo.PrincipalID;
|
||||
}
|
||||
|
||||
|
||||
item.Owner = m_userInfo.PrincipalID;
|
||||
|
||||
// Reset folder ID to the one in which we want to load it
|
||||
|
||||
@@ -36,8 +36,6 @@ using OpenMetaverse;
|
||||
using OpenSim.Framework;
|
||||
using OpenSim.Framework.Serialization;
|
||||
using OpenSim.Framework.Serialization.External;
|
||||
using OpenSim.Framework.Communications;
|
||||
using OpenSim.Framework.Communications.Osp;
|
||||
using OpenSim.Region.CoreModules.World.Archiver;
|
||||
using OpenSim.Region.Framework.Scenes;
|
||||
using OpenSim.Services.Interfaces;
|
||||
@@ -139,20 +137,17 @@ namespace OpenSim.Region.CoreModules.Avatar.Inventory.Archiver
|
||||
m_id, succeeded, m_userInfo, m_invPath, m_saveStream, reportedException);
|
||||
}
|
||||
|
||||
protected void SaveInvItem(InventoryItemBase inventoryItem, string path)
|
||||
protected void SaveInvItem(InventoryItemBase inventoryItem, string path, Dictionary<string, object> options, IUserAccountService userAccountService)
|
||||
{
|
||||
string filename = path + CreateArchiveItemName(inventoryItem);
|
||||
|
||||
// Record the creator of this item for user record purposes (which might go away soon)
|
||||
m_userUuids[inventoryItem.CreatorIdAsUuid] = 1;
|
||||
|
||||
InventoryItemBase saveItem = (InventoryItemBase)inventoryItem.Clone();
|
||||
saveItem.CreatorId = OspResolver.MakeOspa(saveItem.CreatorIdAsUuid, m_scene.UserAccountService);
|
||||
|
||||
string serialization = UserInventoryItemSerializer.Serialize(saveItem);
|
||||
string serialization = UserInventoryItemSerializer.Serialize(inventoryItem, options, userAccountService);
|
||||
m_archiveWriter.WriteFile(filename, serialization);
|
||||
|
||||
m_assetGatherer.GatherAssetUuids(saveItem.AssetID, (AssetType)saveItem.AssetType, m_assetUuids);
|
||||
m_assetGatherer.GatherAssetUuids(inventoryItem.AssetID, (AssetType)inventoryItem.AssetType, m_assetUuids);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
@@ -161,7 +156,7 @@ namespace OpenSim.Region.CoreModules.Avatar.Inventory.Archiver
|
||||
/// <param name="inventoryFolder">The inventory folder to save</param>
|
||||
/// <param name="path">The path to which the folder should be saved</param>
|
||||
/// <param name="saveThisFolderItself">If true, save this folder itself. If false, only saves contents</param>
|
||||
protected void SaveInvFolder(InventoryFolderBase inventoryFolder, string path, bool saveThisFolderItself)
|
||||
protected void SaveInvFolder(InventoryFolderBase inventoryFolder, string path, bool saveThisFolderItself, Dictionary<string, object> options, IUserAccountService userAccountService)
|
||||
{
|
||||
if (saveThisFolderItself)
|
||||
{
|
||||
@@ -176,19 +171,19 @@ namespace OpenSim.Region.CoreModules.Avatar.Inventory.Archiver
|
||||
|
||||
foreach (InventoryFolderBase childFolder in contents.Folders)
|
||||
{
|
||||
SaveInvFolder(childFolder, path, true);
|
||||
SaveInvFolder(childFolder, path, true, options, userAccountService);
|
||||
}
|
||||
|
||||
foreach (InventoryItemBase item in contents.Items)
|
||||
{
|
||||
SaveInvItem(item, path);
|
||||
SaveInvItem(item, path, options, userAccountService);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Execute the inventory write request
|
||||
/// </summary>
|
||||
public void Execute()
|
||||
public void Execute(Dictionary<string, object> options, IUserAccountService userAccountService)
|
||||
{
|
||||
try
|
||||
{
|
||||
@@ -266,7 +261,7 @@ namespace OpenSim.Region.CoreModules.Avatar.Inventory.Archiver
|
||||
m_invPath == String.Empty ? InventoryFolderImpl.PATH_DELIMITER : m_invPath);
|
||||
|
||||
//recurse through all dirs getting dirs and files
|
||||
SaveInvFolder(inventoryFolder, ArchiveConstants.INVENTORY_PATH, !saveFolderContentsOnly);
|
||||
SaveInvFolder(inventoryFolder, ArchiveConstants.INVENTORY_PATH, !saveFolderContentsOnly, options, userAccountService);
|
||||
}
|
||||
else if (inventoryItem != null)
|
||||
{
|
||||
@@ -274,14 +269,17 @@ namespace OpenSim.Region.CoreModules.Avatar.Inventory.Archiver
|
||||
"[INVENTORY ARCHIVER]: Found item {0} {1} at {2}",
|
||||
inventoryItem.Name, inventoryItem.ID, m_invPath);
|
||||
|
||||
SaveInvItem(inventoryItem, ArchiveConstants.INVENTORY_PATH);
|
||||
SaveInvItem(inventoryItem, ArchiveConstants.INVENTORY_PATH, options, userAccountService);
|
||||
}
|
||||
|
||||
// Don't put all this profile information into the archive right now.
|
||||
//SaveUsers();
|
||||
|
||||
new AssetsRequest(
|
||||
new AssetsArchiver(m_archiveWriter), m_assetUuids, m_scene.AssetService, ReceivedAllAssets).Execute();
|
||||
new AssetsArchiver(m_archiveWriter),
|
||||
m_assetUuids, m_scene.AssetService,
|
||||
m_scene.UserAccountService, m_scene.RegionInfo.ScopeID,
|
||||
options, ReceivedAllAssets).Execute();
|
||||
}
|
||||
catch (Exception)
|
||||
{
|
||||
|
||||
@@ -75,6 +75,24 @@ namespace OpenSim.Region.CoreModules.Avatar.Inventory.Archiver
|
||||
private Dictionary<UUID, Scene> m_scenes = new Dictionary<UUID, Scene>();
|
||||
private Scene m_aScene;
|
||||
|
||||
private IUserAccountService m_UserAccountService;
|
||||
protected IUserAccountService UserAccountService
|
||||
{
|
||||
get
|
||||
{
|
||||
if (m_UserAccountService == null)
|
||||
// What a strange thing to do...
|
||||
foreach (Scene s in m_scenes.Values)
|
||||
{
|
||||
m_UserAccountService = s.RequestModuleInterface<IUserAccountService>();
|
||||
break;
|
||||
}
|
||||
|
||||
return m_UserAccountService;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
public InventoryArchiverModule() {}
|
||||
|
||||
public InventoryArchiverModule(bool disablePresenceChecks)
|
||||
@@ -106,11 +124,12 @@ namespace OpenSim.Region.CoreModules.Avatar.Inventory.Archiver
|
||||
|
||||
scene.AddCommand(
|
||||
this, "save iar",
|
||||
"save iar <first> <last> <inventory path> <password> [<IAR path>]",
|
||||
"save iar <first> <last> <inventory path> <password> [--p|-profile=<url>] [<IAR path>]",
|
||||
"Save user inventory archive (IAR).",
|
||||
"<first> is the user's first name." + Environment.NewLine
|
||||
+ "<last> is the user's last name." + Environment.NewLine
|
||||
+ "<inventory path> is the path inside the user's inventory for the folder/item to be saved." + Environment.NewLine
|
||||
+ "-p|--profile=<url> adds the url of the profile service to the saved user information." + Environment.NewLine
|
||||
+ "<IAR path> is the filesystem path at which to save the IAR."
|
||||
+ string.Format(" If this is not given then the filename {0} in the current directory is used", DEFAULT_INV_BACKUP_FILENAME),
|
||||
HandleSaveInvConsoleCommand);
|
||||
@@ -157,7 +176,7 @@ namespace OpenSim.Region.CoreModules.Avatar.Inventory.Archiver
|
||||
{
|
||||
try
|
||||
{
|
||||
new InventoryArchiveWriteRequest(id, this, m_aScene, userInfo, invPath, saveStream).Execute();
|
||||
new InventoryArchiveWriteRequest(id, this, m_aScene, userInfo, invPath, saveStream).Execute(options, UserAccountService);
|
||||
}
|
||||
catch (EntryPointNotFoundException e)
|
||||
{
|
||||
@@ -197,7 +216,7 @@ namespace OpenSim.Region.CoreModules.Avatar.Inventory.Archiver
|
||||
{
|
||||
try
|
||||
{
|
||||
new InventoryArchiveWriteRequest(id, this, m_aScene, userInfo, invPath, savePath).Execute();
|
||||
new InventoryArchiveWriteRequest(id, this, m_aScene, userInfo, invPath, savePath).Execute(options, UserAccountService);
|
||||
}
|
||||
catch (EntryPointNotFoundException e)
|
||||
{
|
||||
@@ -235,14 +254,15 @@ namespace OpenSim.Region.CoreModules.Avatar.Inventory.Archiver
|
||||
if (m_scenes.Count > 0)
|
||||
{
|
||||
UserAccount userInfo = GetUserInfo(firstName, lastName, pass);
|
||||
|
||||
|
||||
if (userInfo != null)
|
||||
{
|
||||
if (CheckPresence(userInfo.PrincipalID))
|
||||
{
|
||||
|
||||
InventoryArchiveReadRequest request;
|
||||
bool merge = (options.ContainsKey("merge") ? (bool)options["merge"] : false);
|
||||
|
||||
|
||||
try
|
||||
{
|
||||
request = new InventoryArchiveReadRequest(m_aScene, userInfo, invPath, loadStream, merge);
|
||||
@@ -256,7 +276,7 @@ namespace OpenSim.Region.CoreModules.Avatar.Inventory.Archiver
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
UpdateClientWithLoadedNodes(userInfo, request.Execute());
|
||||
|
||||
return true;
|
||||
@@ -268,6 +288,9 @@ namespace OpenSim.Region.CoreModules.Avatar.Inventory.Archiver
|
||||
userInfo.FirstName, userInfo.LastName, userInfo.PrincipalID);
|
||||
}
|
||||
}
|
||||
else
|
||||
m_log.ErrorFormat("[INVENTORY ARCHIVER]: User {0} {1} not found",
|
||||
firstName, lastName);
|
||||
}
|
||||
|
||||
return false;
|
||||
@@ -368,10 +391,18 @@ namespace OpenSim.Region.CoreModules.Avatar.Inventory.Archiver
|
||||
protected void HandleSaveInvConsoleCommand(string module, string[] cmdparams)
|
||||
{
|
||||
Guid id = Guid.NewGuid();
|
||||
|
||||
|
||||
Dictionary<string, object> options = new Dictionary<string, object>();
|
||||
|
||||
OptionSet ops = new OptionSet();
|
||||
//ops.Add("v|version=", delegate(string v) { options["version"] = v; });
|
||||
ops.Add("p|profile=", delegate(string v) { options["profile"] = v; });
|
||||
|
||||
List<string> mainParams = ops.Parse(cmdparams);
|
||||
|
||||
try
|
||||
{
|
||||
if (cmdparams.Length < 6)
|
||||
if (mainParams.Count < 6)
|
||||
{
|
||||
m_log.Error(
|
||||
"[INVENTORY ARCHIVER]: usage is save iar <first name> <last name> <inventory path> <user password> [<save file path>]");
|
||||
@@ -379,18 +410,20 @@ namespace OpenSim.Region.CoreModules.Avatar.Inventory.Archiver
|
||||
}
|
||||
|
||||
m_log.Info("[INVENTORY ARCHIVER]: PLEASE NOTE THAT THIS FACILITY IS EXPERIMENTAL. BUG REPORTS WELCOME.");
|
||||
|
||||
string firstName = cmdparams[2];
|
||||
string lastName = cmdparams[3];
|
||||
string invPath = cmdparams[4];
|
||||
string pass = cmdparams[5];
|
||||
string savePath = (cmdparams.Length > 6 ? cmdparams[6] : DEFAULT_INV_BACKUP_FILENAME);
|
||||
if (options.ContainsKey("profile"))
|
||||
m_log.WarnFormat("[INVENTORY ARCHIVER]: Please be aware that inventory archives with creator information are not compatible with OpenSim 0.7.0.2 and earlier. Do not use the -profile option if you want to produce a compatible IAR");
|
||||
|
||||
string firstName = mainParams[2];
|
||||
string lastName = mainParams[3];
|
||||
string invPath = mainParams[4];
|
||||
string pass = mainParams[5];
|
||||
string savePath = (mainParams.Count > 6 ? mainParams[6] : DEFAULT_INV_BACKUP_FILENAME);
|
||||
|
||||
m_log.InfoFormat(
|
||||
"[INVENTORY ARCHIVER]: Saving archive {0} using inventory path {1} for {2} {3}",
|
||||
savePath, invPath, firstName, lastName);
|
||||
|
||||
ArchiveInventory(id, firstName, lastName, invPath, pass, savePath, new Dictionary<string, object>());
|
||||
ArchiveInventory(id, firstName, lastName, invPath, pass, savePath, options);
|
||||
}
|
||||
catch (InventoryArchiverException e)
|
||||
{
|
||||
@@ -518,5 +551,6 @@ namespace OpenSim.Region.CoreModules.Avatar.Inventory.Archiver
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@@ -38,7 +38,6 @@ using OpenSim.Framework;
|
||||
using OpenSim.Framework.Serialization;
|
||||
using OpenSim.Framework.Serialization.External;
|
||||
using OpenSim.Framework.Communications;
|
||||
using OpenSim.Framework.Communications.Osp;
|
||||
using OpenSim.Region.CoreModules.Avatar.Inventory.Archiver;
|
||||
using OpenSim.Region.CoreModules.World.Serialiser;
|
||||
using OpenSim.Region.Framework.Scenes;
|
||||
@@ -96,14 +95,17 @@ namespace OpenSim.Region.CoreModules.Avatar.Inventory.Archiver.Tests
|
||||
item1.Name = m_item1Name;
|
||||
item1.AssetID = UUID.Random();
|
||||
item1.GroupID = UUID.Random();
|
||||
item1.CreatorId = OspResolver.MakeOspa(m_ua2.FirstName, m_ua2.LastName);
|
||||
//item1.CreatorId = OspResolver.MakeOspa(m_ua2.FirstName, m_ua2.LastName);
|
||||
//item1.CreatorId = userUuid.ToString();
|
||||
//item1.CreatorId = "00000000-0000-0000-0000-000000000444";
|
||||
item1.CreatorId = m_ua2.PrincipalID.ToString();
|
||||
item1.Owner = UUID.Zero;
|
||||
|
||||
|
||||
Scene scene = SceneSetupHelpers.SetupScene("Inventory");
|
||||
UserProfileTestUtils.CreateUserWithInventory(scene, m_ua2, "hampshire");
|
||||
|
||||
string item1FileName
|
||||
= string.Format("{0}{1}", ArchiveConstants.INVENTORY_PATH, archiveItemName);
|
||||
tar.WriteFile(item1FileName, UserInventoryItemSerializer.Serialize(item1));
|
||||
tar.WriteFile(item1FileName, UserInventoryItemSerializer.Serialize(item1, new Dictionary<string, object>(), scene.UserAccountService));
|
||||
tar.Close();
|
||||
m_iarStream = new MemoryStream(archiveWriteStream.ToArray());
|
||||
}
|
||||
@@ -386,7 +388,7 @@ namespace OpenSim.Region.CoreModules.Avatar.Inventory.Archiver.Tests
|
||||
Scene scene = SceneSetupHelpers.SetupScene("inventory");
|
||||
|
||||
SceneSetupHelpers.SetupSceneModules(scene, serialiserModule, archiverModule);
|
||||
|
||||
|
||||
UserProfileTestUtils.CreateUserWithInventory(scene, m_ua1, "meowfood");
|
||||
UserProfileTestUtils.CreateUserWithInventory(scene, m_ua2, "hampshire");
|
||||
|
||||
@@ -551,7 +553,7 @@ namespace OpenSim.Region.CoreModules.Avatar.Inventory.Archiver.Tests
|
||||
|
||||
string item1FileName
|
||||
= string.Format("{0}{1}", ArchiveConstants.INVENTORY_PATH, archiveItemName);
|
||||
tar.WriteFile(item1FileName, UserInventoryItemSerializer.Serialize(item1));
|
||||
tar.WriteFile(item1FileName, UserInventoryItemSerializer.Serialize(item1, new Dictionary<string,object>(), null));
|
||||
tar.Close();
|
||||
|
||||
MemoryStream archiveReadStream = new MemoryStream(archiveWriteStream.ToArray());
|
||||
|
||||
@@ -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); });
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -54,6 +54,17 @@ namespace OpenSim.Region.CoreModules.Framework.InventoryAccess
|
||||
|
||||
protected bool m_Enabled = false;
|
||||
protected Scene m_Scene;
|
||||
protected IUserManagement m_UserManagement;
|
||||
protected IUserManagement UserManagementModule
|
||||
{
|
||||
get
|
||||
{
|
||||
if (m_UserManagement == null)
|
||||
m_UserManagement = m_Scene.RequestModuleInterface<IUserManagement>();
|
||||
return m_UserManagement;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
#region INonSharedRegionModule
|
||||
|
||||
@@ -416,7 +427,7 @@ namespace OpenSim.Region.CoreModules.Framework.InventoryAccess
|
||||
//
|
||||
if (action == DeRezAction.Take || action == DeRezAction.TakeCopy)
|
||||
{
|
||||
if (objlist[0].RootPart.FromFolderID != UUID.Zero)
|
||||
if (objlist[0].RootPart.FromFolderID != UUID.Zero && objlist[0].OwnerID == remoteClient.AgentId)
|
||||
{
|
||||
InventoryFolderBase f = new InventoryFolderBase(objlist[0].RootPart.FromFolderID, userID);
|
||||
folder = m_Scene.InventoryService.GetFolder(f);
|
||||
@@ -863,6 +874,13 @@ namespace OpenSim.Region.CoreModules.Framework.InventoryAccess
|
||||
return null;
|
||||
}
|
||||
|
||||
protected void AddUserData(SceneObjectGroup sog)
|
||||
{
|
||||
UserManagementModule.AddUser(sog.RootPart.CreatorID, sog.RootPart.CreatorData);
|
||||
foreach (SceneObjectPart sop in sog.Parts)
|
||||
UserManagementModule.AddUser(sop.CreatorID, sop.CreatorData);
|
||||
}
|
||||
|
||||
public virtual void TransferInventoryAssets(InventoryItemBase item, UUID sender, UUID receiver)
|
||||
{
|
||||
}
|
||||
@@ -943,9 +961,13 @@ namespace OpenSim.Region.CoreModules.Framework.InventoryAccess
|
||||
protected virtual InventoryItemBase GetItem(UUID agentID, UUID itemID)
|
||||
{
|
||||
IInventoryService invService = m_Scene.RequestModuleInterface<IInventoryService>();
|
||||
InventoryItemBase assetRequestItem = new InventoryItemBase(itemID, agentID);
|
||||
assetRequestItem = invService.GetItem(assetRequestItem);
|
||||
return assetRequestItem;
|
||||
InventoryItemBase item = new InventoryItemBase(itemID, agentID);
|
||||
item = invService.GetItem(item);
|
||||
|
||||
if (item.CreatorData != null && item.CreatorData != string.Empty)
|
||||
UserManagementModule.AddUser(item.CreatorIdAsUuid, item.CreatorData);
|
||||
|
||||
return item;
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
@@ -275,6 +275,11 @@ namespace OpenSim.Region.CoreModules.Framework.UserManagement
|
||||
m_log.DebugFormat("[USER MANAGEMENT MODULE]: Added user {0} {1} {2} {3}", user.Id, user.FirstName, user.LastName, user.ProfileURL);
|
||||
}
|
||||
|
||||
public void AddUser(UUID uuid, string first, string last, string profileURL)
|
||||
{
|
||||
AddUser(uuid, profileURL + ";" + first + " " + last);
|
||||
}
|
||||
|
||||
//public void AddUser(UUID uuid, string userData)
|
||||
//{
|
||||
// if (m_UserCache.ContainsKey(uuid))
|
||||
|
||||
@@ -91,9 +91,10 @@ namespace OpenSim.Region.CoreModules.ServiceConnectorsIn.Asset
|
||||
{
|
||||
m_Registered = true;
|
||||
|
||||
m_log.Info("[RegionAssetService]: Starting...");
|
||||
m_log.Info("[HGAssetService]: Starting...");
|
||||
|
||||
Object[] args = new Object[] { m_Config, MainServer.Instance, string.Empty };
|
||||
|
||||
Object[] args = new Object[] { m_Config, MainServer.Instance, "HGAssetService" };
|
||||
|
||||
ServerUtils.LoadPlugin<IServiceConnector>("OpenSim.Server.Handlers.dll:AssetServiceConnector", args);
|
||||
}
|
||||
|
||||
@@ -190,7 +190,8 @@ namespace OpenSim.Region.CoreModules.World.Archiver
|
||||
|
||||
new AssetsRequest(
|
||||
new AssetsArchiver(archiveWriter), assetUuids,
|
||||
m_scene.AssetService, awre.ReceivedAllAssets).Execute();
|
||||
m_scene.AssetService, m_scene.UserAccountService,
|
||||
m_scene.RegionInfo.ScopeID, options, awre.ReceivedAllAssets).Execute();
|
||||
}
|
||||
catch (Exception)
|
||||
{
|
||||
@@ -238,10 +239,10 @@ namespace OpenSim.Region.CoreModules.World.Archiver
|
||||
}
|
||||
|
||||
m_log.InfoFormat("[ARCHIVER]: Creating version {0}.{1} OAR", majorVersion, minorVersion);
|
||||
if (majorVersion == 1)
|
||||
{
|
||||
m_log.WarnFormat("[ARCHIVER]: Please be aware that version 1.0 OARs are not compatible with OpenSim 0.7.0.2 and earlier. Please use the --version=0 option if you want to produce a compatible OAR");
|
||||
}
|
||||
//if (majorVersion == 1)
|
||||
//{
|
||||
// m_log.WarnFormat("[ARCHIVER]: Please be aware that version 1.0 OARs are not compatible with OpenSim 0.7.0.2 and earlier. Please use the --version=0 option if you want to produce a compatible OAR");
|
||||
//}
|
||||
|
||||
StringWriter sw = new StringWriter();
|
||||
XmlTextWriter xtw = new XmlTextWriter(sw);
|
||||
|
||||
@@ -34,6 +34,7 @@ using log4net;
|
||||
using OpenMetaverse;
|
||||
using OpenSim.Framework;
|
||||
using OpenSim.Framework.Serialization;
|
||||
using OpenSim.Framework.Serialization.External;
|
||||
using OpenSim.Services.Interfaces;
|
||||
|
||||
namespace OpenSim.Region.CoreModules.World.Archiver
|
||||
@@ -100,17 +101,26 @@ namespace OpenSim.Region.CoreModules.World.Archiver
|
||||
/// Asset service used to request the assets
|
||||
/// </value>
|
||||
protected IAssetService m_assetService;
|
||||
protected IUserAccountService m_userAccountService;
|
||||
protected UUID m_scopeID; // the grid ID
|
||||
|
||||
protected AssetsArchiver m_assetsArchiver;
|
||||
|
||||
protected Dictionary<string, object> m_options;
|
||||
|
||||
protected internal AssetsRequest(
|
||||
AssetsArchiver assetsArchiver, IDictionary<UUID, AssetType> uuids,
|
||||
IAssetService assetService, AssetsRequestCallback assetsRequestCallback)
|
||||
IAssetService assetService, IUserAccountService userService,
|
||||
UUID scope, Dictionary<string, object> options,
|
||||
AssetsRequestCallback assetsRequestCallback)
|
||||
{
|
||||
m_assetsArchiver = assetsArchiver;
|
||||
m_uuids = uuids;
|
||||
m_assetsRequestCallback = assetsRequestCallback;
|
||||
m_assetService = assetService;
|
||||
m_userAccountService = userService;
|
||||
m_scopeID = scope;
|
||||
m_options = options;
|
||||
m_repliesRequired = uuids.Count;
|
||||
|
||||
m_requestCallbackTimer = new System.Timers.Timer(TIMEOUT);
|
||||
@@ -241,7 +251,8 @@ namespace OpenSim.Region.CoreModules.World.Archiver
|
||||
{
|
||||
// m_log.DebugFormat("[ARCHIVER]: Writing asset {0}", id);
|
||||
m_foundAssetUuids.Add(asset.FullID);
|
||||
m_assetsArchiver.WriteAsset(asset);
|
||||
|
||||
m_assetsArchiver.WriteAsset(PostProcess(asset));
|
||||
}
|
||||
else
|
||||
{
|
||||
@@ -288,5 +299,16 @@ namespace OpenSim.Region.CoreModules.World.Archiver
|
||||
"[ARCHIVER]: Terminating archive creation since asset requster callback failed with {0}", e);
|
||||
}
|
||||
}
|
||||
|
||||
protected AssetBase PostProcess(AssetBase asset)
|
||||
{
|
||||
if (asset.Type == (sbyte)AssetType.Object && asset.Data != null && m_options.ContainsKey("profile"))
|
||||
{
|
||||
//m_log.DebugFormat("[ARCHIVER]: Rewriting object data for {0}", asset.ID);
|
||||
string xml = ExternalRepresentationUtils.RewriteSOP(Utils.BytesToString(asset.Data), m_options["profile"].ToString(), m_userAccountService, m_scopeID);
|
||||
asset.Data = Utils.StringToBytes(xml);
|
||||
}
|
||||
return asset;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user