docs: protected CmsResource initResource(
          CmsObject cms,
          String resourceName,
          HttpServletRequest req,
          HttpServletResponse res)
      throws CmsException {
  
          CmsException tmpException = null;
          CmsResource resource;
          boolean handledSecure = false;
  
          try {
              // try to read the requested resource
              resource = cms.readDefaultFile(resourceName);
          } catch (CmsException e) {
              // file or folder with given name does not exist, store exception
              tmpException = e;
              resource = null;
          }
  
          if (resource != null) {
              // set the request uri to the right file
              cms.getRequestContext().setUri(cms.getSitePath(resource));
              // test if this file is only available for internal access operations
              if (resource.isInternal()) {
                  throw new CmsException(
                      Messages.get().container(Messages.ERR_READ_INTERNAL_RESOURCE_1, cms.getRequestContext().getUri()));
              }
  
              resource = handleSecureResource(cms, req, res, resource, resourceName);
              if (resource == null) {
                  handledSecure = true;
  
              }
          }
  
          boolean clearErrors = false;
          // test if this file has to be checked or modified
          for (I_CmsResourceInit handler : m_resourceInitHandlers) {
              try {
                  resource = handler.initResource(resource, cms, req, res);
                  // the loop has to be interrupted when the exception is thrown!
              } catch (CmsResourceInitException e) {
                  if (e.isClearErrors()) {
                      tmpException = null;
                      clearErrors = true;
                  }
                  break;
              } catch (CmsSecurityException e) {
                  tmpException = e;
                  break;
              }
          }
  
          // file is still null and not found exception was thrown, so throw original exception
          if (resource == null) {
              if (tmpException != null) {
                  throw tmpException;
              } else if (!clearErrors) {
                  throw new CmsVfsResourceNotFoundException(
                      org.opencms.main.Messages.get().container(
                          org.opencms.main.Messages.ERR_PATH_NOT_FOUND_1,
                          resourceName));
  
              }
          } else {
              if (!handledSecure) {
                  if (cms.getRequestContext().getDetailContentId() != null) {
                      // in theory we should do this for all kinds of resource init handlers,
                      // but I'm not clear on how to handle this in general, so only do this for detail pages for now
                      resource = handleSecureResource(cms, req, res, resource, resourceName);
                      handledSecure = true;
                  }
              }
          }
  
          // return the resource read from the VFS
          return resource;
      }