From 4d624f4d8870c3a1de8e93e238a6285a5d7de80b Mon Sep 17 00:00:00 2001 From: pb Date: Fri, 9 Dec 2011 22:35:47 +0000 Subject: [PATCH] Enhancement ccm Loader (kann mehrere sections anlegen), Korrekturen und Bugfixes Loader, Codebereinigung. git-svn-id: https://svn.libreccm.org/ccm/trunk@1330 8810af33-2d31-482b-a856-94f89814c4df --- ccm-cms/src/com/arsdigita/cms/CMSConfig.java | 20 ++- .../cms/CMSConfig_parameter.properties | 9 +- .../src/com/arsdigita/cms/ContentSection.java | 37 ++++++ .../cms/ContentSectionCollection.java | 4 +- .../arsdigita/cms/ContentTypeCollection.java | 5 + ccm-cms/src/com/arsdigita/cms/Loader.java | 57 ++------ .../src/com/arsdigita/cms/LoaderConfig.java | 122 +++++++----------- .../cms/LoaderConfig_parameter.properties | 5 - .../arsdigita/cms/dispatcher/Utilities.java | 12 +- 9 files changed, 124 insertions(+), 147 deletions(-) diff --git a/ccm-cms/src/com/arsdigita/cms/CMSConfig.java b/ccm-cms/src/com/arsdigita/cms/CMSConfig.java index b3210e151..191171c20 100755 --- a/ccm-cms/src/com/arsdigita/cms/CMSConfig.java +++ b/ccm-cms/src/com/arsdigita/cms/CMSConfig.java @@ -531,10 +531,12 @@ public final class CMSConfig extends AbstractConfig { // /////////////////////////////////////////// // Content Section config related parameters // /////////////////////////////////////////// - private final Parameter m_defaultSection = new StringParameter( - "com.arsdigita.cms.default_content_section", - Parameter.REQUIRED, - "content"); +// Nolonger used, +// replaced by c.ad.cms.ContentSection.getDefaultSection().getName() +// private final Parameter m_defaultSection = new StringParameter( +// "com.arsdigita.cms.default_content_section", +// Parameter.REQUIRED, +// "content"); // /////////////////////////////////////////// // Content Section creation parameters // XXX these are probably temporary parameters, as the @@ -655,7 +657,7 @@ public final class CMSConfig extends AbstractConfig { register(m_contentCenterMap); // Content Section config related parameters - register(m_defaultSection); + // register(m_defaultSection); // Content Section creation parameters register(m_defaultItemResolverClass); @@ -712,8 +714,14 @@ public final class CMSConfig extends AbstractConfig { return (InputStream) get(m_itemAdapters); } + /** + * + * @deprecated + * use com.arsdigita.cms.ContentSection.getDefaultSection().getName() instead + */ public final String getDefaultContentSection() { - return (String) get(m_defaultSection); + // return (String) get(m_defaultSection); + return (String) ContentSection.getDefaultSection().getName(); } public final boolean getUseStreamlinedCreation() { diff --git a/ccm-cms/src/com/arsdigita/cms/CMSConfig_parameter.properties b/ccm-cms/src/com/arsdigita/cms/CMSConfig_parameter.properties index c8da5c18f..58f57ad1b 100755 --- a/ccm-cms/src/com/arsdigita/cms/CMSConfig_parameter.properties +++ b/ccm-cms/src/com/arsdigita/cms/CMSConfig_parameter.properties @@ -38,10 +38,11 @@ com.arsdigita.cms.item_adapters.purpose=Path to an XML resource containing adapt com.arsdigita.cms.item_adapters.example=/WEB-INF/resources/cms-item-adapters.xml com.arsdigita.cms.item_adapters.format=[string] -com.arsdigita.cms.default_content_section.title = Default Content Section -com.arsdigita.cms.default_content_section.purpose = The name of the default content section -com.arsdigita.cms.default_content_section.example = content -com.arsdigita.cms.default_content_section.format = [string] +# No longer used +# com.arsdigita.cms.default_content_section.title = Default Content Section +# com.arsdigita.cms.default_content_section.purpose = The name of the default content section +# com.arsdigita.cms.default_content_section.example = content +# com.arsdigita.cms.default_content_section.format = [string] com.arsdigita.cms.use_streamlined_creation.title=Use streamlined content creation com.arsdigita.cms.use_streamlined_creation.purpose=Use streamlined content creation: upon item creation, automatically open authoring steps and forward to the next step diff --git a/ccm-cms/src/com/arsdigita/cms/ContentSection.java b/ccm-cms/src/com/arsdigita/cms/ContentSection.java index 474637ab8..90dc7d8d9 100755 --- a/ccm-cms/src/com/arsdigita/cms/ContentSection.java +++ b/ccm-cms/src/com/arsdigita/cms/ContentSection.java @@ -1056,6 +1056,43 @@ public class ContentSection extends Application { return new ContentSectionCollection(da); } + /** + * Retrieve the default content section in the system. + * + * Default section is the first section created during setup, therefore it + * is recognized as the one with the lowest id. + * + * @return The default content section. + */ + public static ContentSection getDefaultSection() { + ContentSectionCollection sections = getAllSections(); + sections.addOrder(ID); + sections.next(); // positions on the first section + ContentSection section = (ContentSection) sections.getDomainObject(); + if (sections.isFirst() ) { + sections.close(); + s_log.warn("Default section is "+section.getName() ); + return section; + } else { + sections.close(); + s_log.warn("Section found: "+section.getName()+", but not first." ); + return null; + } + } + + /** + * Convenience method to retrieve the name of the default content section + * in the system. + * + * Default section is the first section created during setup, therefore it + * is recognized as the one with the lowest id. + * + * @return The default content section name. + */ + public static String getDefaultSectionName() { + return getDefaultSection().getBaseDataObjectType(); + } + /** * Creates a content section of the given name using default values and * returns it. diff --git a/ccm-cms/src/com/arsdigita/cms/ContentSectionCollection.java b/ccm-cms/src/com/arsdigita/cms/ContentSectionCollection.java index 1f5414311..200aae4e0 100755 --- a/ccm-cms/src/com/arsdigita/cms/ContentSectionCollection.java +++ b/ccm-cms/src/com/arsdigita/cms/ContentSectionCollection.java @@ -37,7 +37,7 @@ public class ContentSectionCollection extends DomainCollection { /** * Constructor. * - **/ + */ public ContentSectionCollection(DataCollection dataCollection) { super(dataCollection); } @@ -50,6 +50,7 @@ public class ContentSectionCollection extends DomainCollection { * (e.g. "primaryURL" in order to sort by section name * see c.ad.london.util.cmd.SiteMapList as an example ). */ + @Override public void addOrder(String order) { m_dataCollection.addOrder(order); } @@ -59,6 +60,7 @@ public class ContentSectionCollection extends DomainCollection { * the collection. * */ + @Override public DomainObject getDomainObject() { return new ContentSection(m_dataCollection.getDataObject()); } diff --git a/ccm-cms/src/com/arsdigita/cms/ContentTypeCollection.java b/ccm-cms/src/com/arsdigita/cms/ContentTypeCollection.java index 4eb2797f2..a7dad9f2d 100755 --- a/ccm-cms/src/com/arsdigita/cms/ContentTypeCollection.java +++ b/ccm-cms/src/com/arsdigita/cms/ContentTypeCollection.java @@ -47,12 +47,17 @@ public class ContentTypeCollection extends DomainCollection { * Set the order of this Collection. This method needs to be called * before next() is called on this collection. * + * @param order: name of the pdl property to use for sorting the collection + * (e.g. "primaryURL" in order to sort by section name + * see c.ad.london.util.cmd.SiteMapList as an example ). */ + @Override public void addOrder(String order) { m_dataCollection.addOrder(order); } + @Override public Filter addFilter(String conditions) { return m_dataCollection.addFilter(conditions); } diff --git a/ccm-cms/src/com/arsdigita/cms/Loader.java b/ccm-cms/src/com/arsdigita/cms/Loader.java index 4531ce3c7..7f9b2ebc9 100755 --- a/ccm-cms/src/com/arsdigita/cms/Loader.java +++ b/ccm-cms/src/com/arsdigita/cms/Loader.java @@ -58,7 +58,7 @@ import org.apache.log4j.Logger; // ccm/admin/sitemap lists them appropriately. // // Next Try -// Refactor using legacy compatible web/Application and ApplicationSetup +// Refactor using legacy compatible web/Application and ApplicationSetup DONE /** @@ -117,48 +117,10 @@ public class Loader extends PackageLoader { ); - -// Nolonger used -// /** -// * Constant string used as key for creating CMS (content-section) as a -// * legacy application. -// */ -// private final static String CMS_PACKAGE_KEY = "content-section"; -// /** -// * Dispatcher class for CMS (needed to be assigned to a legacy application). -// */ -// private final static String CMS_DISPATCHER_CLASS = -// "com.arsdigita.cms.dispatcher.ContentSectionDispatcher"; -// /** -// * Constant string used as key for creating Workspace (content-center) as a -// * legacy application. -// */ -// public static final String WORKSPACE_PACKAGE_KEY = "content-center"; -// private static final String WORKSPACE_INSTANCE_NAME = "Content Center"; -// /** -// * Dispatcher class for Workspace (content-center) (needed to be assigned -// * to a legacy application). -// */ -// private static final String WORKSPACE_DISPATCHER_CLASS = -// "com.arsdigita.cms.dispatcher.ContentCenterDispatcher"; -// // To be updated soon... -// // "com.arsdigita.dispatcher.DefaultPackageDispatcher"; - -// No longer used, moved to class Service -// /** -// * Name of the CMS service package instance, i.e. its URL. -// */ -// private final static String SERVICE_URL = "cms-service"; -// /** -// * Constant string used as key for creating service package as a -// * legacy application. -// */ -// public final static String SERVICE_PACKAGE_KEY = "cms-service"; - - /** - * - */ + /** List of classnames of internal base content types (needed in every + * section created), generated while loading those content types in + * loadContentTypeDefinitions(files) for later use in register step. */ private ArrayList m_content_type_list = new ArrayList(); /** @@ -438,13 +400,14 @@ public class Loader extends PackageLoader { /* Register internal base content types. Paramter is a list of * class names created by internal content type load method. - * @see loadContentTypeDefinitions(List) */ + * @see loadContentTypeDefinitions(List) + * External content types (provided by additional packages) are + * not available at CMS load time and can not processed by Loader. + * Registration of those content types are dealt with in the + * respective Loader or in the CMS workspace GUI. + * For each created section the base types get registered. */ setup.registerContentTypes(m_content_type_list); - // See method doc above. No external content types available at - // cms load time, - // setup.registerContentTypes(s_conf.getContentSectionsContentTypes()); - // Section specific categories, usually not used. // During initial load at install time nor used at all! // default value is false so no categories get loaded. diff --git a/ccm-cms/src/com/arsdigita/cms/LoaderConfig.java b/ccm-cms/src/com/arsdigita/cms/LoaderConfig.java index eeed7c0d4..484fe37d3 100644 --- a/ccm-cms/src/com/arsdigita/cms/LoaderConfig.java +++ b/ccm-cms/src/com/arsdigita/cms/LoaderConfig.java @@ -106,28 +106,28 @@ public final class LoaderConfig extends AbstractConfig { // Parameter.REQUIRED, // "/WEB-INF/resources/content-center-map.xml"); - // Update master object if upgrading from old versioning - // XXX: shouldn't we just gut this section (and - // VersioningUpgrader)? It is an upgrade fix from 5.1 or - // earlier, and relying on VersionedACSObject is - // deprecated - // (pboy): Default value is false and this value didn't change for - // a very long period. Class can be excluded from source. - // final boolean updateMaster = - // ((Boolean)m_conf.getParameter(UPDATE_MASTER)).booleanValue(); - // if (updateMaster) { - // VersioningUpgrader.updateMasterObject(); - // } +// Update master object if upgrading from old versioning +// XXX: shouldn't we just gut this section (and +// VersioningUpgrader)? It is an upgrade fix from 5.1 or +// earlier, and relying on VersionedACSObject is +// deprecated +// (pboy): Default value is false and this value didn't change for +// a very long period. Class can be excluded from source. +// final boolean updateMaster = +// ((Boolean)m_conf.getParameter(UPDATE_MASTER)).booleanValue(); +// if (updateMaster) { +// VersioningUpgrader.updateMasterObject(); +// } - // XXX: ItemDispatcher is no longer used. Is the following - // still a valid enterprise.init parameter? Do we need to - // set ContentSectionServlet.s_cacheItems instead of the - // below (which is currently always true), or does this go - // away entirely? - // final boolean cacheItems = - // ((Boolean)m_conf.getParameter(CACHE_ITEMS)).booleanValue(); - // s_log.debug("Set cache items to " + cacheItems); - // ItemDispatcher.setCacheItems(cacheItems); +// XXX: ItemDispatcher is no longer used. Is the following +// still a valid enterprise.init parameter? Do we need to +// set ContentSectionServlet.s_cacheItems instead of the +// below (which is currently always true), or does this go +// away entirely? +// final boolean cacheItems = +// ((Boolean)m_conf.getParameter(CACHE_ITEMS)).booleanValue(); +// s_log.debug("Set cache items to " + cacheItems); +// ItemDispatcher.setCacheItems(cacheItems); /** @@ -186,11 +186,13 @@ public final class LoaderConfig extends AbstractConfig { * Not implemented yet! We need a new parameter type "list" which must have * multidimensional capabilities. */ -// private final Parameter -// m_staffGroup = new StringParameter( -// "com.arsdigita.cms.loader.section_staff_group", -// Parameter.REQUIRED, -// null); + /* + private final Parameter + m_staffGroup = new StringParameter( + "com.arsdigita.cms.loader.section_staff_group", + Parameter.REQUIRED, + null); + */ private List m_staffGroup; @@ -208,32 +210,6 @@ public final class LoaderConfig extends AbstractConfig { 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" - * } - * - * 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. - * - * While loading ccm-cms no external content type packages are available - * because all content types depend on ccm-cms. Therefore this parameter - * can not beused in loader context. - */ - //private final Parameter - // m_contentTypeList = new StringArrayParameter( - // "com.arsdigita.cms.loader.section_ctypes_list", - // Parameter.REQUIRED, - // new String[] {} ); - // Page Resolver Class, set autonomously by ContentSection.create() method. // Item Resolver Class, configurable. @@ -410,22 +386,24 @@ public final class LoaderConfig extends AbstractConfig { "List of all installed packages") ); -// Currently not a Loader task. There is no way to persist tasks preferences -// on a per section base. -// /** -// * 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. Note that the values below are -// * based on the task labels, and as such are not globalized. -// */ -// private final Parameter -// m_taskAlerts = new StringArrayParameter( -// "com.arsdigita.cms.task_alerts", -// Parameter.REQUIRED, new String[] { -// "Authoring:enable:finish:rollback", -// "Approval:enable:finish:rollback", -// "Deploy:enable:finish:rollback" } ); + // Currently not a Loader task. There is no way to persist tasks preferences + // on a per section base. + /** + * 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. Note that the values below are + * based on the task labels, and as such are not globalized. + */ + /* + private final Parameter + m_taskAlerts = new StringArrayParameter( + "com.arsdigita.cms.task_alerts", + Parameter.REQUIRED, new String[] { + "Authoring:enable:finish:rollback", + "Approval:enable:finish:rollback", + "Deploy:enable:finish:rollback" } ); + */ // /////////////////////////////////////////////////////////////////////// @@ -492,7 +470,6 @@ public final class LoaderConfig extends AbstractConfig { register(m_itemResolverClass); register(m_templateResolverClass); - // register(m_contentTypeList); register(m_useSectionCategories); register(m_categoryFileList); @@ -684,12 +661,5 @@ public final class LoaderConfig extends AbstractConfig { public List getDataQueries() { return dataQueries; } - /** - * Retrieve the - */ -// public List getContentSectionsContentTypes() { -// String[] contentTypes = (String[]) get(m_contentTypeList); -// return Arrays.asList(contentTypes); -// } } diff --git a/ccm-cms/src/com/arsdigita/cms/LoaderConfig_parameter.properties b/ccm-cms/src/com/arsdigita/cms/LoaderConfig_parameter.properties index 65d32c697..fc726ba27 100644 --- a/ccm-cms/src/com/arsdigita/cms/LoaderConfig_parameter.properties +++ b/ccm-cms/src/com/arsdigita/cms/LoaderConfig_parameter.properties @@ -22,8 +22,3 @@ com.arsdigita.cms.loader.section_is_public.title= com.arsdigita.cms.loader.section_is_public.purpose= com.arsdigita.cms.loader.section_is_public.example= com.arsdigita.cms.loader.section_is_public.format=[StringArray] - -com.arsdigita.cms.loader.section_ctypes_list.title= -com.arsdigita.cms.loader.section_ctypes_list.purpose= -com.arsdigita.cms.loader.section_ctypes_list.example= -com.arsdigita.cms.loader.section_ctypes_list.format=[ boolean] diff --git a/ccm-cms/src/com/arsdigita/cms/dispatcher/Utilities.java b/ccm-cms/src/com/arsdigita/cms/dispatcher/Utilities.java index 9c5025527..ec7273aef 100755 --- a/ccm-cms/src/com/arsdigita/cms/dispatcher/Utilities.java +++ b/ccm-cms/src/com/arsdigita/cms/dispatcher/Utilities.java @@ -24,8 +24,6 @@ import com.arsdigita.cms.CMS; import com.arsdigita.cms.ContentSection; import com.arsdigita.cms.ImageAsset; import com.arsdigita.cms.SecurityManager; -//import com.arsdigita.cms.installer.ServiceInstaller; -// import com.arsdigita.cms.installer.WorkspaceInstaller; import com.arsdigita.dispatcher.DispatcherHelper; import com.arsdigita.kernel.Kernel; import com.arsdigita.kernel.KernelContext; @@ -54,9 +52,6 @@ import java.util.Map; */ public class Utilities { -// public final static String CMS_WORKSPACE = WorkspaceInstaller.PACKAGE_KEY; -// public final static String CMS_SERVICE = ServiceInstaller.PACKAGE_KEY; - // Used for caching util lookups private static HashMap m_cache = new HashMap(); @@ -181,7 +176,7 @@ public class Utilities { if ( !instances.next() ) { instances.close(); throw new RuntimeException( - "Failed to locate an instance of the singleton package: " + key); + "Failed to locate an instance of the singleton package: " + key); } else { instance = instances.getPackageInstance(); instances.close(); @@ -192,7 +187,7 @@ public class Utilities { if ( !nodes.next() ) { nodes.close(); throw new RuntimeException( - "Failed to locate a mountpoint for the singleton package: " + key); + "Failed to locate a mountpoint for the singleton package: " + key); } else { node = nodes.getSiteNode(); nodes.close(); @@ -341,7 +336,8 @@ public class Utilities { * the browser does not cache tha page * * @param response The HTTP response - * @deprecated use com.arsdigita.dispatcher.DispatcherHelper.cacheDisable(HttpServletResponse) + * @deprecated use + * com.arsdigita.dispatcher.DispatcherHelper.cacheDisable(HttpServletResponse) */ public static void disableBrowserCache(HttpServletResponse response) { response.addHeader("pragma", "no-cache");