diff --git a/ccm-cms/src/com/arsdigita/cms/contentsection/ContentSectionConfig.java b/ccm-cms/src/com/arsdigita/cms/contentsection/ContentSectionConfig.java index f6987b7a7..06444f0ea 100644 --- a/ccm-cms/src/com/arsdigita/cms/contentsection/ContentSectionConfig.java +++ b/ccm-cms/src/com/arsdigita/cms/contentsection/ContentSectionConfig.java @@ -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 */ @@ -39,17 +44,19 @@ 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 Object to hold one's own instance to return to users. */ + /** + * 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 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 ContentSectionConfig 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.) *
      * taskAlerts = {
      *      { "Authoring",
@@ -97,44 +98,36 @@ public final class ContentSectionConfig extends AbstractConfig {
      *  };
      * 
* - * 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. + * 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. */ - private final Parameter - m_taskAlerts = new StringArrayParameter( - "com.arsdigita.cms.section.task_alerts", - Parameter.REQUIRED, new String[] { - "Authoring:enable:finish:rollback", - "Approval:enable:finish:rollback", - "Deploy:enable:finish:rollback" } - ); + private final Parameter m_taskAlerts = new StringArrayParameter( + "com.arsdigita.cms.section.task_alerts", + Parameter.REQUIRED, new String[]{ + "Authoring:enable:finish:rollback", + "Approval:enable:finish:rollback", + "Deploy:enable:finish:rollback"} + ); /** - * 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( - "com.arsdigita.cms.section.send_overdue_alerts", - Parameter.REQUIRED, - false ); - + 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,40 +135,30 @@ 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( - "com.arsdigita.cms.section.task_duration", - Parameter.REQUIRED, - new Integer(96) ); - + 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( - "com.arsdigita.cms.section.alert_interval", - Parameter.REQUIRED, - new Integer(24) ); - + 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( - "com.arsdigita.cms.section.max_alerts", - Parameter.REQUIRED, - new Integer(5) ); - - + private final Parameter m_maxAlerts = new IntegerParameter( + "com.arsdigita.cms.section.max_alerts", + Parameter.REQUIRED, + new Integer(5)); // /////////////////////////////////////////////////////// // @@ -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,105 +190,87 @@ public final class ContentSectionConfig extends AbstractConfig { * * Parameter name in the old initializer code: PUBLIC. Default true. */ - private final BooleanParameter - m_isPublic = new BooleanParameter( - "com.arsdigita.cms.section.is_public", - Parameter.REQUIRED, - true); + private final BooleanParameter m_isPublic = new BooleanParameter( + "com.arsdigita.cms.section.is_public", + Parameter.REQUIRED, + true); /** * 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( - "com.arsdigita.cms.section.ctypes_list", - Parameter.REQUIRED, - new String[] {} ); + 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 *
com.arsdigita.cms.dispatcher.MultilingualItemResolver
). * * Default value (site-wide) is handled via the parameter - *
com.arsdigita.cms.default_item_resolver_class
. - * 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
com.arsdigita.cms.dispatcher.ItemResolver
. + *
com.arsdigita.cms.default_item_resolver_class
. 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 + *
com.arsdigita.cms.dispatcher.ItemResolver
. * - * 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( - "com.arsdigita.cms.section.item_resolver_class", - Parameter.OPTIONAL, null ); + 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
com.arsdigita.cms.dispatcher.DefaultTemplateResolver
) + * Name of the template resolver class to use for the section (defaults to + *
com.arsdigita.cms.dispatcher.DefaultTemplateResolver
) * * Default value (site-wide) is handled via the parameter - *
com.arsdigita.cms.default_template_resolver_class
. - * 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
com.arsdigita.cms.dispatcher.TemplateResolver
. + *
com.arsdigita.cms.default_template_resolver_class
. 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 + *
com.arsdigita.cms.dispatcher.TemplateResolver
. * * Parameter name TEMPLATE_RESOLVER_CLASS in the old initializer system. */ - private final Parameter - m_templateResolverClass = new StringParameter( - "com.arsdigita.cms.section.template_resolver_class", - Parameter.OPTIONAL, - null ); + 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", - Parameter.REQUIRED, false); + 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( - "com.arsdigita.cms.section.categories_toload", - Parameter.REQUIRED, - new String[] {"/WEB-INF/resources/article-categories.xml", - "/WEB-INF/resources/navigation-categories.xml"} ); + private final Parameter m_categoryFileList = new StringArrayParameter( + "com.arsdigita.cms.section.categories_toload", + Parameter.REQUIRED, + new String[]{"/WEB-INF/resources/article-categories.xml", + "/WEB-INF/resources/navigation-categories.xml"}); // Category tree to load // categories = { "/WEB-INF/resources/article-categories.xml", // "/WEB-INF/resources/navigation-categories.xml" }; @@ -331,14 +279,13 @@ public final class ContentSectionConfig extends AbstractConfig { // List.class, // Collections.EMPTY_LIST); - /** * Constructor, do not instantiate this class directly! * * @see ContentSection#getConfig() */ public ContentSectionConfig() { - + // parameters for alerts (notifications) register(m_taskAlerts); register(m_sendOverdueAlerts); @@ -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,54 +303,47 @@ 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. */ public Boolean getSendOverdueAlerts() { - return ((Boolean) get(m_sendOverdueAlerts)).booleanValue(); - } + return ((Boolean) get(m_sendOverdueAlerts)).booleanValue(); + } /** - * 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(); - } + 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); - } + 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); - } - - + return (Integer) get(m_maxAlerts); + } // /////////////////////////////////////////////////////// // @@ -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 * @@ -465,187 +387,270 @@ public final class ContentSectionConfig extends AbstractConfig { public List getDefaultRoles() { final List AUTH_PRIVS = Arrays.asList( - "new_item","read_item", "preview_item", "edit_item", - "categorize_items"); + "new_item", "read_item", "preview_item", "edit_item", + "categorize_items"); final List EDIT_PRIVS = Arrays.asList( - "new_item","read_item", "preview_item", "edit_item", - "categorize_items", "delete_item", "approve_item" ); + "new_item", "read_item", "preview_item", "edit_item", + "categorize_items", "delete_item", "approve_item"); final List PUBL_PRIVS = Arrays.asList( - "new_item","read_item", "preview_item", "edit_item", - "categorize_items", "delete_item", "approve_item", - "publish"); + "new_item", "read_item", "preview_item", "edit_item", + "categorize_items", "delete_item", "approve_item", + "publish"); final List MNGR_PRIVS = Arrays.asList( - "new_item","read_item", "preview_item", "edit_item", - "categorize_items", "delete_item", "approve_item", - "publish", - "staff_admin", "content_type_admin", "lifecycle_admin", - "workflow_admin", "category_admin"); + "new_item", "read_item", "preview_item", "edit_item", + "categorize_items", "delete_item", "approve_item", + "publish", + "staff_admin", "content_type_admin", "lifecycle_admin", + "workflow_admin", "category_admin"); final List TRST_PRIVS = Arrays.asList( - "new_item","read_item", "preview_item", "edit_item", - "categorize_items", "delete_item", "approve_item", - "publish", "apply_alternate_workflows"); + "new_item", "read_item", "preview_item", "edit_item", + "categorize_items", "delete_item", "approve_item", + "publish", "apply_alternate_workflows"); m_defaultRoles = new ArrayList(); - m_defaultRoles.add - ( new ArrayList() {{ add("Author"); - add("Creates new content"); - add(AUTH_PRIVS); - }} - ); - 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"); - add("Deploys the content to the web site"); - add(PUBL_PRIVS); - }} - ); - m_defaultRoles.add - ( new ArrayList() {{ add("Manager"); - add("Manages the overall content section"); - add(MNGR_PRIVS); - }} - ); - m_defaultRoles.add - ( new ArrayList() {{ add("Trusted User"); - add("A trusted user is allowed to create and publish items without review"); - add(TRST_PRIVS); - }} - ); + m_defaultRoles.add(new ArrayList() { + { + add("Author"); + add("Creates new content"); + add(AUTH_PRIVS); + } - return (List) m_defaultRoles ; + } + ); + 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"); + add("Deploys the content to the web site"); + add(PUBL_PRIVS); + } + + } + ); + m_defaultRoles.add(new ArrayList() { + { + add("Manager"); + add("Manages the overall content section"); + add(MNGR_PRIVS); + } + + } + ); + 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; } public List getDefaultWorkflows() { - - if(m_defaultWorkflows == null) { - - m_defaultWorkflows = new ArrayList(); - // Prodcution Workflow - m_defaultWorkflows.add( - new HashMap() {{ 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() {{ put("name", "Verfassen"); - put("description", "Create content."); - put("type", "Author"); - put("role", - new ArrayList() {{ add("Author"); - }} - ); - }} - ); - add( - new HashMap() {{ put("name", "Überprüfen"); - put("description", "Approve content."); - put("type", "Edit"); - put("role", - new ArrayList() {{ add("Editor"); - }} - ); - put("dependOn", - new ArrayList() {{ add("Verfassen"); - }} - ); - }} - ); - add( - new HashMap() {{ put("name", "Veröffentlichen"); - put("description", "Deploy content."); - put("type", "Deploy"); - put("role", - new ArrayList() {{ add("Publisher"); - }} - ); - put("dependOn", - new ArrayList() {{ add("Überprüfen"); - }} - ); - }} - ); - }} - ); - }} - ); + if (m_defaultWorkflows == null) { - // TrustedUser Workflow - m_defaultWorkflows.add( - new HashMap() {{ put("name", "Direkte Veröffentlichung"); - put("description", "Create and publish content without review"); - put("isDefault", "false"); - put("tasks", - new ArrayList() {{ add( - new HashMap() {{ put("name", "Verfassen"); - put("description", "Create content."); - put("type", "Author"); - put("role", - new ArrayList() {{ add("Author"); - add("Trusted User"); - }} - ); - }} - ); - add( - new HashMap() {{ put("name", "Veröffentlichen"); - put("description", "Deploy content."); - put("type", "Deploy"); - put("role", - new ArrayList() {{ add("Publisher"); - add("Trusted User"); - }} - ); - put("dependOn", - new ArrayList() {{ add("Verfassen"); - }} - ); - }} - ); - }} - ); - }} - ); -/* - // Addiditonal Workflows - m_defaultWorkflows.add( - new HashMap() {{ put("name", ""); - put("description", ""); - put("tasks", - new ArrayList() {{ add( - new HashMap() {{ put("name", ""); - put("description", ""); - put("type", ""); - put("role", - new ArrayList() {{ add(""); - }} - ); - put("dependOn", - new ArrayList() {{ add(""); - }} - ); - }} - ); - }} - ); - }} - ); -*/ + m_defaultWorkflows = new ArrayList(); + + // Prodcution Workflow + m_defaultWorkflows.add( + new HashMap() { + { + 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() { + { + put("name", "Verfassen"); + put("description", "Create content."); + put("type", "Author"); + put("role", + new ArrayList() { + { + add("Author"); + } + + } + ); + } + + } + ); + add( + new HashMap() { + { + put("name", "Überprüfen"); + put("description", "Approve content."); + put("type", "Edit"); + put("role", + new ArrayList() { + { + add("Editor"); + } + + } + ); + put("dependOn", + new ArrayList() { + { + add("Verfassen"); + } + + } + ); + } + + } + ); + add( + new HashMap() { + { + put("name", "Veröffentlichen"); + put("description", "Deploy content."); + put("type", "Deploy"); + put("role", + new ArrayList() { + { + add("Publisher"); + } + + } + ); + put("dependOn", + new ArrayList() { + { + add("Überprüfen"); + } + + } + ); + } + + } + ); + } + + } + ); + } + + } + ); + + // TrustedUser Workflow + m_defaultWorkflows.add( + new HashMap() { + { + put("name", "Direkte Veröffentlichung"); + put("description", "Create and publish content without review"); + put("isDefault", "false"); + put("tasks", + new ArrayList() { + { + add( + new HashMap() { + { + put("name", "Verfassen"); + put("description", "Create content."); + put("type", "Author"); + put("role", + new ArrayList() { + { + add("Author"); + add("Trusted User"); + } + + } + ); + } + + } + ); + add( + new HashMap() { + { + put("name", "Veröffentlichen"); + put("description", "Deploy content."); + put("type", "Deploy"); + put("role", + new ArrayList() { + { + add("Publisher"); + add("Trusted User"); + } + + } + ); + put("dependOn", + new ArrayList() { + { + add("Verfassen"); + } + + } + ); + } + + } + ); + } + + } + ); + } + + } + ); + /* + // Addiditonal Workflows + m_defaultWorkflows.add( + new HashMap() {{ put("name", ""); + put("description", ""); + put("tasks", + new ArrayList() {{ add( + new HashMap() {{ put("name", ""); + put("description", ""); + put("type", ""); + put("role", + new ArrayList() {{ add(""); + }} + ); + put("dependOn", + new ArrayList() {{ add(""); + }} + ); + }} + ); + }} + ); + }} + ); + */ } - + return m_defaultWorkflows; } - + /** - * 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); } - - } diff --git a/ccm-cms/src/com/arsdigita/cms/contentsection/ContentSectionConfig_parameter.properties b/ccm-cms/src/com/arsdigita/cms/contentsection/ContentSectionConfig_parameter.properties index 3c2425d79..73d86624a 100755 --- a/ccm-cms/src/com/arsdigita/cms/contentsection/ContentSectionConfig_parameter.properties +++ b/ccm-cms/src/com/arsdigita/cms/contentsection/ContentSectionConfig_parameter.properties @@ -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 diff --git a/ccm-cms/src/com/arsdigita/cms/contentsection/Initializer.java b/ccm-cms/src/com/arsdigita/cms/contentsection/Initializer.java index e39f8000d..3892b3c1a 100644 --- a/ccm-cms/src/com/arsdigita/cms/contentsection/Initializer.java +++ b/ccm-cms/src/com/arsdigita/cms/contentsection/Initializer.java @@ -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,22 +57,26 @@ 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(); + .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); + //final String url = RuntimeConfig.getConfig().getJDBCURL(); + //final int database = DbHelper.getDatabaseFromURL(url); } // Currently nothing to do here. May change during the ongoing migration process @@ -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, - new ACSObjectInstantiator() { - @Override - public DomainObject doNewInstance(DataObject dobj) { - return new ContentSection(dobj); - } - } ); + 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 @@ -145,34 +137,33 @@ public class Initializer extends CompoundInitializer { // TODO: Store alerts prefs as well as timer configuration for each // content section and make it configurable in the UI. // For now we step through all sections and configure them the same way. - ContentSectionCollection sections=ContentSection.getAllSections(); - while( sections.next() ) { + ContentSectionCollection sections = ContentSection.getAllSections(); + while (sections.next()) { ContentSection section = sections.getContentSection(); // Initialize workflow tasks and associated events from configuration // file filling a hashmap. - initializeTaskAlerts(section, s_conf.getTaskAlerts() ); + initializeTaskAlerts(section, s_conf.getTaskAlerts()); // create a standard java util timer object Timer unfinishedTimer = startNotifierTask( - section, - s_conf.getSendOverdueAlerts(), - s_conf.getTaskDuration(), - s_conf.getAlertInterval(), - s_conf.getMaxAlerts() - ); - if ( unfinishedTimer != null) { + section, + s_conf.getSendOverdueAlerts(), + s_conf.getTaskDuration(), + s_conf.getAlertInterval(), + s_conf.getMaxAlerts() + ); + if (unfinishedTimer != null) { s_unfinishedTimers.addElement(unfinishedTimer); } } sections.close(); - + s_log.debug("content section ContextInitEvent completed"); } /** - * Implementation of the {@link Initializer#init(ContextCloseEvent)} - * method. + * Implementation of the {@link Initializer#init(ContextCloseEvent)} method. * * Stops various background threads started during startup process. */ @@ -182,76 +173,36 @@ public class Initializer extends CompoundInitializer { Timer unfinishedTimer = null; if (s_unfinishedTimers.size() > 0) { - for (Enumeration el=s_unfinishedTimers.elements(); - el.hasMoreElements(); ) { + for (Enumeration el = s_unfinishedTimers.elements(); + el.hasMoreElements();) { unfinishedTimer = (Timer) el.nextElement(); - if(unfinishedTimer != null) { + if (unfinishedTimer != null) { unfinishedTimer.cancel(); } unfinishedTimer = null; - // s_unfinishedTimer = null; + // s_unfinishedTimer = null; } } 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 section A section object * @param taskAlerts An array of tasks and associated events */ public void initializeTaskAlerts(ContentSection section, String[] taskAlerts) { if (taskAlerts != null) { - for (int i=0,n=taskAlerts.length; i