public void Handle(RemoveFileLockCommand command) { File file = fileRepository.GetById(command.FileId); UserDto lockOwner = fileLockingService.GetRequiredLockOwner(file); if (lockOwner.Id != currentUser.Id) { throw new PermissionException("The current user is not the lock owner"); } fileLockingService.Unlock(file, currentUser.ToDomainUser()); UserDto newLockOwner = fileLockingService.GetLockOwner(file); eventBus.PublishAfterCommit <FileLockChangedEvent, FileLockChangedMessage>( new FileLockChangedMessage(command.FileId, FileLockDto.ForUser(newLockOwner))); }
public void Dispose() { fileLockingService.Unlock(lockedFile, lockOwner); }