예제 #1
0
  private void removeContentHomeIfThisSectionIs(
      final ContentEntity content, final MenuItemEntity section) {
    final ContentHomeEntity contentHome = content.getContentHome(section.getSite().getKey());

    if (contentHome != null && contentHome.getMenuItem() == null) {
      content.removeContentHome(section.getSite().getKey());
      contentHomeDao.delete(contentHome);
    } else if (contentHome != null && section.getKey() == contentHome.getMenuItem().getKey()) {
      content.removeContentHome(section.getSite().getKey());
      contentHomeDao.delete(contentHome);
    }

    contentHomeDao
        .getHibernateTemplate()
        .getSessionFactory()
        .evictCollection(ContentEntity.class.getName() + ".contentHomes", content.getKey());
  }
예제 #2
0
  private void doSetContentHome(
      final ContentEntity content,
      final MenuItemEntity section,
      final PageTemplateEntity pageTemplate) {
    final ContentHomeEntity existingHome = content.getContentHome(section.getSite().getKey());
    if (existingHome != null) {
      existingHome.setMenuItem(section);
      existingHome.setPageTemplate(pageTemplate);
    } else {
      final ContentHomeEntity newContentHome = new ContentHomeEntity();
      newContentHome.setKey(new ContentHomeKey(section.getSite().getKey(), content.getKey()));
      newContentHome.setSite(section.getSite());
      newContentHome.setContent(content);
      newContentHome.setMenuItem(section);
      newContentHome.setPageTemplate(pageTemplate);
      contentHomeDao.storeNew(newContentHome);

      content.addContentHome(newContentHome);
    }

    indexTransactionService.registerUpdate(content.getKey(), true);
  }