Check if a resource is locked.

        If a resource has an explicit status we use that, else
        we defer to the parent resource lock status.
429802
def info(self, account_id, resource_id, parent_id):
        
        resource = self.record(account_id, resource_id)
        if resource is None and not parent_id:
            return {'ResourceId': resource_id,
                    'LockStatus': self.STATE_UNLOCKED}
        elif resource is None:
            parent = self.record(account_id, parent_id)
            if parent is None:
                return {'ResourceId': resource_id,
                        'ParentId': parent_id,
                        'LockStatus': self.STATE_UNLOCKED}
            parent['ResourceId'] = resource_id
            parent['ParentId'] = parent_id
            parent['LockType'] = 'parent'
            return parent
        if resource['ResourceId'].startswith('vpc-'):
            return resource
        if resource['ResourceId'].startswith('sg-'):
            return resource
947131
public function hasSharedLock($resource = null): bool
    {
        if (null !== $resource) {
            return isset($this->sharedLock[$this->getResourceId($resource)]);
        }

        return !empty($this->sharedLock);
    }
845938
function isLocked()
    {
        $userID = $this->attribute( 'contentobject_id' );
        $isNotLocked = eZUser::isEnabledAfterFailedLogin( $userID, true );
        return !$isNotLocked;
    }
919444
def lock(self, resource_id, region, account_id=None):
        
        account_id = self.get_account_id(account_id)
        return self.http.post(
            "%s/%s/locks/%s/lock" % (self.endpoint, account_id, resource_id),
            json={'region': region},
            auth=self.get_api_auth())
121687
function Locked(message, code_id) {
    Error.call(this);
    this.message = message || "resource is locked"
    this.code_id = code_id || null;
    this.statusCode = 423;
}
625085
def is_lock(lock):
    
    if lock is None:
        # Don't do useless tests
        return False

    for attr in "acquire", "release", "__enter__", "__exit__":
        if not hasattr(lock, attr):
            # Missing something
            return False

    # Same API as a lock
    return True
320475
public boolean isLocked(Session session, String path)
   {
      String repoPath = session.getRepository().hashCode() + "/" + session.getWorkspace().getName() + "/" + path;

      if (nullResourceLocks.get(repoPath) != null)
      {
         return true;
      }
      return false;
   }
228924
private boolean isLocked(Class entityType, String entityKey, Integer lockType)
            throws LockingException {
        IEntityLock[] locks = retrieveLocks(entityType, entityKey, lockType);
        return locks.length > 0;
    }
646217
protected void doUnlock(HttpServletRequest req, HttpServletResponse resp) {

        String path = getRelativePath(req);

        // Check if Webdav is read only
        if (m_readOnly) {

            resp.setStatus(CmsWebdavStatus.SC_FORBIDDEN);

            if (LOG.isDebugEnabled()) {
                LOG.debug(Messages.get().getBundle().key(Messages.LOG_WEBDAV_READ_ONLY_0));
            }

            return;
        }

        // Check if resource is locked
        if (isLocked(req)) {

            resp.setStatus(CmsWebdavStatus.SC_LOCKED);

            if (LOG.isDebugEnabled()) {
                LOG.debug(Messages.get().getBundle().key(Messages.LOG_ITEM_LOCKED_1, path));
            }

            return;
        }

        if (LOG.isDebugEnabled()) {
            LOG.debug(Messages.get().getBundle().key(Messages.LOG_UNLOCK_ITEM_0));
        }

        m_session.unlock(path);

        resp.setStatus(CmsWebdavStatus.SC_NO_CONTENT);
    }
241968
private CmsLock getSiblingsLock(List<CmsResource> siblings, String resourcename) {

        for (int i = 0; i < siblings.size(); i++) {
            CmsResource sibling = siblings.get(i);
            CmsLock exclusiveLock = getDirectLock(sibling.getRootPath());
            if (exclusiveLock != null) {
                // a sibling is already locked
                return internalSiblingLock(exclusiveLock, resourcename);
            }
        }
        // no locked siblings found
        return null;

    }
962437
public function isAllowed(Lock $lock, $action, Resource $resource = null)
    {
        return $this->resolve($lock, $action, $resource);
    }
1047375
def _ProcessLockAcquired(self):
        """"""
        try:
            is_locked = self._process_lock.acquire(timeout=self._lock_timeout)
            yield is_locked
        finally:
            if is_locked:
                self._process_lock.release()
47725
function isTaskLocked(task) {
  if(task.semaphore) {
    if(!task.semaphore.ttl) {
      throw new TypeError('TimeToLiveNotPresent');
    }
    return ( (timestamp() - task.semaphore.time) < task.semaphore.ttl );
  }
  return false;
}
3382
private boolean checkLock(CmsResource resource) throws CmsException {

        CmsLock lock = m_cms.getLock(resource);
        return lock.isUnlocked() || lock.getUserId().equals(m_cms.getRequestContext().getCurrentUser().getId());
    }
827769
private void internalLockResource(CmsLock lock, Map<String, CmsLock> locks) throws CmsLockException {

        CmsLock currentLock = null;
        if (locks == null) {
            currentLock = OpenCms.getMemoryMonitor().getCachedLock(lock.getResourceName());
        } else {
            currentLock = locks.get(lock.getResourceName());
        }
        if (currentLock != null) {
            if (currentLock.getSystemLock().equals(lock) || currentLock.getEditionLock().equals(lock)) {
                return;
            }
            if (!currentLock.getSystemLock().isUnlocked() && lock.getSystemLock().isUnlocked()) {
                lock.setRelatedLock(currentLock);
                if (locks == null) {
                    OpenCms.getMemoryMonitor().cacheLock(lock);
                } else {
                    locks.put(lock.getResourceName(), lock);
                }
            } else if (currentLock.getSystemLock().isUnlocked() && !lock.getSystemLock().isUnlocked()) {
                currentLock.setRelatedLock(lock);
            } else {
                throw new CmsLockException(
                    Messages.get().container(Messages.ERR_LOCK_ILLEGAL_STATE_2, currentLock, lock));
            }
        } else {
            if (locks == null) {
                OpenCms.getMemoryMonitor().cacheLock(lock);
            } else {
                locks.put(lock.getResourceName(), lock);
            }
        }
    }
1349712
def unlock(self, source_node, check_status=True):
        
        if self.status != self.S_LOCKED:
            raise RuntimeError("Trying to unlock a task with status %s" % self.status)

        self._status = self.S_READY
        if check_status: self.check_status()
        self.history.info("Unlocked by %s", source_node)
538965
public function hasExclusiveLock($resource = null): bool
    {
        if (null !== $resource) {
            return $this->exclusiveLock === $this->getResourceId($resource);
        }

        return null !== $this->exclusiveLock;
    }