Anlegen einer neuen content section per Configuration file funktioniert jetzt.

git-svn-id: https://svn.libreccm.org/ccm/trunk@768 8810af33-2d31-482b-a856-94f89814c4df
master
pb 2011-02-27 10:28:33 +00:00
parent 5083e1cbbf
commit ed616f18d5
12 changed files with 120 additions and 96 deletions

View File

@ -4,10 +4,10 @@
storage="ccm-cms/cms.properties"/>
<config class="com.arsdigita.cms.contentsection.ContentSectionConfig"
storage="ccm-cms/contentsection.properties"/>
<config class="com.arsdigita.cms.LoaderConfig"
storage="ccm-cms/loader.properties"/>
<config class="com.arsdigita.cms.lifecycle.LifecycleConfig"
storage="ccm-cms/lifecycle.properties"/>
<config class="com.arsdigita.cms.LoaderConfig"
storage="ccm-cms/loader.properties"/>
<config class="com.arsdigita.cms.publishToFile.PublishToFileConfig"
storage="ccm-cms/publishToFile.properties"/>
<config class="com.arsdigita.cms.contenttypes.GenericAddressConfig"

View File

@ -1159,7 +1159,9 @@ public class ContentSection extends Application {
templates.save();
//create and initialize the content section application
ContentSection section = (ContentSection) Application.createApplication(BASE_DATA_OBJECT_TYPE, name, name, null);
ContentSection section = (ContentSection) Application
.createApplication(BASE_DATA_OBJECT_TYPE
, name, name, null);
section.initialize(name,
folder,
category,

View File

@ -23,8 +23,6 @@ import com.arsdigita.cms.dispatcher.AssetURLFinder;
import com.arsdigita.cms.dispatcher.ItemDelegatedURLPatternGenerator;
import com.arsdigita.cms.dispatcher.ItemTemplatePatternGenerator;
import com.arsdigita.cms.dispatcher.ItemURLFinder;
// import com.arsdigita.cms.installer.WorkspaceInstaller;
// import com.arsdigita.cms.installer.ContentCenterSetup;
import com.arsdigita.cms.publishToFile.PublishToFileListener;
import com.arsdigita.cms.publishToFile.QueueManager;
import com.arsdigita.cms.search.AssetMetadataProvider;
@ -50,10 +48,6 @@ import com.arsdigita.domain.DomainObjectInstantiator;
import com.arsdigita.domain.xml.TraversalHandler;
import com.arsdigita.kernel.ACSObjectInstantiator;
import com.arsdigita.kernel.NoValidURLException;
// import com.arsdigita.kernel.PackageInstance;
// import com.arsdigita.kernel.PackageInstanceCollection;
// import com.arsdigita.kernel.PackageType;
// import com.arsdigita.kernel.SiteNode;
import com.arsdigita.kernel.URLFinder;
import com.arsdigita.kernel.URLFinderNotFoundException;
import com.arsdigita.kernel.URLService;
@ -65,7 +59,6 @@ import com.arsdigita.persistence.pdl.NameFilter;
import com.arsdigita.runtime.CompoundInitializer;
// import com.arsdigita.runtime.ConfigError;
import com.arsdigita.runtime.DomainInitEvent;
import com.arsdigita.runtime.LegacyInitializer;
import com.arsdigita.runtime.PDLInitializer;
import com.arsdigita.runtime.RuntimeConfig;
import com.arsdigita.search.FilterType;
@ -101,17 +94,11 @@ import org.apache.log4j.Logger;
*/
public class Initializer extends CompoundInitializer {
/** Creates a s_logging category with name = to the full name of class */
private static Logger s_log = Logger.getLogger(Initializer.class);
/** Configuration object for the CMS module */
private static final CMSConfig s_conf = CMSConfig.getInstance();
// Verursacht aktuell eine Exception "no such context"
// Vermutliche Lösung: in config.xml eintragen.
// static { // requirred to actually read the config file!
// s_conf.load();
// }
/**
* Constructor, adds db connection information and various sub-initializers
@ -303,6 +290,7 @@ public class Initializer extends CompoundInitializer {
f.registerInstantiator
(CMSTask.BASE_DATA_OBJECT_TYPE,
new ACSObjectInstantiator() {
@Override
public DomainObject doNewInstance(DataObject dataObject) {
return new CMSTask(dataObject);
}

View File

@ -349,7 +349,6 @@ public class Loader extends PackageLoader {
appsetup.setSingleton(true);
appsetup.setPortalApplication(false);
appsetup.setInstantiator(new ACSObjectInstantiator() {
@Override
protected DomainObject doNewInstance(DataObject dataObject) {
return new Workspace(dataObject);
@ -434,7 +433,6 @@ public class Loader extends PackageLoader {
appsetup.setSingleton(true);
appsetup.setPortalApplication(false);
appsetup.setInstantiator(new ACSObjectInstantiator() {
@Override
protected DomainObject doNewInstance(DataObject dataObject) {
return new Service(dataObject);
@ -481,13 +479,17 @@ public class Loader extends PackageLoader {
appType.setPortalApplication(false);
//setup.setDispatcherClass(ContentItemDispatcher.class.getName());
// contains the xsl to generate the page
appType.setInstantiator(new ACSObjectInstantiator() {
// ApplicationSetup requires an Instantiator which has to be set here
// Setting it up in Initializer prior to creating the application type
// doesn't work!
appType.setInstantiator(new ACSObjectInstantiator() {
@Override
public DomainObject doNewInstance(DataObject dataObject) {
return new ContentSection(dataObject);
}
});
appType.run();
// Step 3:

View File

@ -38,6 +38,7 @@ import org.apache.log4j.Logger;
* later after the installation step.
*
* @author pb
* @version $Id: LoaderConfig.java $
*/
public final class LoaderConfig extends AbstractConfig {
@ -111,8 +112,8 @@ public final class LoaderConfig extends AbstractConfig {
* An entry in this list is required by internal content types (see package
* ccm-cms/src/com/arsdigita/cms/contenttypes)
*/
private final Parameter
m_ctDefFiles = new StringArrayParameter(
private final Parameter m_ctDefFiles =
new StringArrayParameter(
"com.arsdigita.cms.loader.contenttype_definition_files",
Parameter.REQUIRED,
// Generic*.xml added by Quasi in enterprise.init for

View File

@ -207,8 +207,9 @@ public final class ContentSectionConfig extends AbstractConfig {
* See contentsection.ContentSectionSetup.registerRoles()
* In enterprise.init: name roles, List of roles to create.
*
* Not implemented yet! We need a new parameter type "list" which must have
* multidimensional capabilities.
* ** Not implemented yet! **
* We need a new parameter type "list" which must have multidimensional
* capabilities.
*/
// private final StringParameter
// m_staffGroup = new StringParameter(

View File

@ -93,6 +93,8 @@ public final class ContentSectionSetup {
* Wrapper class to create and configure a content section instance
* in one step.
*
* Method needs a transaction to proceed successfully.
* {@link com.arsdigita.cms.contentsection.Initializer#checkForNewContentSection() }
*/
public static void setupContentSectionAppInstance(String name,
List staffGroup,
@ -265,21 +267,25 @@ public final class ContentSectionSetup {
public void registerResolvers(String itemResolverClassName,
String templateResolverClassName) {
if (itemResolverClassName != null && itemResolverClassName.length() > 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());
}

View File

@ -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;
@ -75,7 +71,8 @@ public class Initializer extends CompoundInitializer {
/** Local configuration object ContentSectionConfig containing parameters
which may be changed each system startup. */
private static final ContentSectionConfig s_conf = ContentSectionConfig.getInstance();
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

View File

@ -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,7 +261,8 @@ public class DomainObjectFactory {
*
* @see #registerInstantiator(ObjectType, DomainObjectInstantiator)
*/
public static DomainObjectInstantiator registerInstantiator(String dataObjectType,
public static DomainObjectInstantiator registerInstantiator(
String dataObjectType,
DomainObjectInstantiator instantiator) {
MetadataRoot meta = SessionManager.getMetadataRoot();

View File

@ -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

View File

@ -81,19 +81,18 @@ import com.arsdigita.domain.DomainObject ;
* on the <code>FooGroup</code> instantiator, which contains a hardcoded call
* to the constructor for <code>FooGroup</code>.
*
* @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;
/**

View File

@ -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();