Merge branch 'master' into careminster

avinationmerge
Melanie 2012-04-08 02:25:48 +01:00
commit a25d12d166
3 changed files with 72 additions and 50 deletions

View File

@ -107,9 +107,8 @@ namespace OpenSim.Services.HypergridService
public override List<InventoryFolderBase> GetInventorySkeleton(UUID principalID) public override List<InventoryFolderBase> GetInventorySkeleton(UUID principalID)
{ {
XInventoryFolder suitcase = GetSuitcaseXFolder(principalID); XInventoryFolder suitcase = GetSuitcaseXFolder(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 +118,7 @@ namespace OpenSim.Services.HypergridService
folders.Add(ConvertToOpenSim(x)); folders.Add(ConvertToOpenSim(x));
} }
SetAsRootFolder(suitcase, root); SetAsNormalFolder(suitcase);
folders.Add(ConvertToOpenSim(suitcase)); folders.Add(ConvertToOpenSim(suitcase));
return folders; return folders;
@ -134,12 +133,11 @@ namespace OpenSim.Services.HypergridService
userInventory.Items = new List<InventoryItemBase>(); userInventory.Items = new List<InventoryItemBase>();
XInventoryFolder suitcase = GetSuitcaseXFolder(userID); XInventoryFolder suitcase = GetSuitcaseXFolder(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);
userInventory.Folders.Add(ConvertToOpenSim(suitcase)); userInventory.Folders.Add(ConvertToOpenSim(suitcase));
return userInventory; return userInventory;
} }
@ -164,7 +162,7 @@ namespace OpenSim.Services.HypergridService
userInventory.Items.AddRange(items); userInventory.Items.AddRange(items);
} }
SetAsRootFolder(suitcase, root); SetAsNormalFolder(suitcase);
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,14 +173,13 @@ 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); ;
if (root == null) if (root == null)
{ {
m_log.WarnFormat("[HG SUITCASE INVENTORY SERVICE]: Unable to retrieve local root folder for user {0}", principalID); m_log.WarnFormat("[HG SUITCASE INVENTORY SERVICE]: Unable to retrieve local root folder for user {0}", principalID);
return null;
} }
// Warp! Root folder for travelers is the suitcase folder // Warp! Root folder for travelers is the suitcase folder
@ -202,7 +199,7 @@ namespace OpenSim.Services.HypergridService
CreateSystemFolders(principalID, suitcase.folderID); CreateSystemFolders(principalID, suitcase.folderID);
} }
SetAsRootFolder(suitcase, root); SetAsNormalFolder(suitcase);
return ConvertToOpenSim(suitcase); return ConvertToOpenSim(suitcase);
} }
@ -271,9 +268,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 +286,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 +297,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 +329,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 +352,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 +362,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 +372,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 +393,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 +417,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 +465,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)
{ {
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 +527,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;

View File

@ -319,6 +319,14 @@ ServiceConnectors = "8003/OpenSim.Server.Handlers.dll:AssetServiceConnector,8003
; password help: optional: page providing password assistance for users of your grid ; password help: optional: page providing password assistance for users of your grid
;password = http://127.0.0.1/password ;password = http://127.0.0.1/password
; HG address of the gatekeeper, if you have one
; this is the entry point for all the regions of the world
; gatekeeper = http://127.0.0.1:8002/
; HG user domain, if you have one
; this is the entry point for all user-related HG services
; uas = http://127.0.0.1:8002/
[GatekeeperService] [GatekeeperService]
LocalServiceModule = "OpenSim.Services.HypergridService.dll:GatekeeperService" LocalServiceModule = "OpenSim.Services.HypergridService.dll:GatekeeperService"
;; for the service ;; for the service

View File

@ -231,6 +231,14 @@
; currently unused ; currently unused
;password = http://127.0.0.1/password ;password = http://127.0.0.1/password
; HG address of the gatekeeper, if you have one
; this is the entry point for all the regions of the world
; gatekeeper = http://127.0.0.1:9000/
; HG user domain, if you have one
; this is the entry point for all user-related HG services
; uas = http://127.0.0.1:9000/
[MapImageService] [MapImageService]
; Set this if you want to change the default ; Set this if you want to change the default
; TilesStoragePath = "maptiles" ; TilesStoragePath = "maptiles"