code: protected CmsLockInfo getLock(String sitepath) throws CmsException {
  
          CmsObject cms = getCmsObject();
          CmsUser user = cms.getRequestContext().getCurrentUser();
          CmsLock lock = cms.getLock(sitepath);
          if (lock.isOwnedBy(user)) {
              return CmsLockInfo.forSuccess();
          }
          if (lock.getUserId().isNullUUID()) {
              cms.lockResourceTemporary(sitepath);
              return CmsLockInfo.forSuccess();
          }
          CmsUser owner = cms.readUser(lock.getUserId());
          return CmsLockInfo.forLockedResource(owner.getName());
      }
docs: Helper method for locking a resource which returns some information on whether the locking
  failed, and why.<p>
  
  @param sitepath the site path of the resource to lock
  @return the locking information
  
  @throws CmsException if something went wrong