AEMManager.SlingDavExServlet.EnableDavEx C# (CSharp) Method

EnableDavEx() private method

private EnableDavEx ( ) : void
return void
        private void EnableDavEx()
        {
            string configPostUrl = instance.UrlWithContextPath + "/apps/system/config/org.apache.sling.jcr.davex.impl.servlets.SlingDavExServlet";
              Stopwatch responseTimeStopwatch = new Stopwatch();
              try {
            mLog.Debug("Post davex servlet config to URL: " + configPostUrl);

            StringBuilder postData = new StringBuilder();
            AppendUrlEncoded(postData, "jcr:primaryType", "sling:OsgiConfig");
            AppendUrlEncoded(postData, "alias", "/crx/server");
            AppendUrlEncoded(postData, "dav.create-absolute-uri", "true");
            AppendUrlEncoded(postData, "dav.create-absolute-uri@TypeHint", "Boolean");
            ASCIIEncoding ascii = new ASCIIEncoding();
            byte[] postBytes = ascii.GetBytes(postData.ToString());

            WebRequest request = instance.WebRequestCreate(configPostUrl);
            request.Method = "POST";
            request.Timeout = AEMManager.Properties.Settings.Default.BundleListTimeout;
            request.ContentType = "application/x-www-form-urlencoded";
            request.ContentLength = postBytes.Length;

            Stream postStream = request.GetRequestStream();
            postStream.Write(postBytes, 0, postBytes.Length);
            postStream.Flush();
            postStream.Close();

            responseTimeStopwatch.Start();
            using (WebResponse response = request.GetResponse()) {
              responseTimeStopwatch.Stop();
            }
              }
              catch (WebException ex) {
            if (ex.Status == WebExceptionStatus.Timeout) {
              throw new Exception("Unable to connect to " + configPostUrl + " due to timeout. "
            + "Configured timeout: " + AEMManager.Properties.Settings.Default.BundleListTimeout + "ms, "
            + "measured response time: " + responseTimeStopwatch.ElapsedMilliseconds + "ms");
            }
            else {
              throw new Exception("Unable to connect to " + configPostUrl + ": " + ex.Message);
            }
              }
              catch (Exception ex) {
            throw new Exception("Error posting DavEx config to URL: " + configPostUrl, ex);
              }
        }