public function lockResource($userId, $resourceName)
    {
        $resource = $this->lockedResourceRepository->fromResourceNameByUser($userId, $resourceName);
        if (null === $resource) {
            if ( ! $this->isResourceFree($resourceName)) {
                throw new ResourceNotFreeException('exception_resource_locked');
            }

            $resourceClass = $this->lockedResourceRepository->getRepositoryObjectClassName();
            $resource = new $resourceClass();
            $values = array(
                'ResourceName' => $resourceName,
                'UserId' => $userId,
                'CreatedAt' => time(),
                'UpdatedAt' => time(),
            );
        } else {
            $values = array(
                'UpdatedAt' => time(),
            );
        }

        $result = $this->lockedResourceRepository
                       ->setRepositoryObject($resource)
                       ->save($values);
        if (false === $result) {
            throw new RuntimeException('exception_resource_locking_error');
        }
    }