docs: public void handleHtmlRedirect(
          CmsObject userCms,
          HttpServletRequest request,
          HttpServletResponse response,
          String htmlRedirect)
      throws CmsException {
  
          CmsObject cms = OpenCms.initCmsObject(m_offlineCms);
          CmsRequestContext userContext = userCms.getRequestContext();
          CmsRequestContext currentContext = cms.getRequestContext();
          currentContext.setCurrentProject(userContext.getCurrentProject());
          currentContext.setSiteRoot(userContext.getSiteRoot());
          currentContext.setLocale(userContext.getLocale());
          currentContext.setUri(userContext.getUri());
  
          CmsFile file = cms.readFile(htmlRedirect);
          CmsXmlContent content = CmsXmlContentFactory.unmarshal(cms, file);
  
          // find out the locale to use for reading values from the redirect
          List<Locale> candidates = new ArrayList<Locale>();
          candidates.add(currentContext.getLocale());
          candidates.add(CmsLocaleManager.getDefaultLocale());
          candidates.add(Locale.ENGLISH);
          candidates.addAll(content.getLocales());
          Locale contentLocale = currentContext.getLocale();
          for (Locale candidateLocale : candidates) {
              if (content.hasLocale(candidateLocale)) {
                  contentLocale = candidateLocale;
                  break;
              }
          }
  
          String typeValue = content.getValue(N_TYPE, contentLocale).getStringValue(cms);
          String lnkUri = "";
          Integer errorCode;
          if ("sublevel".equals(typeValue)) {
              // use the nav builder to get the first sub level entry
              CmsJspNavBuilder navBuilder = new CmsJspNavBuilder(cms);
              if (navBuilder.getNavigationForFolder().size() > 0) {
                  CmsJspNavElement target = navBuilder.getNavigationForFolder().get(0);
                  lnkUri = CmsJspTagLink.linkTagAction(target.getResourceName(), request);
                  errorCode = Integer.valueOf(HttpServletResponse.SC_MOVED_TEMPORARILY);
              } else {
                  // send error 404 if no sub entry available
                  errorCode = Integer.valueOf(HttpServletResponse.SC_NOT_FOUND);
              }
          } else {
              I_CmsXmlContentValue contentValue = content.getValue(N_LINK, contentLocale);
              if (contentValue != null) {
                  String linkValue = contentValue.getStringValue(cms);
                  lnkUri = OpenCms.getLinkManager().substituteLinkForUnknownTarget(cms, linkValue);
                  try {
                      errorCode = Integer.valueOf(typeValue);
                  } catch (NumberFormatException e) {
                      LOG.error(e.getMessage(), e);
                      // fall back to default
                      errorCode = Integer.valueOf(307);
                  }
              } else {
                  // send error 404 if no link value is set
                  errorCode = Integer.valueOf(HttpServletResponse.SC_NOT_FOUND);
              }
          }
          request.setAttribute(CmsRequestUtil.ATTRIBUTE_ERRORCODE, errorCode);
          response.setHeader("Location", CmsEncoder.convertHostToPunycode(lnkUri));
          response.setHeader("Connection", "close");
          response.setStatus(errorCode.intValue());
      }