docs: public static CmsResource readOrCreateDetailOnlyPage(CmsObject cms, CmsUUID detailId, String detailOnlyRootPath)
      throws CmsException {
  
          CmsObject rootCms = OpenCms.initCmsObject(cms);
          rootCms.getRequestContext().setSiteRoot("");
          CmsResource containerpage;
          if (rootCms.existsResource(detailOnlyRootPath)) {
              containerpage = rootCms.readResource(detailOnlyRootPath);
          } else {
              String parentFolder = CmsResource.getFolderPath(detailOnlyRootPath);
              List<String> foldersToCreate = new ArrayList<String>();
              // ensure the parent folder exists
              while (!rootCms.existsResource(parentFolder)) {
                  foldersToCreate.add(0, parentFolder);
                  parentFolder = CmsResource.getParentFolder(parentFolder);
              }
              for (String folderName : foldersToCreate) {
                  CmsResource parentRes = rootCms.createResource(
                      folderName,
                      OpenCms.getResourceManager().getResourceType(CmsResourceTypeFolder.getStaticTypeName()));
                  // set the search exclude property on parent folder
                  rootCms.writePropertyObject(
                      folderName,
                      new CmsProperty(
                          CmsPropertyDefinition.PROPERTY_SEARCH_EXCLUDE,
                          A_CmsSearchIndex.PROPERTY_SEARCH_EXCLUDE_VALUE_ALL,
                          null));
                  CmsLockUtil.tryUnlock(rootCms, parentRes);
              }
              containerpage = rootCms.createResource(
                  detailOnlyRootPath,
                  OpenCms.getResourceManager().getResourceType(CmsResourceTypeXmlContainerPage.getStaticTypeName()));
          }
          CmsLockUtil.ensureLock(rootCms, containerpage);
          try {
              CmsResource detailResource = cms.readResource(detailId, CmsResourceFilter.IGNORE_EXPIRATION);
              String title = cms.readPropertyObject(
                  detailResource,
                  CmsPropertyDefinition.PROPERTY_TITLE,
                  true).getValue();
              if (title != null) {
                  title = Messages.get().getBundle(OpenCms.getWorkplaceManager().getWorkplaceLocale(cms)).key(
                      Messages.GUI_DETAIL_CONTENT_PAGE_TITLE_1,
                      title);
                  CmsProperty titleProp = new CmsProperty(CmsPropertyDefinition.PROPERTY_TITLE, title, null);
                  cms.writePropertyObjects(containerpage, Arrays.asList(titleProp));
              }
  
              List<CmsRelation> relations = cms.readRelations(
                  CmsRelationFilter.relationsFromStructureId(detailId).filterType(CmsRelationType.DETAIL_ONLY));
              boolean hasRelation = false;
              for (CmsRelation relation : relations) {
                  if (relation.getTargetId().equals(containerpage.getStructureId())) {
                      hasRelation = true;
                      break;
                  }
              }
              if (!hasRelation) {
                  CmsLockActionRecord lockRecord = null;
                  try {
                      lockRecord = CmsLockUtil.ensureLock(cms, detailResource);
                      cms.addRelationToResource(detailResource, containerpage, CmsRelationType.DETAIL_ONLY.getName());
                  } finally {
                      if ((lockRecord != null) && (lockRecord.getChange() == LockChange.locked)) {
                          cms.unlockResource(detailResource);
                      }
                  }
              }
          } catch (CmsException e) {
              CmsContainerpageService.LOG.error(e.getLocalizedMessage(), e);
          }
          return containerpage;
      }