docs: public CmsLock removeResource(CmsDbContext dbc, CmsResource resource, boolean forceUnlock, boolean removeSystemLock)
      throws CmsException {
  
          String resourcename = resource.getRootPath();
          CmsLock lock = getLock(dbc, resource).getEditionLock();
  
          // check some abort conditions first
          if (!lock.isNullLock()) {
              // the resource is locked by another user or in other project
              if (!forceUnlock && (!lock.isOwnedInProjectBy(dbc.currentUser(), dbc.currentProject()))) {
                  throw new CmsLockException(
                      Messages.get().container(Messages.ERR_RESOURCE_UNLOCK_1, dbc.removeSiteRoot(resourcename)));
              }
  
              // sub-resources of a locked folder can't be unlocked
              if (!forceUnlock && lock.isInherited()) {
                  throw new CmsLockException(
                      Messages.get().container(Messages.ERR_UNLOCK_LOCK_INHERITED_1, dbc.removeSiteRoot(resourcename)));
              }
          }
  
          // remove the lock and clean-up stuff
          if (lock.isExclusive()) {
              if (resource.isFolder()) {
                  // in case of a folder, remove any exclusive locks on sub-resources that probably have
                  // been upgraded from an inherited lock when the user edited a resource
                  Iterator<CmsLock> itLocks = OpenCms.getMemoryMonitor().getAllCachedLocks().iterator();
                  while (itLocks.hasNext()) {
                      String lockedPath = (itLocks.next()).getResourceName();
                      if (lockedPath.startsWith(resourcename) && !lockedPath.equals(resourcename)) {
                          // remove the exclusive locked sub-resource
                          unlockResource(lockedPath, false);
                      }
                  }
              }
              if (removeSystemLock) {
                  unlockResource(resourcename, true);
              }
              unlockResource(resourcename, false);
              return lock;
          }
  
          if (lock.getType().isSharedExclusive()) {
              List<String> locks = OpenCms.getMemoryMonitor().getAllCachedLockPaths();
              // when a resource with a shared lock gets unlocked, fetch all siblings of the resource
              // to the same content record to identify the exclusive locked sibling
              List<CmsResource> siblings = internalReadSiblings(dbc, resource);
              for (int i = 0; i < siblings.size(); i++) {
                  CmsResource sibling = siblings.get(i);
                  if (locks.contains(sibling.getRootPath())) {
                      // remove the exclusive locked sibling
                      if (removeSystemLock) {
                          unlockResource(sibling.getRootPath(), true);
                      }
                      unlockResource(sibling.getRootPath(), false);
                      break; // it can only be one!
                  }
              }
              return lock;
          }
  
          // remove system locks only if explicit required
          if (removeSystemLock && !getLock(dbc, resource).getSystemLock().isUnlocked()) {
              return unlockResource(resourcename, true);
          }
          return lock;
      }