Esempio n. 1
0
        /// <inheritdoc />
        public async Task <IWebDavResult> RefreshLockAsync(string path, IfHeader ifHeader, TimeoutHeader timeoutHeader, CancellationToken cancellationToken)
        {
            if (_lockManager == null)
            {
                throw new NotSupportedException();
            }

            if (ifHeader.Lists.Any(x => x.Path.IsAbsoluteUri))
            {
                throw new InvalidOperationException("A Resource-Tag pointing to a different server or application isn't supported.");
            }

            var timeout = _timeoutPolicy?.SelectTimeout(
                timeoutHeader?.Values ?? new[] { TimeoutHeader.Infinite })
                          ?? TimeoutHeader.Infinite;

            var result = await _lockManager.RefreshLockAsync(_rootFileSystem, ifHeader, timeout, cancellationToken);

            if (result.ErrorResponse != null)
            {
                return(new WebDavResult <error>(WebDavStatusCode.PreconditionFailed, result.ErrorResponse.error));
            }

            Debug.Assert(result.RefreshedLocks != null, "result.RefreshedLocks != null");
            var prop = new prop()
            {
                Any = result.RefreshedLocks.Select(x => new XElement(WebDavXml.Dav + "lockdiscovery", x.ToXElement())).ToArray(),
            };

            return(new WebDavResult <prop>(WebDavStatusCode.OK, prop));
        }