public ExtendedGroupRecord GetGroupRecord(string RequestingAgentID, UUID GroupID, string GroupName)
        {
            if (GroupID == UUID.Zero && (GroupName == null || (GroupName != null && GroupName == string.Empty)))
            {
                return(null);
            }

            Dictionary <string, object> sendData = new Dictionary <string, object>();

            if (GroupID != UUID.Zero)
            {
                sendData["GroupID"] = GroupID.ToString();
            }
            if (!string.IsNullOrEmpty(GroupName))
            {
                sendData["Name"] = GroupsDataUtils.Sanitize(GroupName);
            }

            sendData["RequestingAgentID"] = RequestingAgentID;

            Dictionary <string, object> ret = MakeRequest("GETGROUP", sendData);

            if (ret == null || (ret != null && (!ret.ContainsKey("RESULT") || ret["RESULT"].ToString() == "NULL")))
            {
                return(null);
            }

            return(GroupsDataUtils.GroupRecord((Dictionary <string, object>)ret["RESULT"]));
        }
        public ExtendedGroupRecord UpdateGroup(string RequestingAgentID, UUID groupID, string charter, bool showInList, UUID insigniaID, int membershipFee, bool openEnrollment, bool allowPublish, bool maturePublish)
        {
            ExtendedGroupRecord rec = new ExtendedGroupRecord();

            rec.AllowPublish   = allowPublish;
            rec.Charter        = charter;
            rec.GroupPicture   = insigniaID;
            rec.MaturePublish  = maturePublish;
            rec.GroupID        = groupID;
            rec.MembershipFee  = membershipFee;
            rec.OpenEnrollment = openEnrollment;
            rec.ShowInList     = showInList;

            Dictionary <string, object> sendData = GroupsDataUtils.GroupRecord(rec);

            sendData["RequestingAgentID"] = RequestingAgentID;
            sendData["OP"] = "UPDATE";
            Dictionary <string, object> ret = MakeRequest("PUTGROUP", sendData);

            if (ret == null || (ret != null && (!ret.ContainsKey("RESULT") || ret["RESULT"].ToString() == "NULL")))
            {
                return(null);
            }

            return(GroupsDataUtils.GroupRecord((Dictionary <string, object>)ret["RESULT"]));
        }
        byte[] HandleAddOrUpdateGroup(Dictionary <string, object> request)
        {
            Dictionary <string, object> result = new Dictionary <string, object>();

            ExtendedGroupRecord grec = GroupsDataUtils.GroupRecord(request);

            if (!request.ContainsKey("RequestingAgentID") || !request.ContainsKey("OP"))
            {
                NullResult(result, "Bad network data");
            }

            else
            {
                string RequestingAgentID = request["RequestingAgentID"].ToString();
                string reason            = string.Empty;
                string op = request["OP"].ToString();
                if (op == "ADD")
                {
                    grec.GroupID = m_GroupsService.CreateGroup(RequestingAgentID, grec.GroupName, grec.Charter, grec.ShowInList, grec.GroupPicture, grec.MembershipFee,
                                                               grec.OpenEnrollment, grec.AllowPublish, grec.MaturePublish, grec.FounderID, out reason);
                }
                else if (op == "UPDATE")
                {
                    m_GroupsService.UpdateGroup(RequestingAgentID, grec.GroupID, grec.Charter, grec.ShowInList, grec.GroupPicture, grec.MembershipFee,
                                                grec.OpenEnrollment, grec.AllowPublish, grec.MaturePublish);
                }

                if (grec.GroupID != UUID.Zero)
                {
                    grec = m_GroupsService.GetGroupRecord(RequestingAgentID, grec.GroupID);
                    if (grec == null)
                    {
                        NullResult(result, "Internal Error");
                    }
                    else
                    {
                        result["RESULT"] = GroupsDataUtils.GroupRecord(grec);
                    }
                }
                else
                {
                    NullResult(result, reason);
                }
            }

            string xmlString = ServerUtils.BuildXmlResponse(result);

            //m_log.DebugFormat("[XXX]: resp string: {0}", xmlString);
            return(Util.UTF8NoBomEncoding.GetBytes(xmlString));
        }
        byte[] HandleGetGroup(Dictionary <string, object> request)
        {
            Dictionary <string, object> result = new Dictionary <string, object>();

            if (!request.ContainsKey("RequestingAgentID") || !request.ContainsKey("AccessToken"))
            {
                NullResult(result, "Bad network data");
            }
            else
            {
                string RequestingAgentID = request["RequestingAgentID"].ToString();
                string token             = request["AccessToken"].ToString();

                UUID   groupID   = UUID.Zero;
                string groupName = string.Empty;

                if (request.ContainsKey("GroupID"))
                {
                    groupID = new UUID(request["GroupID"].ToString());
                }
                if (request.ContainsKey("Name"))
                {
                    groupName = request["Name"].ToString();
                }

                ExtendedGroupRecord grec = m_GroupsService.GetGroupRecord(RequestingAgentID, groupID, groupName, token);
                if (grec == null)
                {
                    NullResult(result, "Group not found");
                }
                else
                {
                    result["RESULT"] = GroupsDataUtils.GroupRecord(grec);
                }
            }

            string xmlString = ServerUtils.BuildXmlResponse(result);

            //m_log.DebugFormat("[XXX]: resp string: {0}", xmlString);
            return(Util.UTF8NoBomEncoding.GetBytes(xmlString));
        }
        public ExtendedGroupRecord CreateGroup(string RequestingAgentID, string name, string charter, bool showInList, UUID insigniaID, int membershipFee, bool openEnrollment,
                                               bool allowPublish, bool maturePublish, UUID founderID, out string reason)
        {
            reason = string.Empty;

            ExtendedGroupRecord rec = new ExtendedGroupRecord();

            rec.AllowPublish   = allowPublish;
            rec.Charter        = charter;
            rec.FounderID      = founderID;
            rec.GroupName      = name;
            rec.GroupPicture   = insigniaID;
            rec.MaturePublish  = maturePublish;
            rec.MembershipFee  = membershipFee;
            rec.OpenEnrollment = openEnrollment;
            rec.ShowInList     = showInList;

            Dictionary <string, object> sendData = GroupsDataUtils.GroupRecord(rec);

            sendData["RequestingAgentID"] = RequestingAgentID;
            sendData["OP"] = "ADD";
            Dictionary <string, object> ret = MakeRequest("PUTGROUP", sendData);

            if (ret == null)
            {
                return(null);
            }

            if (ret["RESULT"].ToString() == "NULL")
            {
                reason = ret["REASON"].ToString();
                return(null);
            }

            return(GroupsDataUtils.GroupRecord((Dictionary <string, object>)ret["RESULT"]));
        }