SenseNet.Services.WebDav.Lock.GenerateLockResponse C# (CSharp) Method

GenerateLockResponse() public static method

public static GenerateLockResponse ( string path, HttpContext context ) : void
path string
context System.Web.HttpContext
return void
        public static void GenerateLockResponse(string path, HttpContext context) 
        {
            var timeout = GetRequestTimeout();

            context.Response.StatusCode = 200;

            var node = Node.LoadNode(path);
            if (node != null)
            {
                // if node is not checked out, it should not be opened for edit in word
                if (!node.Locked)
                {
                    context.Response.AddHeader("X-MSDAVEXT_Error", "589839; The%20file%20%22%22%20is%20not%20checked%20out%2e");
                    context.Response.StatusCode = 403;
                    context.Response.Flush();
                    return;
                }
                // if node is checked out by someone else, it should not be opened for edit in word
                if (node.LockedById != User.Current.Id)
                {
                    context.Response.StatusCode = 403;
                    context.Response.Flush();
                    return;
                }
                // sensenet special logic: if the doc is locked by someone else and we return 423, we will get a popup dialog: save a copy, notify, cancel. 
                // instead of this we return 403, and the doc will be displayed, but when clicking on the 'checkout' button we will get the above dialog
                //// if it is checked out by someone else, we should indicate that it is locked
                //if (node.LockedById != User.Current.Id)
                //{
                //    context.Response.StatusCode = 423;
                //    timeout = node.LockTimeout;
                //}
            }

            var writer = GetSuccessResult(node, timeout);
            if (writer != null)
            {
                writer.Flush();
                writer.BaseStream.Seek(0, System.IO.SeekOrigin.Begin);

                var reader = new System.IO.StreamReader(writer.BaseStream, System.Text.Encoding.UTF8);
                var ret = reader.ReadToEnd();

                context.Response.AddHeader("Content-Length", ret.Length.ToString());
                context.Response.Write(ret);

                //System.Diagnostics.Trace.Write(string.Concat("RESPONSE: ", ret));
            }

            context.Response.Flush();
            return;
        }
        private static System.Xml.XmlTextWriter GetSuccessResult(Node node, int timeout)