diff --git a/ccm-cms/src/ccm-cms.config b/ccm-cms/src/ccm-cms.config
index 48dfa584d..dbfdc7732 100755
--- a/ccm-cms/src/ccm-cms.config
+++ b/ccm-cms/src/ccm-cms.config
@@ -4,10 +4,10 @@
storage="ccm-cms/cms.properties"/>
-
+
0) {
+ if (itemResolverClassName != null
+ && itemResolverClassName.length() > 0) {
m_section.setItemResolverClass(itemResolverClassName);
s_log.info("Registering " + itemResolverClassName
+ " as the item resolver class");
} else {
- m_section.setItemResolverClass(ContentSection.getConfig().getDefaultItemResolverClass().getName());
+ m_section.setItemResolverClass(ContentSection.getConfig()
+ .getDefaultItemResolverClass().getName());
s_log.info("Registering " + itemResolverClassName
+ " as the item resolver class");
}
- if (templateResolverClassName != null && templateResolverClassName.length() > 0) {
+ if (templateResolverClassName != null
+ && templateResolverClassName.length() > 0) {
m_section.setTemplateResolverClass(templateResolverClassName);
s_log.info("Registering " + templateResolverClassName
+ " as the template resolver class");
} else {
- m_section.setTemplateResolverClass(ContentSection.getConfig().getDefaultTemplateResolverClass().getName());
+ m_section.setTemplateResolverClass(ContentSection.getConfig()
+ .getDefaultTemplateResolverClass().getName());
s_log.info("Registering " + templateResolverClassName
+ " as the template resolver class");
}
@@ -474,7 +480,8 @@ public final class ContentSectionSetup {
final InputStream stream = loader.getResourceAsStream(filename.substring(1));
if (stream == null) {
- throw new IllegalStateException((String) GlobalizationUtil.globalize("cms.installer.cannot_find_file").localize() + filename);
+ throw new IllegalStateException((String) GlobalizationUtil.globalize(
+ "cms.installer.cannot_find_file").localize() + filename);
}
final BufferedReader input = new BufferedReader(new InputStreamReader(stream));
@@ -501,7 +508,8 @@ public final class ContentSectionSetup {
temp.save();
- TemplateManagerFactory.getInstance().addTemplate(m_section, type, temp, "public");
+ TemplateManagerFactory.getInstance()
+ .addTemplate(m_section, type, temp, "public");
temp.publish(m_lcd, new Date());
}
diff --git a/ccm-cms/src/com/arsdigita/cms/contentsection/Initializer.java b/ccm-cms/src/com/arsdigita/cms/contentsection/Initializer.java
index d87f00427..1517d0474 100644
--- a/ccm-cms/src/com/arsdigita/cms/contentsection/Initializer.java
+++ b/ccm-cms/src/com/arsdigita/cms/contentsection/Initializer.java
@@ -22,24 +22,20 @@ package com.arsdigita.cms.contentsection;
import com.arsdigita.cms.ContentSection;
import com.arsdigita.cms.ContentSectionCollection;
-// import com.arsdigita.cms.LoaderConfig;
-//import com.arsdigita.cms.installer.Util;
-// import com.arsdigita.cms.util.GlobalizationUtil;
import com.arsdigita.cms.workflow.UnfinishedTaskNotifier;
-// import com.arsdigita.domain.DataObjectNotFoundException;
-// import com.arsdigita.persistence.SessionManager;
-// import com.arsdigita.persistence.TransactionContext;
+import com.arsdigita.persistence.SessionManager;
+import com.arsdigita.persistence.TransactionContext;
+import com.arsdigita.domain.DomainObject;
+import com.arsdigita.kernel.ACSObjectInstantiator;
+import com.arsdigita.persistence.DataObject;
import com.arsdigita.runtime.CompoundInitializer;
-// import com.arsdigita.runtime.ConfigError;
import com.arsdigita.runtime.ContextInitEvent;
import com.arsdigita.runtime.ContextCloseEvent;
// import com.arsdigita.runtime.DataInitEvent;
import com.arsdigita.runtime.DomainInitEvent;
-// import com.arsdigita.util.Assert;
import com.arsdigita.web.Application;
import com.arsdigita.cms.workflow.CMSTask;
-// import java.math.BigDecimal;
import java.util.Enumeration;
import java.util.NoSuchElementException;
import java.util.StringTokenizer;
@@ -74,8 +70,9 @@ public class Initializer extends CompoundInitializer {
private static Logger s_log = Logger.getLogger(Initializer.class);
/** Local configuration object ContentSectionConfig containing parameters
- which may be changed each system startup. */
- private static final ContentSectionConfig s_conf = ContentSectionConfig.getInstance();
+ which may be changed each system startup. */
+ private static final ContentSectionConfig s_conf = ContentSectionConfig
+ .getInstance();
/** The Timer used to send Unfinished notifications */
private static Vector s_unfinishedTimers = new Vector();
@@ -95,12 +92,12 @@ public class Initializer extends CompoundInitializer {
// public void init(DataInitEvent evt) {
// }
-// 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.
*
*/
+ @Override
public void init(DomainInitEvent evt) {
s_log.debug("CMS.installer.Initializer.init(DomainInitEvent) invoked");
@@ -108,37 +105,19 @@ public class Initializer extends CompoundInitializer {
// 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()
- );
- }
-
-
- }
+ /* Register object instantiator for ContentSection */
+ evt.getFactory().registerInstantiator
+ (ContentSection.BASE_DATA_OBJECT_TYPE,
+ new ACSObjectInstantiator() {
+ @Override
+ public DomainObject doNewInstance(DataObject dobj) {
+ return new ContentSection(dobj);
+ }
+ } );
+ // whether we have to create an additional (new) content section
+ // specified in config file.
+ checkForNewContentSection();
s_log.debug("CMS.installer.Initializer.init(DomainInitEvent) completed");
}
@@ -155,6 +134,7 @@ public class Initializer extends CompoundInitializer {
* A delay value of 0 inhibits start of processing.
* @param evt The context init event.
*/
+ @Override
public void init(ContextInitEvent evt) {
s_log.debug("content section ContextInitEvent started");
@@ -185,6 +165,7 @@ public class Initializer extends CompoundInitializer {
s_unfinishedTimers.addElement(unfinishedTimer);
}
}
+ sections.close();
s_log.debug("content section ContextInitEvent completed");
}
@@ -193,6 +174,7 @@ public class Initializer extends CompoundInitializer {
* Implementation of the {@link Initializer#init(ContextCloseEvent)}
* method.
*
+ * Stops various background threads started during startup process.
*/
@Override
public void close(ContextCloseEvent evt) {
@@ -211,6 +193,43 @@ public class Initializer extends CompoundInitializer {
s_log.debug("content section ContextCloseEvent completed");
}
+ private void checkForNewContentSection() {
+
+ // 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.warn( "Content section " + newSectionName +
+ " already exists, skipping creation task.\n" +
+ "You may delete the entry from configuration file.");
+ section = sections.getContentSection();
+ sections.close();
+ } else {
+ s_log.info( "Content section " + newSectionName + " in " +
+ " doesn't exist, creating it." );
+ TransactionContext txn = SessionManager.getSession()
+ .getTransactionContext();
+ txn.beginTxn();
+ ContentSectionSetup.setupContentSectionAppInstance
+ (newSectionName,
+ s_conf.getStuffGroup(),
+ s_conf.isPubliclyViewable(),
+ s_conf.getItemResolverClass(),
+ s_conf.getTemplateResolverClass(),
+ s_conf.getContentSectionsContentTypes(),
+ s_conf.getUseSectionCategories(),
+ s_conf.getCategoryFileList()
+ );
+ txn.commitTxn();
+ }
+ }
+
+ }
/**
* Steps through a string array of tasks and associated alert events
diff --git a/ccm-core/src/com/arsdigita/domain/DomainObjectFactory.java b/ccm-core/src/com/arsdigita/domain/DomainObjectFactory.java
index 107cb3407..bb98aa130 100755
--- a/ccm-core/src/com/arsdigita/domain/DomainObjectFactory.java
+++ b/ccm-core/src/com/arsdigita/domain/DomainObjectFactory.java
@@ -70,13 +70,13 @@ import org.apache.log4j.Logger;
* @author Oumi Mehrotra
* @version 1.0
* @version $Id: DomainObjectFactory.java 738 2005-09-01 12:36:52Z sskracic $
- *
**/
public class DomainObjectFactory {
- // map of registered instantiators, keyed by data object type.
+ /** map of registered instantiators, keyed by data object type. */
private static Map s_instantiators = new HashMap();
+ /** private logger instance. */
private static final Logger s_log = Logger.getLogger(DomainObjectFactory.class);
/**
@@ -261,8 +261,9 @@ public class DomainObjectFactory {
*
* @see #registerInstantiator(ObjectType, DomainObjectInstantiator)
*/
- public static DomainObjectInstantiator registerInstantiator(String dataObjectType,
- DomainObjectInstantiator instantiator) {
+ public static DomainObjectInstantiator registerInstantiator(
+ String dataObjectType,
+ DomainObjectInstantiator instantiator) {
MetadataRoot meta = SessionManager.getMetadataRoot();
ObjectType objectType = meta.getObjectType(dataObjectType);
diff --git a/ccm-core/src/com/arsdigita/formbuilder/util/FormbuilderSetup.java b/ccm-core/src/com/arsdigita/formbuilder/util/FormbuilderSetup.java
index 10fa255b4..274714379 100644
--- a/ccm-core/src/com/arsdigita/formbuilder/util/FormbuilderSetup.java
+++ b/ccm-core/src/com/arsdigita/formbuilder/util/FormbuilderSetup.java
@@ -80,7 +80,6 @@ public class FormbuilderSetup {
throws ConfigError {
// If the objects list is not null, load the object list into the database
- // pboy: Obviously, this is a Loader task.
if (objects != null) {
// XXX we don't yet delete types which are no longer in the list
diff --git a/ccm-core/src/com/arsdigita/kernel/ACSObjectInstantiator.java b/ccm-core/src/com/arsdigita/kernel/ACSObjectInstantiator.java
index 39889e288..b30185989 100755
--- a/ccm-core/src/com/arsdigita/kernel/ACSObjectInstantiator.java
+++ b/ccm-core/src/com/arsdigita/kernel/ACSObjectInstantiator.java
@@ -81,19 +81,18 @@ import com.arsdigita.domain.DomainObject ;
* on the FooGroup instantiator, which contains a hardcoded call
* to the constructor for FooGroup.
*
- * @author Oumi Mehrotra
- * @version 1.0
- *
* @see com.arsdigita.domain.DomainObjectInstantiator
* @see com.arsdigita.domain.DomainObjectFactory
* @see com.arsdigita.domain.DomainObject
* @see com.arsdigita.persistence.DataObject
* @see com.arsdigita.kernel.ACSObject
+ *
+ * @author Oumi Mehrotra
+ * @version 1.0
+ * @version $Id: ACSObjectInstantiator.java 287 2005-02-22 00:29:02Z sskracic $
**/
public class ACSObjectInstantiator extends DomainObjectInstantiator {
- public static final String versionId = "$Id: ACSObjectInstantiator.java 287 2005-02-22 00:29:02Z sskracic $ by $Author: sskracic $, $DateTime: 2004/08/16 18:10:38 $";
-
protected boolean m_useReflectionForSubtypes = true;
/**
diff --git a/ccm-core/src/com/arsdigita/web/Application.java b/ccm-core/src/com/arsdigita/web/Application.java
index 4d96b9815..64017ded1 100755
--- a/ccm-core/src/com/arsdigita/web/Application.java
+++ b/ccm-core/src/com/arsdigita/web/Application.java
@@ -81,6 +81,7 @@ public class Application extends Resource {
public static final String BASE_DATA_OBJECT_TYPE =
"com.arsdigita.web.Application";
+ @Override
protected String getBaseDataObjectType() {
return BASE_DATA_OBJECT_TYPE;
}
@@ -171,9 +172,11 @@ public class Application extends Resource {
final ApplicationType type =
ApplicationType.retrieveApplicationTypeForApplication(typeName);
if (type == null) {
- throw new IllegalArgumentException("No ApplicationType found for type name " + typeName);
+ throw new IllegalArgumentException(
+ "No ApplicationType found for type name " + typeName);
}
- return Application.createApplication(type,fragment,title,parent,createContainerGroup);
+ return Application.createApplication(type,fragment,
+ title,parent,createContainerGroup);
}
/**
@@ -220,7 +223,8 @@ public class Application extends Resource {
final String title,
final Application parent,
final boolean createContainerGroup) {
- final Application application = (Application) Resource.createResource(type, title, parent);
+ final Application application = (Application) Resource.createResource(
+ type, title, parent);
if (createContainerGroup) {
s_log.debug("Creating Group for application");
application.createGroup();