Merge branch 'master' of /home/opensim/var/repo/opensim

integration
BlueWall 2012-04-07 14:22:14 -04:00
commit 931c28888b
1 changed files with 55 additions and 48 deletions

View File

@ -109,7 +109,7 @@ namespace OpenSim.Services.HypergridService
XInventoryFolder suitcase = GetSuitcaseXFolder(principalID); XInventoryFolder suitcase = GetSuitcaseXFolder(principalID);
XInventoryFolder root = GetRootXFolder(principalID); XInventoryFolder root = GetRootXFolder(principalID);
List<XInventoryFolder> tree = GetFolderTree(suitcase.folderID); List<XInventoryFolder> tree = GetFolderTree(principalID, suitcase.folderID);
if (tree == null || (tree != null && tree.Count == 0)) if (tree == null || (tree != null && tree.Count == 0))
return null; return null;
@ -119,7 +119,7 @@ namespace OpenSim.Services.HypergridService
folders.Add(ConvertToOpenSim(x)); folders.Add(ConvertToOpenSim(x));
} }
SetAsRootFolder(suitcase, root); SetAsNormalFolder(suitcase, root);
folders.Add(ConvertToOpenSim(suitcase)); folders.Add(ConvertToOpenSim(suitcase));
return folders; return folders;
@ -136,10 +136,10 @@ namespace OpenSim.Services.HypergridService
XInventoryFolder suitcase = GetSuitcaseXFolder(userID); XInventoryFolder suitcase = GetSuitcaseXFolder(userID);
XInventoryFolder root = GetRootXFolder(userID); XInventoryFolder root = GetRootXFolder(userID);
List<XInventoryFolder> tree = GetFolderTree(suitcase.folderID); List<XInventoryFolder> tree = GetFolderTree(userID, suitcase.folderID);
if (tree == null || (tree != null && tree.Count == 0)) if (tree == null || (tree != null && tree.Count == 0))
{ {
SetAsRootFolder(suitcase, root); SetAsNormalFolder(suitcase, root);
userInventory.Folders.Add(ConvertToOpenSim(suitcase)); userInventory.Folders.Add(ConvertToOpenSim(suitcase));
return userInventory; return userInventory;
} }
@ -164,7 +164,7 @@ namespace OpenSim.Services.HypergridService
userInventory.Items.AddRange(items); userInventory.Items.AddRange(items);
} }
SetAsRootFolder(suitcase, root); SetAsNormalFolder(suitcase, root);
userInventory.Folders.Add(ConvertToOpenSim(suitcase)); userInventory.Folders.Add(ConvertToOpenSim(suitcase));
m_log.DebugFormat("[HG SUITCASE INVENTORY SERVICE]: GetUserInventory for user {0} returning {1} folders and {2} items", m_log.DebugFormat("[HG SUITCASE INVENTORY SERVICE]: GetUserInventory for user {0} returning {1} folders and {2} items",
@ -175,8 +175,6 @@ namespace OpenSim.Services.HypergridService
public override InventoryFolderBase GetRootFolder(UUID principalID) public override InventoryFolderBase GetRootFolder(UUID principalID)
{ {
m_log.DebugFormat("[HG SUITCASE INVENTORY SERVICE]: GetRootFolder for {0}", principalID); m_log.DebugFormat("[HG SUITCASE INVENTORY SERVICE]: GetRootFolder for {0}", principalID);
if (m_Database == null)
m_log.ErrorFormat("[XXX]: m_Database is NULL!");
// Let's find out the local root folder // Let's find out the local root folder
XInventoryFolder root = GetRootXFolder(principalID); ; XInventoryFolder root = GetRootXFolder(principalID); ;
@ -202,7 +200,7 @@ namespace OpenSim.Services.HypergridService
CreateSystemFolders(principalID, suitcase.folderID); CreateSystemFolders(principalID, suitcase.folderID);
} }
SetAsRootFolder(suitcase, root); SetAsNormalFolder(suitcase, root);
return ConvertToOpenSim(suitcase); return ConvertToOpenSim(suitcase);
} }
@ -271,9 +269,8 @@ namespace OpenSim.Services.HypergridService
public override InventoryCollection GetFolderContent(UUID principalID, UUID folderID) public override InventoryCollection GetFolderContent(UUID principalID, UUID folderID)
{ {
InventoryCollection coll = null; InventoryCollection coll = null;
XInventoryFolder suitcase = GetSuitcaseXFolder(principalID);
if (!IsWithinSuitcaseTree(folderID, suitcase)) if (!IsWithinSuitcaseTree(principalID, folderID))
return new InventoryCollection(); return new InventoryCollection();
coll = base.GetFolderContent(principalID, folderID); coll = base.GetFolderContent(principalID, folderID);
@ -290,9 +287,7 @@ namespace OpenSim.Services.HypergridService
{ {
// Let's do a bit of sanity checking, more than the base service does // Let's do a bit of sanity checking, more than the base service does
// make sure the given folder exists under the suitcase tree of this user // make sure the given folder exists under the suitcase tree of this user
XInventoryFolder suitcase = GetSuitcaseXFolder(principalID); if (!IsWithinSuitcaseTree(principalID, folderID))
if (!IsWithinSuitcaseTree(folderID, suitcase))
return new List<InventoryItemBase>(); return new List<InventoryItemBase>();
return base.GetFolderItems(principalID, folderID); return base.GetFolderItems(principalID, folderID);
@ -303,21 +298,27 @@ namespace OpenSim.Services.HypergridService
m_log.WarnFormat("[HG SUITCASE INVENTORY SERVICE]: AddFolder {0} {1}", folder.Name, folder.ParentID); m_log.WarnFormat("[HG SUITCASE INVENTORY SERVICE]: AddFolder {0} {1}", folder.Name, folder.ParentID);
// Let's do a bit of sanity checking, more than the base service does // Let's do a bit of sanity checking, more than the base service does
// make sure the given folder's parent folder exists under the suitcase tree of this user // make sure the given folder's parent folder exists under the suitcase tree of this user
XInventoryFolder suitcase = GetSuitcaseXFolder(folder.Owner);
if (!IsWithinSuitcaseTree(folder.ParentID, suitcase)) if (!IsWithinSuitcaseTree(folder.Owner, folder.ParentID))
return false; return false;
// OK, it's legit // OK, it's legit
return base.AddFolder(folder); if (base.AddFolder(folder))
{
List<XInventoryFolder> tree;
if (m_SuitcaseTrees.TryGetValue(folder.Owner, out tree))
tree.Add(ConvertFromOpenSim(folder));
return true;
}
return false;
} }
public override bool UpdateFolder(InventoryFolderBase folder) public override bool UpdateFolder(InventoryFolderBase folder)
{ {
XInventoryFolder suitcase = GetSuitcaseXFolder(folder.Owner);
m_log.DebugFormat("[HG SUITCASE INVENTORY SERVICE]: Update folder {0}, version {1}", folder.ID, folder.Version); m_log.DebugFormat("[HG SUITCASE INVENTORY SERVICE]: Update folder {0}, version {1}", folder.ID, folder.Version);
if (!IsWithinSuitcaseTree(folder.ID, suitcase)) if (!IsWithinSuitcaseTree(folder.Owner, folder.ID))
{ {
m_log.DebugFormat("[HG SUITCASE INVENTORY SERVICE]: folder {0} not within Suitcase tree", folder.Name); m_log.DebugFormat("[HG SUITCASE INVENTORY SERVICE]: folder {0} not within Suitcase tree", folder.Name);
return false; return false;
@ -329,9 +330,8 @@ namespace OpenSim.Services.HypergridService
public override bool MoveFolder(InventoryFolderBase folder) public override bool MoveFolder(InventoryFolderBase folder)
{ {
XInventoryFolder suitcase = GetSuitcaseXFolder(folder.Owner); if (!IsWithinSuitcaseTree(folder.Owner, folder.ID) ||
!IsWithinSuitcaseTree(folder.Owner, folder.ParentID))
if (!IsWithinSuitcaseTree(folder.ID, suitcase) || !IsWithinSuitcaseTree(folder.ParentID, suitcase))
return false; return false;
return base.MoveFolder(folder); return base.MoveFolder(folder);
@ -353,9 +353,7 @@ namespace OpenSim.Services.HypergridService
{ {
// Let's do a bit of sanity checking, more than the base service does // Let's do a bit of sanity checking, more than the base service does
// make sure the given folder's parent folder exists under the suitcase tree of this user // make sure the given folder's parent folder exists under the suitcase tree of this user
XInventoryFolder suitcase = GetSuitcaseXFolder(item.Owner); if (!IsWithinSuitcaseTree(item.Owner, item.Folder))
if (!IsWithinSuitcaseTree(item.Folder, suitcase))
return false; return false;
// OK, it's legit // OK, it's legit
@ -365,9 +363,7 @@ namespace OpenSim.Services.HypergridService
public override bool UpdateItem(InventoryItemBase item) public override bool UpdateItem(InventoryItemBase item)
{ {
XInventoryFolder suitcase = GetSuitcaseXFolder(item.Owner); if (!IsWithinSuitcaseTree(item.Owner, item.Folder))
if (!IsWithinSuitcaseTree(item.Folder, suitcase))
return false; return false;
return base.UpdateItem(item); return base.UpdateItem(item);
@ -377,9 +373,7 @@ namespace OpenSim.Services.HypergridService
{ {
// Principal is b0rked. *sigh* // Principal is b0rked. *sigh*
XInventoryFolder suitcase = GetSuitcaseXFolder(items[0].Owner); if (!IsWithinSuitcaseTree(items[0].Owner, items[0].Folder))
if (!IsWithinSuitcaseTree(items[0].Folder, suitcase))
return false; return false;
return base.MoveItems(principalID, items); return base.MoveItems(principalID, items);
@ -400,15 +394,8 @@ namespace OpenSim.Services.HypergridService
item.Name, item.ID, item.Folder); item.Name, item.ID, item.Folder);
return null; return null;
} }
XInventoryFolder suitcase = GetSuitcaseXFolder(it.Owner);
if (suitcase == null)
{
m_log.DebugFormat("[HG SUITCASE INVENTORY SERVICE]: Root or Suitcase are null for user {0}",
it.Owner);
return null;
}
if (!IsWithinSuitcaseTree(it.Folder, suitcase)) if (!IsWithinSuitcaseTree(it.Owner, it.Folder))
{ {
m_log.DebugFormat("[HG SUITCASE INVENTORY SERVICE]: Item {0} (folder {1}) is not within Suitcase", m_log.DebugFormat("[HG SUITCASE INVENTORY SERVICE]: Item {0} (folder {1}) is not within Suitcase",
it.Name, it.Folder); it.Name, it.Folder);
@ -431,9 +418,7 @@ namespace OpenSim.Services.HypergridService
if (f != null) if (f != null)
{ {
XInventoryFolder suitcase = GetSuitcaseXFolder(f.Owner); if (!IsWithinSuitcaseTree(f.Owner, f.ID))
if (!IsWithinSuitcaseTree(f.ID, suitcase))
return null; return null;
} }
@ -481,22 +466,37 @@ namespace OpenSim.Services.HypergridService
if (folders != null && folders.Length > 0) if (folders != null && folders.Length > 0)
return folders[0]; return folders[0];
// check to see if we have the old Suitcase folder
folders = m_Database.GetFolders(
new string[] { "agentID", "folderName", "parentFolderID" },
new string[] { principalID.ToString(), "My Suitcase", UUID.Zero.ToString() });
if (folders != null && folders.Length > 0)
{
// Move it to under the root folder
XInventoryFolder root = GetRootXFolder(principalID);
folders[0].parentFolderID = root.folderID;
folders[0].type = 100;
m_Database.StoreFolder(folders[0]);
return folders[0];
}
return null; return null;
} }
private void SetAsRootFolder(XInventoryFolder suitcase, XInventoryFolder root) private void SetAsNormalFolder(XInventoryFolder suitcase, XInventoryFolder root)
{ {
suitcase.type = (short)AssetType.Folder; suitcase.type = (short)AssetType.Folder;
} }
private List<XInventoryFolder> GetFolderTree(UUID folder) private List<XInventoryFolder> GetFolderTree(UUID principalID, UUID folder)
{ {
List<XInventoryFolder> t = null; List<XInventoryFolder> t = null;
if (m_SuitcaseTrees.TryGetValue(folder, out t)) if (m_SuitcaseTrees.TryGetValue(principalID, out t))
return t; return t;
t = GetFolderTreeRecursive(folder); t = GetFolderTreeRecursive(folder);
m_SuitcaseTrees.AddOrUpdate(folder, t, 120); m_SuitcaseTrees.AddOrUpdate(principalID, t, 5*60); // 5minutes
return t; return t;
} }
@ -528,11 +528,18 @@ namespace OpenSim.Services.HypergridService
/// <param name="root"></param> /// <param name="root"></param>
/// <param name="suitcase"></param> /// <param name="suitcase"></param>
/// <returns></returns> /// <returns></returns>
private bool IsWithinSuitcaseTree(UUID folderID, XInventoryFolder suitcase) private bool IsWithinSuitcaseTree(UUID principalID, UUID folderID)
{ {
XInventoryFolder suitcase = GetSuitcaseXFolder(principalID);
if (suitcase == null)
{
m_log.WarnFormat("[HG SUITCASE INVENTORY SERVICE]: User {0} does not have a Suitcase folder", principalID);
return false;
}
List<XInventoryFolder> tree = new List<XInventoryFolder>(); List<XInventoryFolder> tree = new List<XInventoryFolder>();
tree.Add(suitcase); // Warp! the tree is the real root folder plus the children of the suitcase folder tree.Add(suitcase); // Warp! the tree is the real root folder plus the children of the suitcase folder
tree.AddRange(GetFolderTree(suitcase.folderID)); tree.AddRange(GetFolderTree(principalID, suitcase.folderID));
XInventoryFolder f = tree.Find(delegate(XInventoryFolder fl) XInventoryFolder f = tree.Find(delegate(XInventoryFolder fl)
{ {
if (fl.folderID == folderID) return true; if (fl.folderID == folderID) return true;