* This is an initial basic experimental code for inventory import and export from the region server
* Probably not yet ready for general use
* Thanks Kayne!
0.6.0-stable
Justin Clarke Casey 2008-09-29 14:41:16 +00:00
parent e0795e44ac
commit 7ec065198a
3 changed files with 33 additions and 75 deletions

View File

@ -316,6 +316,21 @@ namespace OpenSim.Framework.Communications.Cache
return folderList; return folderList;
} }
public List<InventoryFolderImpl> RequestListOfFolderImpls()
{
List<InventoryFolderImpl> folderList = new List<InventoryFolderImpl>();
lock (SubFolders)
{
foreach (InventoryFolderImpl folder in SubFolders.Values)
{
folderList.Add(folder);
}
}
return folderList;
}
public int TotalCount public int TotalCount
{ {
get get

View File

@ -282,6 +282,10 @@ namespace OpenSim
SaveInv(cmdparams); SaveInv(cmdparams);
break; break;
case "load-inv":
LoadInv(cmdparams);
break;
case "plugin": case "plugin":
m_sceneManager.SendCommandToPluginModules(cmdparams); m_sceneManager.SendCommandToPluginModules(cmdparams);
break; break;

View File

@ -49,6 +49,8 @@ using OpenSim.Region.Environment.Interfaces;
using OpenSim.Region.Environment.Scenes; using OpenSim.Region.Environment.Scenes;
using OpenSim.Region.Physics.Manager; using OpenSim.Region.Physics.Manager;
using OpenSim.Region.Environment.Modules.Avatar.Inventory;
namespace OpenSim namespace OpenSim
{ {
/// <summary> /// <summary>
@ -707,90 +709,27 @@ namespace OpenSim
protected void SaveInv(string[] cmdparams) protected void SaveInv(string[] cmdparams)
{ {
m_log.Error("[CONSOLE]: This command has not yet been implemented!"); m_log.Error("[CONSOLE]: This command has not yet been implemented!");
if (cmdparams.Length < 3) if (cmdparams.Length < 3)
{ {
m_log.Error("[CONSOLE]: usage is save-inv <first name> <last name> <inventory path> [<save file path>]"); m_log.Error("[CONSOLE]: usage is save-inv <first name> <last name> <inventory path> [<save file path>]");
return; return;
} }
new InventoryArchiveWriteRequest(m_sceneManager.CurrentOrFirstScene,m_commsManager).execute(cmdparams);
}
string firstName = cmdparams[0]; /// <summary>
string lastName = cmdparams[1]; /// Load inventory from a tar.gz file.
string invPath = cmdparams[2]; /// </summary>
//string savePath = (cmdparams.Length > 3 ? cmdparams[3] : DEFAULT_INV_BACKUP_FILENAME); /// <param name="cmdparams"></param>
protected void LoadInv(string[] cmdparams)
UserProfileData userProfile = m_commsManager.UserService.GetUserProfile(firstName, lastName); {
if (null == userProfile) m_log.Error("[CONSOLE]: This command has not yet been implemented!");
if (cmdparams.Length < 3)
{ {
m_log.ErrorFormat("[CONSOLE]: Failed to find user {0} {1}", firstName, lastName); m_log.Error("[CONSOLE]: usage is load-inv <first name> <last name> <inventory path> [<load file path>]");
return; return;
} }
new InventoryArchiveReadRequest(m_sceneManager.CurrentOrFirstScene, m_commsManager).execute(cmdparams);
CachedUserInfo userInfo = m_commsManager.UserProfileCacheService.GetUserDetails(userProfile.ID);
if (null == userInfo)
{
m_log.ErrorFormat("[CONSOLE]: Failed to find user info for {0} {1} {2}", firstName, lastName, userProfile.ID);
return;
}
InventoryFolderImpl inventoryFolder = null;
InventoryItemBase inventoryItem = null;
if (userInfo.HasReceivedInventory)
{
// Eliminate double slashes and any leading / on the path. This might be better done within InventoryFolderImpl
// itself (possibly at a small loss in efficiency).
string[] components
= invPath.Split(new string[] { InventoryFolderImpl.PATH_DELIMITER }, StringSplitOptions.RemoveEmptyEntries);
invPath = String.Empty;
foreach (string c in components)
{
invPath += c + InventoryFolderImpl.PATH_DELIMITER;
}
invPath = invPath.Remove(invPath.LastIndexOf(InventoryFolderImpl.PATH_DELIMITER));
// Annoyingly Split actually returns the original string if the input string consists only of delimiters
// Therefore if we still start with a / after the split, then we need the root folder
if (invPath.StartsWith(InventoryFolderImpl.PATH_DELIMITER))
{
inventoryFolder = userInfo.RootFolder;
}
else
{
inventoryFolder = userInfo.RootFolder.FindFolderByPath(invPath);
}
// The path may point to an item instead
if (inventoryFolder == null)
{
inventoryItem = userInfo.RootFolder.FindItemByPath(invPath);
}
}
else
{
m_log.ErrorFormat("[CONSOLE]: Have not yet received inventory info for user {0} {1} {2}", firstName, lastName, userProfile.ID);
return;
}
if (null == inventoryFolder)
{
if (null == inventoryItem)
{
m_log.ErrorFormat("[CONSOLE]: Could not find inventory entry at path {0}", invPath);
return;
}
else
{
m_log.InfoFormat("[CONSOLE]: Found item {0} {1} at {2}", inventoryItem.Name, inventoryItem.ID,
invPath);
}
}
else
{
m_log.InfoFormat("[CONSOLE]: Found folder {0} {1} at {2}", inventoryFolder.Name, inventoryFolder.ID,
invPath);
}
} }
/// <summary> /// <summary>