/** * update updateEmptySidebar * * @param session */ public static void updateEmptySidebar(CoreSession session) { try { DocumentModelList children = session.query("SELECT * FROM " + Docs.SITE.type()); for (DocumentModel docLabsSite : children) { LabsSite labsSite = Tools.getAdapter(LabsSite.class, docLabsSite, session); HtmlPage sidebar = labsSite.getSidebar(); if (sidebar.getSections().size() < 2) { session.removeDocument(sidebar.getDocument().getRef()); session.save(); LabsSiteUtils.createDefaultSidebarPage(labsSite.getDocument(), session); session.save(); } } } catch (ClientException e) { LOG.error("updateEmptySidebar : ", e); } }
/** @param session */ public static void updateSiteTemplateAndSidebar(CoreSession session) { try { DocumentModelList children = session.query("SELECT * FROM " + Docs.SITE.type()); for (DocumentModel docLabsSite : children) { LabsSite labsSite = Tools.getAdapter(LabsSite.class, docLabsSite, session); String templateName = labsSite.getTemplate().getTemplateName(); if (templateName.equals("homeSimple")) { labsSite.setTopPageNavigation(false); labsSite.getTemplate().setTemplateName("left"); LabsSiteUtils.createSimpleSidebarPage(labsSite.getDocument(), session); } else if (templateName.equals("homeLeftComplex")) { labsSite.setTopPageNavigation(true); labsSite.getTemplate().setTemplateName("left"); LabsSiteUtils.createComplexSidebarPage(labsSite.getDocument(), session); } else if (templateName.equals("centerFullScreen")) { labsSite.setTopPageNavigation(true); LabsSiteUtils.createDefaultSidebarPage(labsSite.getDocument(), session); } else if (templateName.equals("homeRightComplex")) { labsSite.getTemplate().setTemplateName("right"); labsSite.setTopPageNavigation(true); LabsSiteUtils.createComplexSidebarPage(labsSite.getDocument(), session); } else if (templateName.equals("homeRightSimple")) { labsSite.getTemplate().setTemplateName("right"); labsSite.setTopPageNavigation(false); LabsSiteUtils.createSimpleSidebarPage(labsSite.getDocument(), session); } else if (templateName.equals("domi")) { labsSite.setTopPageNavigation(true); LabsSiteUtils.createDefaultSidebarPage(labsSite.getDocument(), session); } else if (templateName.equals("supplyChain")) { labsSite.setTopPageNavigation(true); LabsSiteUtils.createDefaultSidebarPage(labsSite.getDocument(), session); } session.saveDocument(docLabsSite); } session.save(); } catch (ClientException e) { LOG.error("updateSiteTemplateAndSidebar : ", e); } }