docs: public void addResource(CmsDbContext dbc, CmsResource resource, CmsUser user, CmsProject project, CmsLockType type)
      throws CmsLockException, CmsException {
  
          // check the type
          if (!type.isSystem() && !type.isExclusive()) {
              // invalid type
              throw new CmsLockException(Messages.get().container(Messages.ERR_INVALID_LOCK_TYPE_1, type.toString()));
          }
  
          // get the current lock
          CmsLock currentLock = getLock(dbc, resource);
  
          // check lockability
          checkLockable(dbc, resource, user, project, type, currentLock);
  
          boolean needNewLock = true;
          // prevent shared locks get compromised
          if ((type.isExclusive()) && !(type.isTemporary() && currentLock.isInherited())) {
              if (!currentLock.getEditionLock().isUnlocked()) {
                  needNewLock = false;
              }
          }
  
          CmsLock newLock = CmsLock.getNullLock();
          if (needNewLock) {
              // lock the resource
              newLock = new CmsLock(resource.getRootPath(), user.getId(), project, type);
              lockResource(newLock);
          }
  
          // handle collisions with exclusive locked sub-resources in case of a folder
          if (resource.isFolder() && newLock.getSystemLock().isUnlocked()) {
              String resourceName = resource.getRootPath();
              Iterator<CmsLock> itLocks = OpenCms.getMemoryMonitor().getAllCachedLocks().iterator();
              while (itLocks.hasNext()) {
                  CmsLock lock = itLocks.next();
                  String lockedPath = lock.getResourceName();
                  if (lockedPath.startsWith(resourceName) && !lockedPath.equals(resourceName)) {
                      unlockResource(lockedPath, false);
                  }
              }
          }
      }