code: private void lockTemporary(CmsResource resource) throws CmsException {
  
          CmsObject cms = getCms();
          CmsUser user = cms.getRequestContext().getCurrentUser();
          CmsLock lock = cms.getLock(resource);
          if (!lock.isOwnedBy(user)) {
              cms.lockResourceTemporary(resource);
          } else if (!lock.isOwnedInProjectBy(user, cms.getRequestContext().getCurrentProject())) {
              cms.changeLock(resource);
          }
      }
docs: Locks the given resource temporarily.<p>
  
  @param resource the resource to lock
  
  @throws CmsException if locking fails