code: public String getDetailPage(CmsObject cms, String pageRootPath, String originPath, String targetDetailPage) {
  
          boolean online = isOnline(cms);
          String resType = getCacheState(online).getParentFolderType(pageRootPath);
          if (resType == null) {
              return null;
          }
          if ((targetDetailPage != null) && getDetailPages(cms, resType).contains(targetDetailPage)) {
              return targetDetailPage;
          }
  
          String originRootPath = cms.getRequestContext().addSiteRoot(originPath);
          CmsADEConfigData configData = lookupConfiguration(cms, originRootPath);
          CmsADEConfigData targetConfigData = lookupConfiguration(cms, pageRootPath);
          boolean targetFirst = targetConfigData.isPreferDetailPagesForLocalContents();
          List<CmsADEConfigData> configs = targetFirst
          ? Arrays.asList(targetConfigData, configData)
          : Arrays.asList(configData, targetConfigData);
          for (CmsADEConfigData config : configs) {
              List<CmsDetailPageInfo> pageInfo = config.getDetailPagesForType(resType);
              if ((pageInfo != null) && !pageInfo.isEmpty()) {
                  return pageInfo.get(0).getUri();
              }
          }
          return null;
      }
docs: Gets the detail page for a content element.<p>
  
  @param cms the CMS context
  @param pageRootPath the element's root path
  @param originPath the path in which the the detail page is being requested
  @param targetDetailPage the target detail page to use
  
  @return the detail page for the content element