docs: protected void commitTempFile() throws CmsException {
  
          CmsObject cms = getCms();
          CmsFile tempFile;
          List<CmsProperty> properties;
          try {
              switchToTempProject();
              tempFile = cms.readFile(getParamTempfile(), CmsResourceFilter.ALL);
              properties = cms.readPropertyObjects(getParamTempfile(), false);
          } finally {
              // make sure the project is reset in case of any exception
              switchToCurrentProject();
          }
          if (cms.existsResource(getParamResource(), CmsResourceFilter.ALL)) {
              // update properties of original file first (required if change in encoding occurred)
              cms.writePropertyObjects(getParamResource(), properties);
              // now replace the content of the original file
              CmsFile orgFile = cms.readFile(getParamResource(), CmsResourceFilter.ALL);
              orgFile.setContents(tempFile.getContents());
              getCloneCms().writeFile(orgFile);
          } else {
              // original file does not exist, remove visibility permission entries and copy temporary file
  
              // switch to the temporary file project
              try {
                  switchToTempProject();
                  // lock the temporary file
                  cms.changeLock(getParamTempfile());
                  // remove visibility permissions for everybody on temporary file if possible
                  if (cms.hasPermissions(tempFile, CmsPermissionSet.ACCESS_CONTROL)) {
                      cms.rmacc(
                          getParamTempfile(),
                          I_CmsPrincipal.PRINCIPAL_GROUP,
                          OpenCms.getDefaultUsers().getGroupUsers());
                  }
              } finally {
                  // make sure the project is reset in case of any exception
                  switchToCurrentProject();
              }
  
              cms.copyResource(getParamTempfile(), getParamResource(), CmsResource.COPY_AS_NEW);
              // ensure the content handler is called
              CmsFile orgFile = cms.readFile(getParamResource(), CmsResourceFilter.ALL);
              getCloneCms().writeFile(orgFile);
  
          }
          // remove the temporary file flag
          int flags = cms.readResource(getParamResource(), CmsResourceFilter.ALL).getFlags();
          if ((flags & CmsResource.FLAG_TEMPFILE) == CmsResource.FLAG_TEMPFILE) {
              flags ^= CmsResource.FLAG_TEMPFILE;
              cms.chflags(getParamResource(), flags);
          }
      }