Пример #1
0
            /// <summary>Return a Map suitable for conversion into JSON.</summary>
            /// <returns>A JSONish Map</returns>
            public virtual IDictionary <string, object> ToJson()
            {
                IDictionary <string, object> json  = new LinkedHashMap <string, object>();
                IDictionary <string, object> inner = new LinkedHashMap <string, object>();
                JSONArray statuses = new JSONArray();

                foreach (FSOperations.StatusPair s in statusPairs)
                {
                    statuses.AddItem(s.ToJsonInner(false));
                }
                inner[HttpFSFileSystem.FileStatusJson]  = statuses;
                json[HttpFSFileSystem.FileStatusesJson] = inner;
                return(json);
            }
Пример #2
0
        /// <summary>Converts an <code>AclStatus</code> object into a JSON object.</summary>
        /// <param name="aclStatus">AclStatus object</param>
        /// <returns>The JSON representation of the ACLs for the file</returns>
        private static IDictionary <string, object> AclStatusToJSON(AclStatus aclStatus)
        {
            IDictionary <string, object> json  = new LinkedHashMap <string, object>();
            IDictionary <string, object> inner = new LinkedHashMap <string, object>();
            JSONArray entriesArray             = new JSONArray();

            inner[HttpFSFileSystem.OwnerJson]        = aclStatus.GetOwner();
            inner[HttpFSFileSystem.GroupJson]        = aclStatus.GetGroup();
            inner[HttpFSFileSystem.AclStickyBitJson] = aclStatus.IsStickyBit();
            foreach (AclEntry e in aclStatus.GetEntries())
            {
                entriesArray.AddItem(e.ToString());
            }
            inner[HttpFSFileSystem.AclEntriesJson] = entriesArray;
            json[HttpFSFileSystem.AclStatusJson]   = inner;
            return(json);
        }
Пример #3
0
        /// <summary>Converts xAttrs to a JSON object.</summary>
        /// <param name="xAttrs">file xAttrs.</param>
        /// <param name="encoding">format of xattr values.</param>
        /// <returns>The JSON representation of the xAttrs.</returns>
        /// <exception cref="System.IO.IOException"></exception>
        private static IDictionary XAttrsToJSON(IDictionary <string, byte[]> xAttrs, XAttrCodec
                                                encoding)
        {
            IDictionary jsonMap   = new LinkedHashMap();
            JSONArray   jsonArray = new JSONArray();

            if (xAttrs != null)
            {
                foreach (KeyValuePair <string, byte[]> e in xAttrs)
                {
                    IDictionary json = new LinkedHashMap();
                    json[HttpFSFileSystem.XattrNameJson] = e.Key;
                    if (e.Value != null)
                    {
                        json[HttpFSFileSystem.XattrValueJson] = XAttrCodec.EncodeValue(e.Value, encoding);
                    }
                    jsonArray.AddItem(json);
                }
            }
            jsonMap[HttpFSFileSystem.XattrsJson] = jsonArray;
            return(jsonMap);
        }