docs: private CmsContentDefinition readContentDefinition(
          CmsFile file,
          CmsXmlContent content,
          String entityId,
          String clientId,
          Locale locale,
          boolean newLocale,
          Locale mainLocale,
          CmsEntity editedLocaleEntity,
          Map<String, String> settingPresets)
      throws CmsException {
  
          long timer = 0;
          if (LOG.isDebugEnabled()) {
              timer = System.currentTimeMillis();
          }
          CmsObject cms = getCmsObject();
          List<Locale> availableLocalesList = OpenCms.getLocaleManager().getAvailableLocales(cms, file);
          if (!availableLocalesList.contains(locale)) {
              availableLocalesList.retainAll(content.getLocales());
              List<Locale> defaultLocales = OpenCms.getLocaleManager().getDefaultLocales(cms, file);
              Locale replacementLocale = OpenCms.getLocaleManager().getBestMatchingLocale(
                  locale,
                  defaultLocales,
                  availableLocalesList);
              LOG.info(
                  "Can't edit locale "
                      + locale
                      + " of file "
                      + file.getRootPath()
                      + " because it is not configured as available locale. Using locale "
                      + replacementLocale
                      + " instead.");
              locale = replacementLocale;
              entityId = CmsContentDefinition.uuidToEntityId(file.getStructureId(), locale.toString());
          }
  
          if (CmsStringUtil.isEmptyOrWhitespaceOnly(entityId)) {
              entityId = CmsContentDefinition.uuidToEntityId(file.getStructureId(), locale.toString());
          }
          boolean performedAutoCorrection = checkAutoCorrection(cms, content);
          if (performedAutoCorrection) {
              content.initDocument();
          }
          if (LOG.isDebugEnabled()) {
              LOG.debug(
                  Messages.get().getBundle().key(
                      Messages.LOG_TAKE_UNMARSHALING_TIME_1,
                      "" + (System.currentTimeMillis() - timer)));
          }
          CmsContentTypeVisitor visitor = new CmsContentTypeVisitor(cms, file, locale);
          if (LOG.isDebugEnabled()) {
              timer = System.currentTimeMillis();
          }
          visitor.visitTypes(content.getContentDefinition(), getWorkplaceLocale(cms));
          if (LOG.isDebugEnabled()) {
              LOG.debug(
                  Messages.get().getBundle().key(
                      Messages.LOG_TAKE_VISITING_TYPES_TIME_1,
                      "" + (System.currentTimeMillis() - timer)));
          }
          CmsEntity entity = null;
          Map<String, String> syncValues = new HashMap<String, String>();
          Collection<String> skipPaths = new HashSet<String>();
          evaluateSyncLocaleValues(content, syncValues, skipPaths);
          if (content.hasLocale(locale) && newLocale) {
              // a new locale is requested, so remove the present one
              content.removeLocale(locale);
          }
          if (!content.hasLocale(locale)) {
              if ((mainLocale != null) && content.hasLocale(mainLocale)) {
                  content.copyLocale(mainLocale, locale);
              } else {
                  content.addLocale(cms, locale);
              }
              // sync the locale values
              if (!visitor.getLocaleSynchronizations().isEmpty() && (content.getLocales().size() > 1)) {
                  for (Locale contentLocale : content.getLocales()) {
                      if (!contentLocale.equals(locale)) {
                          content.synchronizeLocaleIndependentValues(cms, skipPaths, contentLocale);
                      }
                  }
              }
          }
          Element element = content.getLocaleNode(locale);
          if (LOG.isDebugEnabled()) {
              timer = System.currentTimeMillis();
          }
          entity = readEntity(
              content,
              element,
              locale,
              entityId,
              "",
              getTypeUri(content.getContentDefinition()),
              visitor,
              false,
              editedLocaleEntity);
  
          if (LOG.isDebugEnabled()) {
              LOG.debug(
                  Messages.get().getBundle().key(
                      Messages.LOG_TAKE_READING_ENTITY_TIME_1,
                      "" + (System.currentTimeMillis() - timer)));
          }
          List<String> contentLocales = new ArrayList<String>();
          for (Locale contentLocale : content.getLocales()) {
              contentLocales.add(contentLocale.toString());
          }
          Locale workplaceLocale = OpenCms.getWorkplaceManager().getWorkplaceLocale(cms);
          TreeMap<String, String> availableLocales = new TreeMap<String, String>();
          for (Locale availableLocale : OpenCms.getLocaleManager().getAvailableLocales(cms, file)) {
              availableLocales.put(availableLocale.toString(), availableLocale.getDisplayName(workplaceLocale));
          }
          String title = cms.readPropertyObject(file, CmsPropertyDefinition.PROPERTY_TITLE, false).getValue();
          try {
              CmsGallerySearchResult searchResult = CmsGallerySearch.searchById(cms, file.getStructureId(), locale);
              title = searchResult.getTitle();
          } catch (CmsException e) {
              LOG.warn(e.getLocalizedMessage(), e);
          }
          String typeName = OpenCms.getResourceManager().getResourceType(file.getTypeId()).getTypeName();
          boolean autoUnlock = OpenCms.getWorkplaceManager().shouldAcaciaUnlock();
          Map<String, CmsEntity> entities = new HashMap<String, CmsEntity>();
          entities.put(entityId, entity);
  
          Map<String, CmsAttributeConfiguration> attrConfig = visitor.getAttributeConfigurations();
          Map<String, CmsType> types = visitor.getTypes();
          List<CmsTabInfo> tabInfos = visitor.getTabInfos();
  
          if (clientId != null) {
              CmsContainerElementBean containerElement = getSessionCache().getCacheContainerElement(clientId);
              I_CmsFormatterBean formatter = getFormatterForElement(containerElement);
              if ((formatter != null)
                  && formatter.isAllowsSettingsInEditor()
                  && (formatter.getSettings() != null)
                  && !formatter.getSettings().isEmpty()) {
                  Map<String, CmsXmlContentProperty> settingsConfig = OpenCms.getADEManager().getFormatterSettings(
                      cms,
                      formatter,
                      containerElement.getResource(),
                      locale,
                      getRequest());
                  com.google.common.base.Supplier<CmsXmlContent> contentSupplier = Suppliers.memoize(() -> {
                      try {
                          return CmsXmlContentFactory.unmarshal(cms, cms.readFile(containerElement.getResource()));
                      } catch (CmsException e) {
                          LOG.error(e.getLocalizedMessage(), e);
                          return null;
                      }
                  });
                  settingsConfig = CmsXmlContentPropertyHelper.resolveMacrosForPropertyInfo(
                      cms,
                      null,
                      containerElement.getResource(),
                      contentSupplier,
                      CmsElementUtil.createStringTemplateSource(formatter, contentSupplier),
                      settingsConfig);
                  CmsMessages messages = OpenCms.getWorkplaceManager().getMessages(m_workplaceLocale);
                  List<I_CmsFormatterBean> nestedFormatters = formatter.hasNestedFormatterSettings()
                  ? OpenCms.getADEManager().getNestedFormatters(cms, containerElement.getResource(), locale, getRequest())
                  : Collections.emptyList();
                  String firstContentAttributeName = types.get(
                      entity.getTypeName()).getAttributeNames().iterator().next();
                  List<String> addedVisibleAttrs = addSettingsAttributes(
                      attrConfig,
                      settingsConfig,
                      nestedFormatters,
                      messages,
                      locale,
                      settingPresets);
                  addSettingsTypes(entity.getTypeName(), types, settingsConfig, nestedFormatters);
                  if (editedLocaleEntity != null) {
                      transferSettingValues(editedLocaleEntity, entity);
                  } else {
                      addSettingsValues(entity, containerElement, nestedFormatters);
                  }
                  if (tabInfos.isEmpty()) {
                      tabInfos.add(
                          new CmsTabInfo(
                              Messages.get().getBundle(workplaceLocale).key(Messages.GUI_CONTENT_TAB_LABEL_0),
                              "content",
                              firstContentAttributeName.substring(entity.getTypeName().length() + 1),
                              false,
                              null));
                  }
                  if (addedVisibleAttrs.size() > 0) {
                      tabInfos.add(
                          new CmsTabInfo(
                              Messages.get().getBundle(workplaceLocale).key(Messages.GUI_SETTINGS_TAB_LABEL_0),
                              CmsContentDefinition.SETTINGS_TAB_ID,
                              CmsFileUtil.removeLeadingSeparator(addedVisibleAttrs.iterator().next()),
                              false,
                              Messages.get().getBundle(workplaceLocale).key(Messages.GUI_SETTINGS_TAB_DESCRIPTION_0)));
                  }
              }
  
          }
  
          return new CmsContentDefinition(
              entityId,
              entities,
              visitor.getAttributeConfigurations(),
              visitor.getWidgetConfigurations(),
              visitor.getComplexWidgetData(),
              visitor.getTypes(),
              visitor.getTabInfos(),
              locale.toString(),
              contentLocales,
              availableLocales,
              visitor.getLocaleSynchronizations(),
              syncValues,
              skipPaths,
              title,
              cms.getSitePath(file),
              typeName,
              CmsIconUtil.getIconClasses(CmsIconUtil.getDisplayType(cms, file), file.getName(), false),
              performedAutoCorrection,
              autoUnlock,
              getChangeHandlerScopes(content.getContentDefinition()));
      }