Removed creation of new content sections via the initializer (Ticket #2029)

git-svn-id: https://svn.libreccm.org/ccm/trunk@2530 8810af33-2d31-482b-a856-94f89814c4df
master
jensp 2014-02-19 13:18:12 +00:00
parent 8aa2a7ea21
commit 3d25fc7630
3 changed files with 480 additions and 532 deletions

View File

@ -16,11 +16,15 @@
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*
*/
package com.arsdigita.cms.contentsection;
import com.arsdigita.cms.ContentSection;
import com.arsdigita.runtime.AbstractConfig;
import com.arsdigita.util.parameter.*;
import com.arsdigita.util.parameter.BooleanParameter;
import com.arsdigita.util.parameter.IntegerParameter;
import com.arsdigita.util.parameter.Parameter;
import com.arsdigita.util.parameter.StringArrayParameter;
import com.arsdigita.util.parameter.StringParameter;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.HashMap;
@ -30,8 +34,9 @@ import org.apache.log4j.Logger;
/**
* Configuration parameter to configure a content section during startup.
*
* Configures parameter which are not persisted in the database and may be
* changes during each startup of the system.
* Configures parameter which are not persisted in the database and may be changes during each
* startup of the system.
*
* @author pb
* @author Sören Bernstein <quasi@quasiweb.de>
*/
@ -40,16 +45,18 @@ public final class ContentSectionConfig extends AbstractConfig {
private List m_defaultRoles;
private List m_defaultWorkflows;
/** Private Logger instance for debugging purpose. */
private static final Logger s_log =
Logger.getLogger(ContentSectionConfig.class);
/**
* Private Logger instance for debugging purpose.
*/
private static final Logger s_log = Logger.getLogger(ContentSectionConfig.class);
/** Private Object to hold one's own instance to return to users. */
/**
* Private Object to hold one's own instance to return to users.
*/
private static ContentSectionConfig s_config;
/**
* Returns the singleton configuration record for the content section
* environment.
* Returns the singleton configuration record for the content section environment.
*
* @return The <code>ContentSectionConfig</code> record; it cannot be null
*/
@ -62,7 +69,6 @@ public final class ContentSectionConfig extends AbstractConfig {
return s_config;
}
// /////////////////////////////////////////////////////////////////////////////
//
// Set of parameters controlling Overdue Task alerts:
@ -71,18 +77,13 @@ public final class ContentSectionConfig extends AbstractConfig {
// configuration applied to every content section.
//
// /////////////////////////////////////////////////////////////////////////////
/**
* A list of workflow tasks, and the associated events for which alerts
* have to be sent.
* Parameter name TASK_ALERTS in the old initializer system / enterprise.init
* Specifies when to generate email alerts: by default, generate email alerts
* on enable, finish, and rollback (happens on rejection) changes.
* There are four action types for each task type: enable, disable, finish,
* and rollback.
* Example:
* (Note that the values below are based on the task labels, and as such are
* not globalized.)
* A list of workflow tasks, and the associated events for which alerts have to be sent.
* Parameter name TASK_ALERTS in the old initializer system / enterprise.init Specifies when to
* generate email alerts: by default, generate email alerts on enable, finish, and rollback
* (happens on rejection) changes. There are four action types for each task type: enable,
* disable, finish, and rollback. Example: (Note that the values below are based on the task
* labels, and as such are not globalized.)
* <pre>
* taskAlerts = {
* { "Authoring",
@ -97,21 +98,16 @@ public final class ContentSectionConfig extends AbstractConfig {
* };
* </pre>
*
* In the new Initializer system we use a specifically formatted String Array
* because we have no List parameter. Format:
* - A string for each task to handle, possible values: Authoring, Approval,
* Deploy
* - Each Task String: [taskName]:[alert_1]:...:[alert_n]
* The specially formatted string is not handled by StringArray parameter,
* but forwarded untouched to the initializer which has the duty to process
* it!
* In the new Initializer system we use a specifically formatted String Array because we have no
* List parameter. Format: - A string for each task to handle, possible values: Authoring,
* Approval, Deploy - Each Task String: [taskName]:[alert_1]:...:[alert_n] The specially
* formatted string is not handled by StringArray parameter, but forwarded untouched to the
* initializer which has the duty to process it!
*
* Currently there is no way to persist taskAlerts section specific. So all
* sections have to treated equally.
* Default values are provided here.
* Currently there is no way to persist taskAlerts section specific. So all sections have to
* treated equally. Default values are provided here.
*/
private final Parameter
m_taskAlerts = new StringArrayParameter(
private final Parameter m_taskAlerts = new StringArrayParameter(
"com.arsdigita.cms.section.task_alerts",
Parameter.REQUIRED, new String[]{
"Authoring:enable:finish:rollback",
@ -120,21 +116,18 @@ public final class ContentSectionConfig extends AbstractConfig {
);
/**
* Should we send alerts about overdue tasks at all?
* Send alerts when a task is overdue (has remained in the \"enabled\" state
* for a long time)
* Parameter SEND_OVERDUE_ALERTS in the old initializer system, default false
* Should we send alerts about overdue tasks at all? Send alerts when a task is overdue (has
* remained in the \"enabled\" state for a long time) Parameter SEND_OVERDUE_ALERTS in the old
* initializer system, default false
*/
private final Parameter
m_sendOverdueAlerts = new BooleanParameter(
private final Parameter m_sendOverdueAlerts = new BooleanParameter(
"com.arsdigita.cms.section.send_overdue_alerts",
Parameter.REQUIRED,
false);
/**
* The time between when a task is enabled (i.e. it is made available for
* completion) and when it is considered overdue (in HOURS).
* The time between when a task is enabled (i.e. it is made available for completion) and when
* it is considered overdue (in HOURS).
*/
// XXX Once the Duration of a Task can actually be maintained (in the UI,
// or initialization parameters), we should use the value in the DB, and
@ -142,41 +135,31 @@ public final class ContentSectionConfig extends AbstractConfig {
// Parameter name TASK_DURATION in the old initializer system.
// Description: How long a task can remain \"enabled\" before it is
// considered overdue (in hours)
private final Parameter
m_taskDuration = new IntegerParameter(
private final Parameter m_taskDuration = new IntegerParameter(
"com.arsdigita.cms.section.task_duration",
Parameter.REQUIRED,
new Integer(96));
/**
* The time to wait between sending successive alerts on the same
* overdue task (in HOURS).
* Parameter name OVERDUE_ALERT_INTERVAL in old initializer system
* Description: Time to wait between sending overdue notifications on the
* same task (in hours)
* The time to wait between sending successive alerts on the same overdue task (in HOURS).
* Parameter name OVERDUE_ALERT_INTERVAL in old initializer system Description: Time to wait
* between sending overdue notifications on the same task (in hours)
*/
private final Parameter
m_alertInterval = new IntegerParameter(
private final Parameter m_alertInterval = new IntegerParameter(
"com.arsdigita.cms.section.alert_interval",
Parameter.REQUIRED,
new Integer(24));
/**
* The maximum number of alerts to send about any one overdue task.
* Parameter name MAX_ALERTS in old initializer system.
* Description: The maximum number of alerts to send that a single task is
* overdue
* The maximum number of alerts to send about any one overdue task. Parameter name MAX_ALERTS in
* old initializer system. Description: The maximum number of alerts to send that a single task
* is overdue
*/
private final Parameter
m_maxAlerts = new IntegerParameter(
private final Parameter m_maxAlerts = new IntegerParameter(
"com.arsdigita.cms.section.max_alerts",
Parameter.REQUIRED,
new Integer(5));
// ///////////////////////////////////////////////////////
//
// Set of parameters which specify a new content section
@ -185,37 +168,20 @@ public final class ContentSectionConfig extends AbstractConfig {
// startups) parameters are ignored and not processed.
//
// ///////////////////////////////////////////////////////
/**
* The name of a new content section to be create during next boot of the
* system. During subsequent startups, when the section to be created
* already exists, the parameter is ignored and processing skipped.
* Staff Group Contains roles and associated privileges. In loading step a complete default
* configuration is persisted in database, immutable at this point. See
* contentsection.ContentSectionSetup.registerRoles() In enterprise.init: name roles, List of
* roles to create.
*
* Empty by default so no processing will take place.
*/
private final Parameter
m_newContentSectionName = new StringParameter(
"com.arsdigita.cms.section.new_section_name",
Parameter.OPTIONAL,
null);
/**
* Staff Group
* Contains roles and associated privileges. In loading step a complete
* default configuration is persisted in database, immutable at this point.
* 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(
// "com.arsdigita.cms.loader.section_staff_group",
// Parameter.REQUIRED,
// null);
// Viewer group, set autonomously by ContentSection.create() method. We can
// here specify, whether the first ( probalby only) content section should
// have a public viewer, i.e. without registration and login.
@ -224,8 +190,7 @@ public final class ContentSectionConfig extends AbstractConfig {
*
* Parameter name in the old initializer code: PUBLIC. Default true.
*/
private final BooleanParameter
m_isPublic = new BooleanParameter(
private final BooleanParameter m_isPublic = new BooleanParameter(
"com.arsdigita.cms.section.is_public",
Parameter.REQUIRED,
true);
@ -233,92 +198,75 @@ public final class ContentSectionConfig extends AbstractConfig {
/**
* List of content types to register in the given content-section.
*
* Example:
* {
* "com.arsdigita.cms.contenttypes.Address",
* "com.arsdigita.cms.contenttypes.Article",
* "com.arsdigita.cms.contenttypes.Contact"
* }
* Example: { "com.arsdigita.cms.contenttypes.Address",
* "com.arsdigita.cms.contenttypes.Article", "com.arsdigita.cms.contenttypes.Contact" }
*
* Parameter name "TYPES" in the old initializer code, empty by default in
* the former enterprise.init file.
* When the list is empty and the first default content section is created,
* all installed content types will get registered. This behaviour should
* not be altered without very good reasons.
* Parameter name "TYPES" in the old initializer code, empty by default in the former
* enterprise.init file. When the list is empty and the first default content section is
* created, all installed content types will get registered. This behaviour should not be
* altered without very good reasons.
*/
private final Parameter
m_contentTypeList = new StringArrayParameter(
private final Parameter m_contentTypeList = new StringArrayParameter(
"com.arsdigita.cms.section.ctypes_list",
Parameter.REQUIRED,
new String[]{});
// Page Resolver Class, set autonomously by ContentSection.create() method.
// Item Resolver Class, configurable.
/**
* Name of the item resolver class to use for the section (defaults to
* <pre>com.arsdigita.cms.dispatcher.MultilingualItemResolver</pre>).
*
* Default value (site-wide) is handled via the parameter
* <pre>com.arsdigita.cms.default_item_resolver_class</pre>.
* Section-specific override can be added here. Only do so if you are
* changing from the default for a specific content section. The class
* must implement <pre>com.arsdigita.cms.dispatcher.ItemResolver</pre>.
* <pre>com.arsdigita.cms.default_item_resolver_class</pre>. Section-specific override can be
* added here. Only do so if you are changing from the default for a specific content section.
* The class must implement
* <pre>com.arsdigita.cms.dispatcher.ItemResolver</pre>.
*
* Parameter name ITEM_RESOLVER_CLASS in the old initializer system.
* Description: The ItemResolver class to use for the section
* (defaults to MultilingualItemResolver)
* Parameter name ITEM_RESOLVER_CLASS in the old initializer system. Description: The
* ItemResolver class to use for the section (defaults to MultilingualItemResolver)
*/
private final Parameter
m_itemResolverClass = new StringParameter(
private final Parameter m_itemResolverClass = new StringParameter(
"com.arsdigita.cms.section.item_resolver_class",
Parameter.OPTIONAL, null);
// , "com.arsdigita.cms.dispatcher.MultilingualItemResolver"
// Template Resolver Class, configurable.
/**
* Name of the template resolver class to use for the section
* (defaults to <pre>com.arsdigita.cms.dispatcher.DefaultTemplateResolver</pre>)
* Name of the template resolver class to use for the section (defaults to
* <pre>com.arsdigita.cms.dispatcher.DefaultTemplateResolver</pre>)
*
* Default value (site-wide) is handled via the parameter
* <pre>com.arsdigita.cms.default_template_resolver_class</pre>.
* Section-specific override can be added here. Only do so if you are
* changing from the default for a specific content section. The class
* must implement <pre>com.arsdigita.cms.dispatcher.TemplateResolver</pre>.
* <pre>com.arsdigita.cms.default_template_resolver_class</pre>. Section-specific override can
* be added here. Only do so if you are changing from the default for a specific content
* section. The class must implement
* <pre>com.arsdigita.cms.dispatcher.TemplateResolver</pre>.
*
* Parameter name TEMPLATE_RESOLVER_CLASS in the old initializer system.
*/
private final Parameter
m_templateResolverClass = new StringParameter(
private final Parameter m_templateResolverClass = new StringParameter(
"com.arsdigita.cms.section.template_resolver_class",
Parameter.OPTIONAL,
null);
// "com.arsdigita.cms.dispatcher.DefaultTemplateResolver" );
// XML Generator Class, set autonomously by ContentSection.create() method.
/**
* Determins weather to use section specific category tree(s). Defaults to
* false, so standard navigation is used.
* If set to true loader loads the categories from file(s) specified in the
* Determins weather to use section specific category tree(s). Defaults to false, so standard
* navigation is used. If set to true loader loads the categories from file(s) specified in the
* next parameter ( m_categoryFileList )
*/
private final Parameter
m_useSectionCategories = new BooleanParameter
("com.arsdigita.cms.section.use_section_categories",
private final Parameter m_useSectionCategories = new BooleanParameter(
"com.arsdigita.cms.section.use_section_categories",
Parameter.REQUIRED, false);
/**
* XML file containing the category tree to load for this content section.
* Usually not loaded {@see m_useSectionCategories). The files listed as
* default values are demo material and must be replaced in a production
* environment.
* XML file containing the category tree to load for this content section. Usually not loaded {
*
* @see m_useSectionCategories). The files listed as default values are demo material and must
* be replaced in a production environment.
*/
private final Parameter
m_categoryFileList = new StringArrayParameter(
private final Parameter m_categoryFileList = new StringArrayParameter(
"com.arsdigita.cms.section.categories_toload",
Parameter.REQUIRED,
new String[]{"/WEB-INF/resources/article-categories.xml",
@ -331,7 +279,6 @@ public final class ContentSectionConfig extends AbstractConfig {
// List.class,
// Collections.EMPTY_LIST);
/**
* Constructor, do not instantiate this class directly!
*
@ -346,8 +293,6 @@ public final class ContentSectionConfig extends AbstractConfig {
register(m_alertInterval);
register(m_maxAlerts);
// parameters for creation of a new (additional) content section
register(m_newContentSectionName);
// register(m_staffGroup); NOT IMPLEMENTED yet
register(m_isPublic);
register(m_itemResolverClass);
@ -358,22 +303,19 @@ public final class ContentSectionConfig extends AbstractConfig {
}
// //////////////////////////////////////////////////////////
//
// Processing of parameters which handle overdue notification
//
// //////////////////////////////////////////////////////////
/**
* Retrieve the list of workflow tasks and events for each tasks which
* should receive overdue notification alerts
* Retrieve the list of workflow tasks and events for each tasks which should receive overdue
* notification alerts
*/
public final String[] getTaskAlerts() {
return (String[]) get(m_taskAlerts);
}
/**
* Retrieve whether to send overdue information for unfinished tasks.
*/
@ -382,31 +324,27 @@ public final class ContentSectionConfig extends AbstractConfig {
}
/**
* Retrieve time between when a task is enabled and when it is considered
* overdue.
* Retrieve time between when a task is enabled and when it is considered overdue.
*/
public Integer getTaskDuration() {
return ((Integer) get(m_taskDuration)).intValue();
}
/**
* Retrieve the time to wait between sending successive alerts on the same
* overdue task (in HOURS).
* Retrieve the time to wait between sending successive alerts on the same overdue task (in
* HOURS).
*/
public Integer getAlertInterval() {
return (Integer) get(m_alertInterval);
}
/**
* Retrieve the maximum number of alerts to send that a single task is
* overdue
* Retrieve the maximum number of alerts to send that a single task is overdue
*/
public Integer getMaxAlerts() {
return (Integer) get(m_maxAlerts);
}
// ///////////////////////////////////////////////////////
//
// Processing of parameters which specify a new content
@ -415,49 +353,33 @@ public final class ContentSectionConfig extends AbstractConfig {
// exists and skip processing.
//
// ///////////////////////////////////////////////////////
/**
* Retrieve the name of a new content-section to create.
* Retrieve the STAFF GROUP, i.e. a set of roles (author, editor, publisher, manager) and
* associated privileges for the content section to be created (m_contentSectionName).
*
* The initializer has to check if it already exists and skip processing.
* In loading step a complete default configuration is persisted in database, immutable at this
* point. See contentsection.ContentSectionSetup.registerRoles() In enterprise.init: name roles,
* List of roles to create.
*
* Set consists of a set of roles, for each role first field is the role name, second is the
* description, third is a list of privileges, and (optional) fourth is the workflow task to
* assign to.
*
* The set of roles constructed here is a complete set which reflects all functions of CMS and
* forms a necessary base for operations. When the first content section is created and loaded
* into database (during installation) this set is created, immutable by installer /
* administrator. Additional content section may be created using a subset. For a very special
* purpose a developer may alter the set.
*
* This method is typically used to construct the initial content section during installation.
*
* Not really implemented yet! We need a new parameter type "list" which must have
* multidimensional capabilities.
*
* As a temporary measure a constant list is retrieved. Until now the list was burried in
* enterprise.init and not user available for configuration. So it may turn into a permanent
* solution.
*/
public String getNewContentSectionName() {
return (String) get(m_newContentSectionName);
}
/**
* Retrieve the STAFF GROUP, i.e. a set of roles (author, editor, publisher,
* manager) and associated privileges for the content section to be created
* (m_contentSectionName).
*
* In loading step a complete default configuration is persisted in database,
* immutable at this point.
* See contentsection.ContentSectionSetup.registerRoles()
* In enterprise.init: name roles, List of roles to create.
*
* Set consists of a set of roles, for each role first field is the role name,
* second is the description, third is a list of privileges, and (optional)
* fourth is the workflow task to assign to.
*
* The set of roles constructed here is a complete set which reflects all
* functions of CMS and forms a necessary base for operations. When the first
* content section is created and loaded into database (during installation)
* this set is created, immutable by installer / administrator. Additional
* content section may be created using a subset. For a very special purpose
* a developer may alter the set.
*
* This method is typically used to construct the initial content section
* during installation.
*
* Not really implemented yet! We need a new parameter type "list" which
* must have multidimensional capabilities.
*
* As a temporary measure a constant list is retrieved. Until now the list
* was burried in enterprise.init and not user available for configuration.
* So it may turn into a permanent solution.
*/
/**
* Changed: The forth field is not used anymore
*
@ -487,35 +409,50 @@ public final class ContentSectionConfig extends AbstractConfig {
m_defaultRoles = new ArrayList();
m_defaultRoles.add
( new ArrayList() {{ add("Author");
m_defaultRoles.add(new ArrayList() {
{
add("Author");
add("Creates new content");
add(AUTH_PRIVS);
}}
}
}
);
m_defaultRoles.add
( new ArrayList() {{ add("Editor");
m_defaultRoles.add(new ArrayList() {
{
add("Editor");
add("Reviews and approves the author's work");
add(EDIT_PRIVS);
}}
}
}
);
m_defaultRoles.add
( new ArrayList() {{ add("Publisher");
m_defaultRoles.add(new ArrayList() {
{
add("Publisher");
add("Deploys the content to the web site");
add(PUBL_PRIVS);
}}
}
}
);
m_defaultRoles.add
( new ArrayList() {{ add("Manager");
m_defaultRoles.add(new ArrayList() {
{
add("Manager");
add("Manages the overall content section");
add(MNGR_PRIVS);
}}
}
}
);
m_defaultRoles.add
( new ArrayList() {{ add("Trusted User");
m_defaultRoles.add(new ArrayList() {
{
add("Trusted User");
add("A trusted user is allowed to create and publish items without review");
add(TRST_PRIVS);
}}
}
}
);
return (List) m_defaultRoles;
@ -530,88 +467,156 @@ public final class ContentSectionConfig extends AbstractConfig {
// Prodcution Workflow
m_defaultWorkflows.add(
new HashMap<String, Object>() {{ put("name", "Redigierte Veröffentlichung");
new HashMap<String, Object>() {
{
put("name", "Redigierte Veröffentlichung");
put("description", "A process that involves creating and approving content.");
put("isDefault", "true");
put("tasks",
new ArrayList() {{ add(
new HashMap<String, Object>() {{ put("name", "Verfassen");
new ArrayList() {
{
add(
new HashMap<String, Object>() {
{
put("name", "Verfassen");
put("description", "Create content.");
put("type", "Author");
put("role",
new ArrayList<String>() {{ add("Author");
}}
new ArrayList<String>() {
{
add("Author");
}
}
);
}}
}
}
);
add(
new HashMap<String, Object>() {{ put("name", "Überprüfen");
new HashMap<String, Object>() {
{
put("name", "Überprüfen");
put("description", "Approve content.");
put("type", "Edit");
put("role",
new ArrayList<String>() {{ add("Editor");
}}
new ArrayList<String>() {
{
add("Editor");
}
}
);
put("dependOn",
new ArrayList<String>() {{ add("Verfassen");
}}
new ArrayList<String>() {
{
add("Verfassen");
}
}
);
}}
}
}
);
add(
new HashMap<String, Object>() {{ put("name", "Veröffentlichen");
new HashMap<String, Object>() {
{
put("name", "Veröffentlichen");
put("description", "Deploy content.");
put("type", "Deploy");
put("role",
new ArrayList<String>() {{ add("Publisher");
}}
new ArrayList<String>() {
{
add("Publisher");
}
}
);
put("dependOn",
new ArrayList<String>() {{ add("Überprüfen");
}}
new ArrayList<String>() {
{
add("Überprüfen");
}
}
);
}}
}
}
);
}}
}
}
);
}}
}
}
);
// TrustedUser Workflow
m_defaultWorkflows.add(
new HashMap<String, Object>() {{ put("name", "Direkte Veröffentlichung");
new HashMap<String, Object>() {
{
put("name", "Direkte Veröffentlichung");
put("description", "Create and publish content without review");
put("isDefault", "false");
put("tasks",
new ArrayList() {{ add(
new HashMap<String, Object>() {{ put("name", "Verfassen");
new ArrayList() {
{
add(
new HashMap<String, Object>() {
{
put("name", "Verfassen");
put("description", "Create content.");
put("type", "Author");
put("role",
new ArrayList<String>() {{ add("Author");
new ArrayList<String>() {
{
add("Author");
add("Trusted User");
}}
}
}
);
}}
}
}
);
add(
new HashMap<String, Object>() {{ put("name", "Veröffentlichen");
new HashMap<String, Object>() {
{
put("name", "Veröffentlichen");
put("description", "Deploy content.");
put("type", "Deploy");
put("role",
new ArrayList<String>() {{ add("Publisher");
new ArrayList<String>() {
{
add("Publisher");
add("Trusted User");
}}
}
}
);
put("dependOn",
new ArrayList<String>() {{ add("Verfassen");
}}
new ArrayList<String>() {
{
add("Verfassen");
}
}
);
}}
}
}
);
}}
}
}
);
}}
}
}
);
/*
// Addiditonal Workflows
@ -644,8 +649,8 @@ public final class ContentSectionConfig extends AbstractConfig {
}
/**
* Retrieve whether the content-section is publicly viewable (i.e. without
* registration and login)
* Retrieve whether the content-section is publicly viewable (i.e. without registration and
* login)
*/
public Boolean isPubliclyViewable() {
return ((Boolean) get(m_isPublic)).booleanValue();
@ -665,10 +670,11 @@ public final class ContentSectionConfig extends AbstractConfig {
return (String) get(m_templateResolverClass);
}
/**
* Retrieve whether to use section specific categories. If true they are
* loaded using the next parameters file list {@see getUseSectionCategories()}
* Retrieve whether to use section specific categories. If true they are loaded using the next
* parameters file list {
*
* @see getUseSectionCategories()}
*
* Default value is false, so standard navigation is used.
* @return
@ -678,9 +684,8 @@ public final class ContentSectionConfig extends AbstractConfig {
}
/**
* Retrieve the list of files containing categories to load.
* In old Initialiser: Parameter name: CATEGORIES
* Deskr. "XML file containing the category tree"
* Retrieve the list of files containing categories to load. In old Initialiser: Parameter name:
* CATEGORIES Deskr. "XML file containing the category tree"
*/
public List getCategoryFileList() {
String[] catFiles = (String[]) get(m_categoryFileList);
@ -695,6 +700,4 @@ public final class ContentSectionConfig extends AbstractConfig {
return Arrays.asList(taskAlerts);
}
}

View File

@ -1,8 +1,3 @@
com.arsdigita.cms.contentsection.new_section_name.title=Name of a new content section to be created during next ccm startup.
com.arsdigita.cms.contentsection.new_section_name.purpose=Name of a new content section to be created during next ccm startup. Will be ignored if it already exists.
com.arsdigita.cms.contentsection.new_section_name.example=content
com.arsdigita.cms.contentsection.new_section_name.format=[string]
com.arsdigita.cms.contentsection.xxx.title=
com.arsdigita.cms.contentsection.xxx.purpose=
com.arsdigita.cms.contentsection.xxx.example=/default/item.jsp

View File

@ -16,8 +16,6 @@
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*
*/
package com.arsdigita.cms.contentsection;
import com.arsdigita.cms.ContentSection;
@ -41,19 +39,15 @@ import java.util.Timer;
import java.util.Vector;
import org.apache.log4j.Logger;
/**
* Initializes the content section sub-package of the CMS package (module).
*
* XXX Reformulate according to the code development!
* This initializer performs:
* - check whether to create an additional content sections during restart
* - initializes alert preferences for each content section
* - initializes overdue alerts for each content section
* XXX Reformulate according to the code development! This initializer performs: - check whether to
* create an additional content sections during restart - initializes alert preferences for each
* content section - initializes overdue alerts for each content section
*
* In the (hopefully) near future:
* Content section specific tasks of cms.Initializer will be moved into this
* Initializer.
* In the (hopefully) near future: Content section specific tasks of cms.Initializer will be moved
* into this Initializer.
*
*
* @author Daniel Berrange (berrange@redhat.com)
@ -63,19 +57,23 @@ import org.apache.log4j.Logger;
*/
public class Initializer extends CompoundInitializer {
/** Creates a s_logging category with name = to the full name of class */
/**
* Creates a s_logging category with name = to the full name of class
*/
private static Logger s_log = Logger.getLogger(Initializer.class);
/** Configuration object ContentSectionConfig containing parameters
which may be changed each system startup. */
/**
* Configuration object ContentSectionConfig containing parameters which may be changed each
* system startup.
*/
private static final ContentSectionConfig s_conf = ContentSectionConfig
.getInstance();
/** The Timer used to send Unfinished notifications */
/**
* The Timer used to send Unfinished notifications
*/
private static Vector s_unfinishedTimers = new Vector();
public Initializer() {
//final String url = RuntimeConfig.getConfig().getJDBCURL();
//final int database = DbHelper.getDatabaseFromURL(url);
@ -89,10 +87,9 @@ public class Initializer extends CompoundInitializer {
// */
// public void init(DataInitEvent evt) {
// }
/**
* Initializes domain-coupling machinery, usually consisting of
* registering object instantiators and observers.
* Initializes domain-coupling machinery, usually consisting of registering object instantiators
* and observers.
*
* Here additionally checks whether to create a new content section.
*/
@ -105,32 +102,27 @@ public class Initializer extends CompoundInitializer {
super.init(evt);
/* Register object instantiator for ContentSection */
evt.getFactory().registerInstantiator
(ContentSection.BASE_DATA_OBJECT_TYPE,
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("contentsection.Initializer.init(DomainInitEvent) completed");
}
/**
* Implementation of the {@link Initializer#init(ContextInitEvent)}
* method.
* Implementation of the {@link Initializer#init(ContextInitEvent)} method.
*
* Steps through all installed content sections and for each section
* - initializes the alert preferences
* - initializes the scheduler background thread to fire all alert events.
* Steps through all installed content sections and for each section - initializes the alert
* preferences - initializes the scheduler background thread to fire all alert events.
*
* A delay value of 0 inhibits start of processing.
*
* @param evt The context init event.
*/
@Override
@ -171,8 +163,7 @@ public class Initializer extends CompoundInitializer {
}
/**
* Implementation of the {@link Initializer#init(ContextCloseEvent)}
* method.
* Implementation of the {@link Initializer#init(ContextCloseEvent)} method.
*
* Stops various background threads started during startup process.
*/
@ -196,52 +187,12 @@ 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.getDefaultRoles(),
s_conf.getDefaultWorkflows(),
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
* creating section specific CMStasks from configuration file.
* Steps through a string array of tasks and associated alert events creating section specific
* CMStasks from configuration file.
*
* Note: Tasks are created on a per section base, but we have currently no
* way to store different values for each section. So all sections are
* configured equal.
* Note: Tasks are created on a per section base, but we have currently no way to store
* different values for each section. So all sections are configured equal.
*
* @param section A section object
* @param taskAlerts An array of tasks and associated events
@ -266,13 +217,13 @@ public class Initializer extends CompoundInitializer {
}
/**
* @param section content section for which notifier should be started
* @param sendOverdue
* @param duration
* @param alertInterval
* @param max
*
* @return
*/
private Timer startNotifierTask(ContentSection section,
@ -284,8 +235,8 @@ public class Initializer extends CompoundInitializer {
Timer unfinished = null;
if (sendOverdue.booleanValue()) {
if (duration == null || alertInterval == null || max == null) {
s_log.info("Not sending overdue task alerts, " +
"required initialization parameters were not specified");
s_log.info("Not sending overdue task alerts, "
+ "required initialization parameters were not specified");
return null;
}
// start the Timer as a daemon, so it doesn't keep the JVM from exiting
@ -297,8 +248,7 @@ public class Initializer extends CompoundInitializer {
max.intValue());
// schedule the Task to start in 5 minutes, at 1 hour intervals
unfinished.schedule(notifier, 5L * 60 * 1000, 60L * 60 * 1000);
s_log.info("Sending overdue alerts for tasks greater than " +
duration + " hours old");
s_log.info("Sending overdue alerts for tasks greater than " + duration + " hours old");
} else {
s_log.info("Not sending overdue task alerts");
}