From 07d864b427752661ad5a03bfcd00a490601eb7e5 Mon Sep 17 00:00:00 2001 From: pb Date: Fri, 29 Oct 2010 06:45:00 +0000 Subject: [PATCH] CMS: Erstellung neuer content sections implementiert. git-svn-id: https://svn.libreccm.org/ccm/trunk@591 8810af33-2d31-482b-a856-94f89814c4df --- .../cms/ContentSectionCollection.java | 3 + .../contentsection/ContentSectionSetup.java | 5 -- .../cms/contentsection/Initializer.java | 71 +++++++++++++------ 3 files changed, 52 insertions(+), 27 deletions(-) diff --git a/ccm-cms/src/com/arsdigita/cms/ContentSectionCollection.java b/ccm-cms/src/com/arsdigita/cms/ContentSectionCollection.java index f54701b99..34672671b 100755 --- a/ccm-cms/src/com/arsdigita/cms/ContentSectionCollection.java +++ b/ccm-cms/src/com/arsdigita/cms/ContentSectionCollection.java @@ -46,6 +46,9 @@ public class ContentSectionCollection extends DomainCollection { * Set the order of this Collection. This method needs to be called * before next() is called on this collection. * + * @param order: name of the pdl property to use for sorting the collection + * (e.g. "primaryURL" in order to sort by section name + * see c.ad.london.util.cmd.SiteMapList as an example ). */ public void addOrder(String order) { m_dataCollection.addOrder(order); diff --git a/ccm-cms/src/com/arsdigita/cms/contentsection/ContentSectionSetup.java b/ccm-cms/src/com/arsdigita/cms/contentsection/ContentSectionSetup.java index db1e7391e..f7a9fa1cf 100644 --- a/ccm-cms/src/com/arsdigita/cms/contentsection/ContentSectionSetup.java +++ b/ccm-cms/src/com/arsdigita/cms/contentsection/ContentSectionSetup.java @@ -85,9 +85,6 @@ public final class ContentSectionSetup { private WorkflowTemplate m_wf; final ContentSection m_section; - // Load main CMS configuration file - private static final LoaderConfig s_conf = new LoaderConfig(); - /** * Constructor. Using this constructor the content section has to be @@ -133,8 +130,6 @@ public final class ContentSectionSetup { // section specific categories, usually not used. if (useSectionCategories) { - // Iterator files = ((List) m_conf.getParameter(CATEGORIES)).iterator(); - // Iterator files = s_conf.getCategoryFileList().iterator(); Iterator files = categoryFileList.iterator(); while ( files.hasNext() ) { setup.registerCategories((String) files.next()); diff --git a/ccm-cms/src/com/arsdigita/cms/contentsection/Initializer.java b/ccm-cms/src/com/arsdigita/cms/contentsection/Initializer.java index f745f4f7d..d87f00427 100644 --- a/ccm-cms/src/com/arsdigita/cms/contentsection/Initializer.java +++ b/ccm-cms/src/com/arsdigita/cms/contentsection/Initializer.java @@ -31,12 +31,12 @@ import com.arsdigita.cms.workflow.UnfinishedTaskNotifier; // import com.arsdigita.persistence.TransactionContext; import com.arsdigita.runtime.CompoundInitializer; // import com.arsdigita.runtime.ConfigError; -// import com.arsdigita.runtime.DataInitEvent; import com.arsdigita.runtime.ContextInitEvent; import com.arsdigita.runtime.ContextCloseEvent; -// import com.arsdigita.runtime.DomainInitEvent; +// import com.arsdigita.runtime.DataInitEvent; +import com.arsdigita.runtime.DomainInitEvent; // import com.arsdigita.util.Assert; -// import com.arsdigita.web.Application; +import com.arsdigita.web.Application; import com.arsdigita.cms.workflow.CMSTask; // import java.math.BigDecimal; @@ -96,25 +96,52 @@ public class Initializer extends CompoundInitializer { // } // Currently nothing to do here. Will be changed in the ongoing migration process -// /** -// * Initializes domain-coupling machinery, usually consisting of -// * registering object instantiators and observers. -// * -// */ -// public void init(DomainInitEvent evt) { -// s_log.debug("CMS.installer.Initializer.init(DomainInitEvent) invoked"); -// -// // Recursive invokation of init, is it really necessary?? -// // On the other hand: -// // An empty implementations prevents this initializer from being executed. -// // A missing implementations causes the super class method to be executed, -// // which invokes the above added LegacyInitializer. -// // If super is not invoked, various other cms sub-initializer may not run. -// super.init(evt); -// -// -// s_log.debug("CMS.installer.Initializer.init(DomainInitEvent) completed"); -// } + /** + * Initializes domain-coupling machinery, usually consisting of + * registering object instantiators and observers. + * + */ + public void init(DomainInitEvent evt) { + s_log.debug("CMS.installer.Initializer.init(DomainInitEvent) invoked"); + + // Recursive invokation of init! + // An empty implementations prevents this initializer from being executed. + super.init(evt); + + // Check here weather a new content section has to be created. + String newSectionName = s_conf.getNewContentSectionName(); + if (newSectionName != null && !newSectionName.isEmpty() ) { + ContentSectionCollection sections=ContentSection.getAllSections(); + sections.addEqualsFilter( Application.PRIMARY_URL, + "/" + newSectionName + "/" ); + ContentSection section; + if( sections.next() ) { + // Section with the configured name already exists + s_log.debug( "Content section " + newSectionName + + " already exists, skipping creation task." ); + section = sections.getContentSection(); + sections.close(); + } else { + s_log.debug( "Content section " + newSectionName + " in " + + " doesn't exist, creating it." ); + ContentSectionSetup.setupContentSectionAppInstance + (newSectionName, + s_conf.getStuffGroup(), + s_conf.isPubliclyViewable(), + s_conf.getItemResolverClass(), + s_conf.getTemplateResolverClass(), + s_conf.getContentSectionsContentTypes(), + s_conf.getUseSectionCategories(), + s_conf.getCategoryFileList() + ); + } + + + } + + + s_log.debug("CMS.installer.Initializer.init(DomainInitEvent) completed"); + } /**