code: public void deleteCategory(CmsObject cms, String categoryPath, String referencePath) throws CmsException {
  
          CmsCategory category = readCategory(cms, categoryPath, referencePath);
          String folderPath = cms.getRequestContext().removeSiteRoot(category.getRootPath());
          CmsLock lock = cms.getLock(folderPath);
          if (lock.isNullLock()) {
              cms.lockResource(folderPath);
          } else if (lock.isLockableBy(cms.getRequestContext().getCurrentUser())) {
              cms.changeLock(folderPath);
          }
          cms.deleteResource(folderPath, CmsResource.DELETE_PRESERVE_SIBLINGS);
      }
docs: Deletes the category identified by the given path.<p>
  
  Only the most global category matching the given category path for the
  given resource will be affected.<p>
  
  This method will try to lock the involved resource.<p>
  
  @param cms the current cms context
  @param categoryPath the path of the category to delete
  @param referencePath the reference path to find the category repositories
  
  @throws CmsException if something goes wrong