code: private void saveContainers(
          CmsObject cms,
          CmsResource containerpage,
          String containerpageUri,
          List<CmsContainer> containers)
      throws CmsException {
  
          CmsContainerPageBean page = generateContainerPageForContainers(containers, containerpage.getRootPath());
  
          CmsModelGroupHelper modelHelper = new CmsModelGroupHelper(
              getCmsObject(),
              getConfigData(containerpage.getRootPath()),
              getSessionCache(),
              isEditingModelGroups(cms, containerpage));
          if (isEditingModelGroups(cms, containerpage)) {
              page = modelHelper.saveModelGroups(page, containerpage);
          } else {
              page = modelHelper.removeModelGroupContainers(page);
          }
          CmsXmlContainerPage xmlCnt = CmsXmlContainerPageFactory.unmarshal(cms, cms.readFile(containerpageUri));
          xmlCnt.save(cms, page);
      }
docs: Saves the given containers to the container page resource.<p>
  
  @param cms the cms context
  @param containerpage the container page resource
  @param containerpageUri the container page site path
  @param containers the container to save
  
  @throws CmsException if something goes wrong writing the file