code: public void lockResource(CmsRequestContext context, CmsResource resource, CmsLockType type) throws CmsException {
  
          CmsDbContext dbc = m_dbContextFactory.getDbContext(context);
          try {
              checkOfflineProject(dbc);
              checkPermissions(dbc, resource, CmsPermissionSet.ACCESS_WRITE, false, CmsResourceFilter.ALL);
              m_driverManager.lockResource(dbc, resource, type);
          } catch (Exception e) {
              CmsMessageContainer messageContainer;
              if (e instanceof CmsLockException) {
                  messageContainer = ((CmsLockException)e).getMessageContainer();
              } else {
                  messageContainer = Messages.get().container(
                      Messages.ERR_LOCK_RESOURCE_2,
                      context.getSitePath(resource),
                      type.toString());
              }
              dbc.report(null, messageContainer, e);
          } finally {
              dbc.clear();
          }
      }
docs: Locks a resource.<p>
  
  The <code>type</code> parameter controls what kind of lock is used.<br>
  Possible values for this parameter are: <br>
  <ul>
  <li><code>{@link org.opencms.lock.CmsLockType#EXCLUSIVE}</code></li>
  <li><code>{@link org.opencms.lock.CmsLockType#TEMPORARY}</code></li>
  <li><code>{@link org.opencms.lock.CmsLockType#PUBLISH}</code></li>
  </ul><p>
  
  @param context the current request context
  @param resource the resource to lock
  @param type type of the lock
  
  @throws CmsException if something goes wrong
  
  @see CmsObject#lockResource(String)
  @see CmsObject#lockResourceTemporary(String)
  @see org.opencms.file.types.I_CmsResourceType#lockResource(CmsObject, CmsSecurityManager, CmsResource, CmsLockType)