From 82690e138448ebac6456ab03dcca4b0a8a1cc57a Mon Sep 17 00:00:00 2001 From: Justin Clark-Casey (justincc) Date: Sat, 24 Nov 2012 02:43:31 +0000 Subject: Fix bug where loading an OAR with a deeded parcel would always set the parcel owner ID to the estate owner even if the group UUID was present. Aims to address http://opensimulator.org/mantis/view.php?id=6355 As part of this work, an incomplete IXGroupsData was added which currently only allows store/fetch/delete of group records (i.e. no membership data etc) This is subject to change and currently only an in-memory storage implementation exists for regression test purposes. --- .../Common/Mock/MockGroupsServicesConnector.cs | 77 +++++++++++++++++++++- .../Tests/Common/Mock/TestXInventoryDataPlugin.cs | 25 +------ 2 files changed, 76 insertions(+), 26 deletions(-) (limited to 'OpenSim/Tests') diff --git a/OpenSim/Tests/Common/Mock/MockGroupsServicesConnector.cs b/OpenSim/Tests/Common/Mock/MockGroupsServicesConnector.cs index 6fb9df1..3035cea 100644 --- a/OpenSim/Tests/Common/Mock/MockGroupsServicesConnector.cs +++ b/OpenSim/Tests/Common/Mock/MockGroupsServicesConnector.cs @@ -26,12 +26,15 @@ */ using System; +using System.Collections; using System.Collections.Generic; using System.Reflection; using log4net; using Mono.Addins; using Nini.Config; using OpenMetaverse; +using OpenSim.Data; +using OpenSim.Data.Null; using OpenSim.Framework; using OpenSim.Region.Framework.Interfaces; using OpenSim.Region.Framework.Scenes; @@ -44,6 +47,8 @@ namespace OpenSim.Tests.Common.Mock { private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); + IXGroupData m_data = new NullXGroupData(null, null); + public string Name { get { return "MockGroupsServicesConnector"; } @@ -84,7 +89,33 @@ namespace OpenSim.Tests.Common.Mock int membershipFee, bool openEnrollment, bool allowPublish, bool maturePublish, UUID founderID) { - return UUID.Zero; + XGroup group = new XGroup() + { + groupID = UUID.Random(), + ownerRoleID = UUID.Random(), + name = name, + charter = charter, + showInList = showInList, + insigniaID = insigniaID, + membershipFee = membershipFee, + openEnrollment = openEnrollment, + allowPublish = allowPublish, + maturePublish = maturePublish, + founderID = founderID, + everyonePowers = (ulong)XmlRpcGroupsServicesConnectorModule.DefaultEveryonePowers, + ownersPowers = (ulong)XmlRpcGroupsServicesConnectorModule.DefaultOwnerPowers + }; + + if (m_data.StoreGroup(group)) + { + m_log.DebugFormat("[MOCK GROUPS SERVICES CONNECTOR]: Created group {0} {1}", group.name, group.groupID); + return group.groupID; + } + else + { + m_log.ErrorFormat("[MOCK GROUPS SERVICES CONNECTOR]: Failed to create group {0}", name); + return UUID.Zero; + } } public void UpdateGroup(UUID requestingAgentID, UUID groupID, string charter, bool showInList, @@ -107,9 +138,49 @@ namespace OpenSim.Tests.Common.Mock { } - public GroupRecord GetGroupRecord(UUID requestingAgentID, UUID GroupID, string GroupName) + public GroupRecord GetGroupRecord(UUID requestingAgentID, UUID groupID, string groupName) { - return null; + m_log.DebugFormat( + "[MOCK GROUPS SERVICES CONNECTOR]: Processing GetGroupRecord() for groupID {0}, name {1}", + groupID, groupName); + + XGroup[] groups; + string field, val; + + if (groupID != UUID.Zero) + { + field = "groupID"; + val = groupID.ToString(); + } + else + { + field = "name"; + val = groupName; + } + + groups = m_data.GetGroups(field, val); + + if (groups.Length == 0) + return null; + + XGroup xg = groups[0]; + + GroupRecord gr = new GroupRecord() + { + GroupID = xg.groupID, + GroupName = xg.name, + AllowPublish = xg.allowPublish, + MaturePublish = xg.maturePublish, + Charter = xg.charter, + FounderID = xg.founderID, + // FIXME: group picture storage location unknown + MembershipFee = xg.membershipFee, + OpenEnrollment = xg.openEnrollment, + OwnerRoleID = xg.ownerRoleID, + ShowInList = xg.showInList + }; + + return gr; } public GroupProfileData GetMemberGroupProfile(UUID requestingAgentID, UUID GroupID, UUID AgentID) diff --git a/OpenSim/Tests/Common/Mock/TestXInventoryDataPlugin.cs b/OpenSim/Tests/Common/Mock/TestXInventoryDataPlugin.cs index f9bf768..ccbdf81 100644 --- a/OpenSim/Tests/Common/Mock/TestXInventoryDataPlugin.cs +++ b/OpenSim/Tests/Common/Mock/TestXInventoryDataPlugin.cs @@ -33,10 +33,11 @@ using log4net; using OpenMetaverse; using OpenSim.Framework; using OpenSim.Data; +using OpenSim.Data.Null; namespace OpenSim.Tests.Common.Mock { - public class TestXInventoryDataPlugin : IXInventoryData + public class TestXInventoryDataPlugin : NullGenericDataHandler, IXInventoryData { private Dictionary m_allFolders = new Dictionary(); private Dictionary m_allItems = new Dictionary(); @@ -58,28 +59,6 @@ namespace OpenSim.Tests.Common.Mock return origFolders.Select(f => f.Clone()).ToArray(); } - private List Get(string[] fields, string[] vals, List inputEntities) - { - List entities = inputEntities; - - for (int i = 0; i < fields.Length; i++) - { - entities - = entities.Where( - e => - { - FieldInfo fi = typeof(T).GetField(fields[i]); - if (fi == null) - throw new NotImplementedException(string.Format("No field {0} for val {1}", fields[i], vals[i])); - - return fi.GetValue(e).ToString() == vals[i]; - } - ).ToList(); - } - - return entities; - } - public bool StoreFolder(XInventoryFolder folder) { m_allFolders[folder.folderID] = folder.Clone(); -- cgit v1.1