/// <inheritdoc />
        public async Task <IWebDavResult> UnlockAsync(string path, LockTokenHeader stateToken, CancellationToken cancellationToken)
        {
            if (_lockManager == null)
            {
                throw new NotSupportedException();
            }

            var releaseStatus = await _lockManager.ReleaseAsync(path, stateToken.StateToken, cancellationToken).ConfigureAwait(false);

            if (releaseStatus != LockReleaseStatus.Success)
            {
                var href = new Uri(_context.PublicControllerUrl, path);
                href = new Uri("/" + _context.PublicRootUrl.MakeRelativeUri(href).OriginalString);
                return(new WebDavResult <error>(
                           WebDavStatusCode.Conflict,
                           new error()
                {
                    ItemsElementName = new[] { ItemsChoiceType.locktokenmatchesrequesturi, },
                    Items = new object[]
                    {
                        new errorNoconflictinglock()
                        {
                            href = new[] { href.OriginalString },
                        },
                    },
                }));
            }

            return(new WebDavResult(WebDavStatusCode.NoContent));
        }
Exemple #2
0
 /// <inheritdoc />
 public Task <IWebDavResult> UnlockAsync(string path, LockTokenHeader stateToken, CancellationToken cancellationToken)
 {
     if (_unlockHandler == null)
     {
         throw new NotSupportedException();
     }
     return(_unlockHandler.UnlockAsync(path, stateToken, cancellationToken));
 }
Exemple #3
0
        public async Task <IActionResult> UnlockAsync(
            string path,
            [FromHeader(Name = "Lock-Token")] string lockToken,
            CancellationToken cancellationToken = default(CancellationToken))
        {
            if (_dispatcher.Class2 == null)
            {
                throw new NotSupportedException();
            }

            if (string.IsNullOrEmpty(lockToken))
            {
                return(new WebDavIndirectResult(_dispatcher, new WebDavResult(WebDavStatusCode.BadRequest), _responseLogger));
            }
            var lt     = LockTokenHeader.Parse(lockToken);
            var result = await _dispatcher.Class2.UnlockAsync(path ?? string.Empty, lt, cancellationToken).ConfigureAwait(false);

            return(new WebDavIndirectResult(_dispatcher, result, _responseLogger));
        }