private async Task <WopiResponse> ProcessRefreshLockRequestAsync(RefreshLockRequest wopiRequest, CancellationToken cancellationToken) { if (!int.TryParse(wopiRequest.FileId, out var contentId)) { return new WopiResponse { StatusCode = HttpStatusCode.NotFound } } ; if (!(await Node.LoadNodeAsync(contentId, cancellationToken).ConfigureAwait(false) is File file)) { return new WopiResponse { StatusCode = HttpStatusCode.NotFound } } ; var existingLock = SharedLock.GetLock(file.Id, CancellationToken.None); if (existingLock == null) { return(new WopiResponse { StatusCode = HttpStatusCode.Conflict, Headers = new Dictionary <string, string> { { WopiHeader.Lock, string.Empty }, { WopiHeader.LockFailureReason, "Unlocked" } } }); } if (existingLock != wopiRequest.Lock) { return(new WopiResponse { StatusCode = HttpStatusCode.Conflict, Headers = new Dictionary <string, string> { { WopiHeader.Lock, existingLock }, { WopiHeader.LockFailureReason, "LockedByAnother" } } }); } SharedLock.RefreshLock(contentId, existingLock, CancellationToken.None); return(new WopiResponse { StatusCode = HttpStatusCode.OK }); }
private WopiResponse ProcessRefreshLockRequest(RefreshLockRequest wopiReq) { if (!int.TryParse(wopiReq.FileId, out var contentId)) { return new WopiResponse { StatusCode = HttpStatusCode.NotFound } } ; if (!(Node.LoadNode(contentId) is File file)) { return new WopiResponse { StatusCode = HttpStatusCode.NotFound } } ; var existingLock = SharedLock.GetLock(file.Id); if (existingLock == null) { return(new WopiResponse { StatusCode = HttpStatusCode.Conflict, Headers = new Dictionary <string, string> { { WopiHeader.Lock, string.Empty }, { WopiHeader.LockFailureReason, "Unlocked" } } }); } if (existingLock != wopiReq.Lock) { return(new WopiResponse { StatusCode = HttpStatusCode.Conflict, Headers = new Dictionary <string, string> { { WopiHeader.Lock, existingLock }, { WopiHeader.LockFailureReason, "LockedByAnother" } } }); } SharedLock.RefreshLock(contentId, existingLock); return(new WopiResponse { StatusCode = HttpStatusCode.OK }); }