public string DeleteKey(UUID experience, string key)
 {
     return(m_service.DeleteKey(experience, key));
 }
        private byte[] AccessKeyValueDatabase(Dictionary <string, object> request)
        {
            UUID experience_id;

            if (!UUID.TryParse(request["EXPERIENCE"].ToString(), out experience_id))
            {
                return(FailureResult());
            }

            if (request.ContainsKey("ACTION") == false)
            {
                return(FailureResult());
            }

            string action = request["ACTION"].ToString();

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

            if (action == "GET")
            {
                if (request.ContainsKey("KEY") == false)
                {
                    return(FailureResult());
                }

                string key = request["KEY"].ToString();

                string get = m_service.GetKeyValue(experience_id, key);

                if (get != null)
                {
                    result.Add("result", "success");
                    result.Add("value", get);
                }
                else
                {
                    result.Add("result", "missing");
                }
            }
            else if (action == "CREATE")
            {
                if (request.ContainsKey("KEY") == false || request.ContainsKey("VALUE") == false)
                {
                    return(FailureResult());
                }

                string key = request["KEY"].ToString();
                string val = request["VALUE"].ToString();

                string get = m_service.GetKeyValue(experience_id, key);

                if (get == null)
                {
                    result.Add("result", m_service.CreateKeyValue(experience_id, key, val));
                }
                else
                {
                    result.Add("result", "exists");
                }
            }
            else if (action == "UPDATE")
            {
                if (request.ContainsKey("KEY") == false || request.ContainsKey("VALUE") == false || request.ContainsKey("CHECK") == false)
                {
                    return(FailureResult());
                }

                string key   = request["KEY"].ToString();
                string val   = request["VALUE"].ToString();
                bool   check = request["CHECK"].ToString() == "TRUE";

                string original = string.Empty;
                if (check)
                {
                    if (request.ContainsKey("ORIGINAL") == false)
                    {
                        return(FailureResult());
                    }
                    else
                    {
                        original = request["ORIGINAL"].ToString();
                    }
                }

                result.Add("result", m_service.UpdateKeyValue(experience_id, key, val, check, original));
            }
            else if (action == "DELETE")
            {
                if (request.ContainsKey("KEY") == false)
                {
                    return(FailureResult());
                }

                string key = request["KEY"].ToString();

                result.Add("result", m_service.DeleteKey(experience_id, key));
            }
            else if (action == "COUNT")
            {
                int count = m_service.GetKeyCount(experience_id);
                result.Add("result", "success");
                result.Add("count", count);
            }
            else if (action == "GETKEYS")
            {
                if (request.ContainsKey("START") == false || request.ContainsKey("COUNT") == false)
                {
                    return(FailureResult());
                }

                int start = int.Parse(request["START"].ToString());
                int count = int.Parse(request["COUNT"].ToString());

                string[] keys = m_service.GetKeys(experience_id, start, count);

                int i = 0;
                foreach (var str in keys)
                {
                    result.Add("key_" + i++, str);
                }
            }
            else if (action == "SIZE")
            {
                int size = m_service.GetSize(experience_id);
                result.Add("result", "success");
                result.Add("count", size);
            }

            string xmlString = ServerUtils.BuildXmlResponse(result);

            return(Util.UTF8NoBomEncoding.GetBytes(xmlString));
        }
 public string DeleteKey(UUID experience, string key)
 {
     return(m_remoteConnector.DeleteKey(experience, key));
 }