diff --git a/ccm-cms/pdl/com/arsdigita/content-section/ContentType.pdl b/ccm-cms/pdl/com/arsdigita/content-section/ContentType.pdl index 8a771c4c0..b0113aece 100755 --- a/ccm-cms/pdl/com/arsdigita/content-section/ContentType.pdl +++ b/ccm-cms/pdl/com/arsdigita/content-section/ContentType.pdl @@ -32,7 +32,7 @@ object type ContentType extends ACSObject { String[0..1] ancestors = content_types.ancestors VARCHAR(2000); String[0..1] siblings = content_types.siblings VARCHAR(2000); - Boolean[1..1] isInternal = content_types.is_internal CHAR(1); + String[1..1] mode = content_types.mode CHAR(1); BigDecimal[0..1] itemFormID = content_types.item_form_id INTEGER; AuthoringKit[0..1] authoringKit = join content_types.type_id to authoring_kits.type_id; @@ -64,7 +64,7 @@ association { do { select t.type_id, t.object_type, t.label, t.description, t.classname, - t.ancestors, t.siblings, t.is_internal, t.item_form_id + t.ancestors, t.siblings, t.mode, t.item_form_id from content_types t, content_section_type_map m, authoring_kits a where @@ -80,7 +80,7 @@ association { creatableContentTypes.className = t.classname; creatableContentTypes.ancestors = t.ancestors; creatableContentTypes.siblings = t.siblings; - creatableContentTypes.isInternal = t.is_internal; + creatableContentTypes.mode = t.mode; creatableContentTypes.itemFormID = t.item_form_id; } } @@ -112,7 +112,7 @@ association { do { select t.type_id, t.object_type, t.label, t.description, t.classname, - t.ancestors, t.siblings, t.is_internal, t.item_form_id + t.ancestors, t.siblings, t.mode, t.item_form_id from content_types t where @@ -128,7 +128,7 @@ association { notAssociatedContentTypes.className = t.classname; notAssociatedContentTypes.ancestors = t.ancestors; notAssociatedContentTypes.siblings = t.siblings; - notAssociatedContentTypes.isInternal = t.is_internal; + notAssociatedContentTypes.mode = t.mode; notAssociatedContentTypes.itemFormID = t.item_form_id; } } @@ -157,9 +157,9 @@ query registeredContentTypes { select t.type_id, t.object_type, t.label, t.description, t.classname, t.ancestors, t.siblings, - t.is_internal, t.item_form_id + t.mode, t.item_form_id from content_types t - where t.is_internal = '0' + where t.mode != 'I' and exists (select 1 from content_section_type_map where type_id = t.type_id) } map { @@ -170,7 +170,7 @@ query registeredContentTypes { type.className = t.classname; type.ancestors = t.ancestors; type.siblings = t.siblings; - type.isInternal = t.is_internal; + type.mode = t.mode; type.itemFormID = t.item_form_id; } } diff --git a/ccm-cms/sql/ccm-cms/default/content-section/comment-content_types.sql b/ccm-cms/sql/ccm-cms/default/content-section/comment-content_types.sql index 6d68ca160..f23e2dbd0 100755 --- a/ccm-cms/sql/ccm-cms/default/content-section/comment-content_types.sql +++ b/ccm-cms/sql/ccm-cms/default/content-section/comment-content_types.sql @@ -30,13 +30,28 @@ comment on column content_types.classname is ' comment on column content_types.label is ' The pretty name for this content type '; -comment on column content_types.is_internal is ' +--comment on column content_types.is_internal is ' +-- An internal content type is one that is not user-defined and maintained +-- internally. A content type should be made internal under the following +-- two conditions: +-- 1) The object type needs to take advantage of content type services +-- (i.e., versioning, categorization, lifecycle, workflow) that are already +-- implemented in CMS. +-- 2) The content type cannot be explicitly registered to a content section. +-- The Template content type is one such internal content type. +--'; + comment on column content_types.mode is ' + Saves the mode of the content type: I = internal, H = hidden + An internal content type is one that is not user-defined and maintained internally. A content type should be made internal under the following two conditions: - 1) The object type needs to take advantage of content type services - (i.e., versioning, categorization, lifecycle, workflow) that are already + 1) The object type needs to take advantage of content type services + (i.e., versioning, categorization, lifecycle, workflow) that are already implemented in CMS. 2) The content type cannot be explicitly registered to a content section. The Template content type is one such internal content type. + + A hidden content type is one that cannot used directly but other content + types can extend from it. Also, it is a legit parent for UDCTs. '; diff --git a/ccm-cms/sql/ccm-cms/default/content-section/table-content_types.sql b/ccm-cms/sql/ccm-cms/default/content-section/table-content_types.sql index 2bbc3edd4..46d1ec7e8 100755 --- a/ccm-cms/sql/ccm-cms/default/content-section/table-content_types.sql +++ b/ccm-cms/sql/ccm-cms/default/content-section/table-content_types.sql @@ -31,9 +31,12 @@ create table content_types ( classname varchar(200), ancestors varchar(2000), siblings varchar(2000), - is_internal char(1) default '0' not null - constraint content_types_is_internal_ck - check ( is_internal in ('0', '1') ), +-- is_internal char(1) default '0' not null +-- constraint content_types_is_internal_ck +-- check ( is_internal in ('0', '1') ), + mode char(1) default '' not null + constraint content_types_mode_ck + check ( mode in ('D', 'H', 'I') ), item_form_id integer constraint content_types_form_id_fk references bebop_components (component_id) diff --git a/ccm-cms/src/WEB-INF/content-types/GenericAddress.xml b/ccm-cms/src/WEB-INF/content-types/GenericAddress.xml index 805e40127..f90224633 100644 --- a/ccm-cms/src/WEB-INF/content-types/GenericAddress.xml +++ b/ccm-cms/src/WEB-INF/content-types/GenericAddress.xml @@ -9,7 +9,7 @@ description="A generic address type" objectType="com.arsdigita.cms.contenttypes.GenericAddress" classname="com.arsdigita.cms.contenttypes.GenericAddress" - isInternal="yes"> + mode="hidden"> diff --git a/ccm-cms/src/WEB-INF/content-types/GenericArticle.xml b/ccm-cms/src/WEB-INF/content-types/GenericArticle.xml index fc01210a0..49aca9b2b 100644 --- a/ccm-cms/src/WEB-INF/content-types/GenericArticle.xml +++ b/ccm-cms/src/WEB-INF/content-types/GenericArticle.xml @@ -4,12 +4,12 @@ xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://xmlns.redhat.com/cms/content-types content-types.xsd"> - + mode="hidden"> - + diff --git a/ccm-cms/src/WEB-INF/content-types/GenericContact.xml b/ccm-cms/src/WEB-INF/content-types/GenericContact.xml index 4d56ea725..9a7503622 100644 --- a/ccm-cms/src/WEB-INF/content-types/GenericContact.xml +++ b/ccm-cms/src/WEB-INF/content-types/GenericContact.xml @@ -9,7 +9,7 @@ description="A generic Contact type" objectType="com.arsdigita.cms.contenttypes.GenericContact" classname="com.arsdigita.cms.contenttypes.GenericContact" - isInternal="yes"> + mode="hidden"> diff --git a/ccm-cms/src/WEB-INF/content-types/GenericOrganizationalUnit.xml b/ccm-cms/src/WEB-INF/content-types/GenericOrganizationalUnit.xml index 603074293..224beca80 100644 --- a/ccm-cms/src/WEB-INF/content-types/GenericOrganizationalUnit.xml +++ b/ccm-cms/src/WEB-INF/content-types/GenericOrganizationalUnit.xml @@ -10,7 +10,7 @@ description="A generic content type for organizations and projects." objectType="com.arsdigita.cms.contenttypes.GenericOrganizationalUnit" classname= "com.arsdigita.cms.contenttypes.GenericOrganizationalUnit" - isInternal="yes"> + mode="hidden"> diff --git a/ccm-cms/src/WEB-INF/content-types/GenericPerson.xml b/ccm-cms/src/WEB-INF/content-types/GenericPerson.xml index 4e8b5e1dc..359d14a02 100644 --- a/ccm-cms/src/WEB-INF/content-types/GenericPerson.xml +++ b/ccm-cms/src/WEB-INF/content-types/GenericPerson.xml @@ -9,7 +9,7 @@ description="A generic Person type" objectType="com.arsdigita.cms.contenttypes.GenericPerson" classname="com.arsdigita.cms.contenttypes.GenericPerson" - isInternal="yes"> + mode="hidden"> diff --git a/ccm-cms/src/WEB-INF/content-types/Template.xml b/ccm-cms/src/WEB-INF/content-types/Template.xml index 9230945ae..a35dc5bbe 100755 --- a/ccm-cms/src/WEB-INF/content-types/Template.xml +++ b/ccm-cms/src/WEB-INF/content-types/Template.xml @@ -7,7 +7,7 @@ description="Templates for rendering content items" objectType="com.arsdigita.cms.Template" classname="com.arsdigita.cms.Template" - isInternal="yes"> + mode="internal"> A content section represents a collection of content that is * managed as a unit. Content sections typically correspond to major @@ -94,12 +92,10 @@ import java.math.BigDecimal; public class ContentSection extends Application { private static final Logger s_log = Logger.getLogger(ContentSection.class); - public static final String BASE_DATA_OBJECT_TYPE = - "com.arsdigita.cms.ContentSection"; + "com.arsdigita.cms.ContentSection"; public static final String PACKAGE_TYPE = "content-section"; public final static String STYLESHEET = "/packages/content-section/xsl/cms.xsl"; - protected static final String ID = "id"; protected static final String PACKAGE = "package"; protected static final String NAME = "label"; @@ -113,27 +109,21 @@ public class ContentSection extends Application { protected static final String ITEM_RESOLVER_CLASS = "itemResolverClass"; protected static final String TEMPLATE_RESOLVER_CLASS = "templateResolverClass"; protected static final String XML_GENERATOR_CLASS = "xmlGeneratorClass"; - protected static final String CONTENT_TYPES = "associatedContentTypes"; protected static final String CREATABLE_CONTENT_TYPES = - "creatableContentTypes"; + "creatableContentTypes"; protected static final String CONTENT_TYPES_NOT_ASSOC = - "notAssociatedContentTypes"; + "notAssociatedContentTypes"; protected static final String LIFECYCLE_DEFINITIONS = - "associatedLifecycleDefinitions"; + "associatedLifecycleDefinitions"; protected static final String WF_TEMPLATES = "associatedWorkflowTemplates"; - private final static String ITEM_QUERY = "com.arsdigita.cms.ItemsInSection"; private final static String SECTION_ID = "sectionId"; - private static final CMSConfig s_config = new CMSConfig(); static { s_config.load(); } - - - // Cached properties PageResolver m_pageResolver = null; ItemResolver m_itemResolver = null; @@ -144,7 +134,6 @@ public class ContentSection extends Application { // super(BASE_DATA_OBJECT_TYPE); // } // - /** * Constructor re-creating a content section object by retrieving its data * object by OID @@ -177,7 +166,6 @@ public class ContentSection extends Application { super(new OID(BASE_DATA_OBJECT_TYPE, id)); } - public static CMSConfig getConfig() { return s_config; } @@ -186,6 +174,7 @@ public class ContentSection extends Application { * @return the base PDL object type for this section. Child classes should * override this method to return the correct value */ + @Override public String getBaseDataObjectType() { return BASE_DATA_OBJECT_TYPE; } @@ -197,6 +186,7 @@ public class ContentSection extends Application { * @param key The name of the attribute * @return The value of the attribute */ + @Override public Object get(String key) { return super.get(key); } @@ -208,6 +198,7 @@ public class ContentSection extends Application { * @param key The name of the attribute * @param value The value of the attribute */ + @Override public void set(String key, Object value) { super.set(key, value); } @@ -215,6 +206,7 @@ public class ContentSection extends Application { /** * Sets the content section of the root folder to this section. */ + @Override protected void afterSave() { super.afterSave(); // Set the root folder's content section. @@ -238,6 +230,7 @@ public class ContentSection extends Application { * * @return A title */ + @Override public String getDisplayName() { return getName(); } @@ -290,7 +283,6 @@ public class ContentSection extends Application { // public SiteNode getSiteNode() { // return getPackageInstance().getDefaultMountPoint(); // } - /** * Finds the location of the content section. * @@ -337,7 +329,6 @@ public class ContentSection extends Application { // // return path.substring(0, path.length() - 1); // } - /** * Get the folder in which all draft items are contained, directly or * indirectly. This folder will in general contain different kinds of @@ -371,7 +362,7 @@ public class ContentSection extends Application { // sub-items/folders. The next step is to recursively update items // under the root folder when fetching "all items in a section" is // implemented. - if ( !isNew() ) { + if (!isNew()) { Folder oldRoot = getRootFolder(); oldRoot.setContentSection(null); oldRoot.save(); @@ -506,8 +497,8 @@ public class ContentSection extends Application { if (m_pageResolver == null) { if (s_log.isDebugEnabled()) { - s_log.debug("The page resolver hasn't been loaded yet; " + - "loading it now"); + s_log.debug("The page resolver hasn't been loaded yet; " + + "loading it now"); } try { @@ -677,13 +668,10 @@ public class ContentSection extends Application { m_xmlGenerator = null; } - - ////////////////////////////// // // Globalization. // - /** * Gets the default Locale. This is used for translating or creating * content if no locale is specified. @@ -692,7 +680,7 @@ public class ContentSection extends Application { */ public Locale getDefaultLocale() { DataObject obj = (DataObject) get(DEFAULT_LOCALE); - if ( obj == null ) { + if (obj == null) { return null; } else { return new Locale(obj); @@ -748,7 +736,7 @@ public class ContentSection extends Application { DataAssociation da = (DataAssociation) get(LOCALES); locale.addToAssociation(da); - if ( isDefault ) { + if (isDefault) { setDefaultLocale(locale); } } @@ -764,22 +752,27 @@ public class ContentSection extends Application { locale.removeFromAssociation(da); } - ////////////////////////////// // // Content types. // - /** * Get all user-defined content types registered to the content section. * * @return A ContentTypeCollection of registered content types */ public ContentTypeCollection getContentTypes() { + return getContentTypes(false); + } + + public ContentTypeCollection getContentTypes(boolean hidden) { DataAssociation da = (DataAssociation) get(CONTENT_TYPES); ContentTypeCollection types = new ContentTypeCollection(da); - // Filter out internal contentt types. - types.addFilter("isInternal = '0'"); + // Filter out internal content types. + types.addFilter("mode != 'I'"); + if (!hidden) { + types.addFilter("mode != 'H'"); + } return types; } @@ -793,10 +786,17 @@ public class ContentSection extends Application { * 3) possess a non-empty creation component in its AuthoringKit. */ public ContentTypeCollection getCreatableContentTypes() { + return getCreatableContentTypes(false); + } + + public ContentTypeCollection getCreatableContentTypes(boolean hidden) { DataAssociation da = (DataAssociation) get(CREATABLE_CONTENT_TYPES); ContentTypeCollection types = new ContentTypeCollection(da); // Filter out internal content types. - types.addFilter("isInternal = '0'"); + types.addFilter("mode != 'I'"); + if (!hidden) { + types.addFilter("mode != 'H'"); + } return types; } @@ -807,7 +807,7 @@ public class ContentSection extends Application { * @param type The content type */ public void addContentType(ContentType type) { - if ( ! hasContentType(type) ) { + if (!hasContentType(type)) { DataAssociation da = (DataAssociation) get(CONTENT_TYPES); type.addToAssociation(da); } @@ -835,7 +835,7 @@ public class ContentSection extends Application { DataAssociation da = (DataAssociation) get(CONTENT_TYPES); DataAssociationCursor cursor = da.cursor(); cursor.addEqualsFilter(ID, type.getID()); - return ( cursor.size() > 0 ); + return (cursor.size() > 0); } /** @@ -849,16 +849,14 @@ public class ContentSection extends Application { DataAssociation da = (DataAssociation) get(CONTENT_TYPES_NOT_ASSOC); ContentTypeCollection types = new ContentTypeCollection(da); // Filter out internal content types. - types.addFilter("isInternal = '0'"); + types.addFilter("mode != 'I'"); return types; } - ////////////////////////////// // // Lifecycle definitions. // - /** * Get all lifecycle definitions registered to the content section. * @@ -866,8 +864,7 @@ public class ContentSection extends Application { * lifecycle definition. */ public LifecycleDefinitionCollection getLifecycleDefinitions() { - return - new LifecycleDefinitionCollection(getLifecycleDefinitionsAssociation()); + return new LifecycleDefinitionCollection(getLifecycleDefinitionsAssociation()); } /** @@ -892,12 +889,10 @@ public class ContentSection extends Application { return (DataAssociation) get(LIFECYCLE_DEFINITIONS); } - ////////////////////////////// // // Workflow templates. // - /** * Get all workflow templates registered to the content section. * @@ -931,13 +926,10 @@ public class ContentSection extends Application { return (DataAssociation) get(WF_TEMPLATES); } - - ////////////////////////////// // // Finding a content section. // - /** * Looks up the section given the SiteNode. * @@ -947,9 +939,9 @@ public class ContentSection extends Application { * @post ( return != null ) */ public static ContentSection getSectionFromNode(SiteNode node) - throws DataObjectNotFoundException { + throws DataObjectNotFoundException { - return (ContentSection)retrieveApplicationForSiteNode(node); + return (ContentSection) retrieveApplicationForSiteNode(node); // BigDecimal sectionId = null; // @@ -991,7 +983,6 @@ public class ContentSection extends Application { // } // return section; // } - /** * Get the content section for an item. * @@ -1003,7 +994,7 @@ public class ContentSection extends Application { * @return The content section of an item */ public static ContentSection getContentSection(ContentItem item) - throws DataObjectNotFoundException { + throws DataObjectNotFoundException { return item.getContentSection(); } @@ -1018,7 +1009,7 @@ public class ContentSection extends Application { * @return The content section of the folder */ public static ContentSection getContentSection(Folder folder) - throws DataObjectNotFoundException { + throws DataObjectNotFoundException { return folder.getContentSection(); } @@ -1029,13 +1020,10 @@ public class ContentSection extends Application { * @return A collection of content sections */ public static ContentSectionCollection getAllSections() { - DataCollection da = SessionManager.getSession().retrieve - (BASE_DATA_OBJECT_TYPE); + DataCollection da = SessionManager.getSession().retrieve(BASE_DATA_OBJECT_TYPE); return new ContentSectionCollection(da); } - - /** * Creates a content section of the given name using default values and * returns it. @@ -1055,27 +1043,20 @@ public class ContentSection extends Application { String xgc = "com.arsdigita.cms.dispatcher.SimpleXMLGenerator"; String trc = "com.arsdigita.cms.dispatcher.DefaultTemplateResolver"; - ContentSection section = ContentSection.create( name, - folder, - category, - staff, - prc, - irc, - xgc, - trc); + ContentSection section = ContentSection.create(name, + folder, + category, + staff, + prc, + irc, + xgc, + trc); // Set the default context on the root folder to // the content section PermissionService.setContext(folder.getOID(), section.getOID()); createDefaultResources(section); -// Left over, see above -// } -// }; -// rootExcursion.run(); -// -// //now retrieve the created content section and return it -// return (ContentSection) Application.retrieveApplicationForPath("/" + name + "/"); return section; } @@ -1093,22 +1074,21 @@ public class ContentSection extends Application { * @return The new content section */ public static ContentSection create(String name, - Folder folder, - Category category, - Group staff, - String prc, - String irc, - String xgc) { + Folder folder, + Category category, + Group staff, + String prc, + String irc, + String xgc) { return ContentSection.create( - name, - folder, - category, - staff, - prc, - irc, - xgc, - "com.arsdigita.cms.dispatcher.DefaultTemplateResolver" - ); + name, + folder, + category, + staff, + prc, + irc, + xgc, + "com.arsdigita.cms.dispatcher.DefaultTemplateResolver"); } /** @@ -1126,13 +1106,13 @@ public class ContentSection extends Application { * @return The new content section */ public static ContentSection create(String name, - Folder folder, - Category category, - Group staff, - String prc, - String irc, - String xgc, - String trc) { + Folder folder, + Category category, + Group staff, + String prc, + String irc, + String xgc, + String trc) { // This could be moved out of here and into the Installer // (passing it into a modified version of create) @@ -1143,28 +1123,26 @@ public class ContentSection extends Application { // Create template root folder. Folder templates = new Folder(); templates.setName("templates"); - templates.setLabel( (String) GlobalizationUtil.globalize( - "cms.templates").localize()); + templates.setLabel((String) GlobalizationUtil.globalize( + "cms.templates").localize()); templates.save(); //create and initialize the content section application - ContentSection section = (ContentSection) Application.createApplication - (BASE_DATA_OBJECT_TYPE, name, name, null ); - section.initialize( name, - folder, - category, - staff, - prc, - irc, - xgc, - trc, - templates, - viewers); + ContentSection section = (ContentSection) Application.createApplication(BASE_DATA_OBJECT_TYPE, name, name, null); + section.initialize(name, + folder, + category, + staff, + prc, + irc, + xgc, + trc, + templates, + viewers); return section; } - /** * Creates and maps default resources to the content section. * @@ -1185,7 +1163,7 @@ public class ContentSection extends Application { rm = r.createInstance(section, "admin/index"); rm.save(); - // XXX What's up with this? The class doesn't exist anymore. + // XXX What's up with this? The class doesn't exist anymore. //r = rt.createInstance("com.arsdigita.cms.user.ItemIndexPage"); //r.save(); //rm = r.createInstance(section, "index"); @@ -1207,8 +1185,8 @@ public class ContentSection extends Application { protected static Folder createRootFolder(String name) { Folder root = new Folder(); root.setName("/"); - root.setLabel( (String) GlobalizationUtil.globalize( - "cms.installer.root_folder").localize()); + root.setLabel((String) GlobalizationUtil.globalize( + "cms.installer.root_folder").localize()); root.save(); return root; } @@ -1239,7 +1217,6 @@ public class ContentSection extends Application { return staff; } - /** * Initialize a newly created content section. * @@ -1254,16 +1231,16 @@ public class ContentSection extends Application { * @return The new content section */ public ContentSection initialize( - String name, - Folder folder, - Category category, - Group staff, - String prc, - String irc, - String xgc, - String trc, - Folder templates, - Group viewers) { + String name, + Folder folder, + Category category, + Group staff, + String prc, + String irc, + String xgc, + String trc, + Folder templates, + Group viewers) { setName(name); //setPackageInstance(pkg); @@ -1281,7 +1258,6 @@ public class ContentSection extends Application { return this; } - /** * Fetches the child items of this section. An item is defined to be "in" * a content section if it can be found directly in the folder hierarchy @@ -1304,5 +1280,4 @@ public class ContentSection extends Application { public String getStylesheetPath() { return STYLESHEET; } - } diff --git a/ccm-cms/src/com/arsdigita/cms/ContentType.java b/ccm-cms/src/com/arsdigita/cms/ContentType.java index f0919b87c..6cdc103eb 100755 --- a/ccm-cms/src/com/arsdigita/cms/ContentType.java +++ b/ccm-cms/src/com/arsdigita/cms/ContentType.java @@ -65,7 +65,7 @@ public class ContentType extends ACSObject { public static final String LABEL = "label"; public static final String DESCRIPTION = "description"; public static final String CLASSNAME = "className"; - public static final String IS_INTERNAL = "isInternal"; + public static final String MODE = "mode"; public static final String AUTHORING_KIT = "authoringKit"; public static final String ITEM_FORM_ID = "itemFormID"; public static final String ITEM_FORM = "itemForm"; @@ -123,8 +123,8 @@ public class ContentType extends ACSObject { @Override protected void beforeSave() { - if (isInternal() == null) { - setInternal(false); + if (getMode() == null) { + setMode("default"); } super.beforeSave(); } @@ -224,17 +224,37 @@ public class ContentType extends ACSObject { * otherwise. */ public Boolean isInternal() { - return (Boolean) get(IS_INTERNAL); + return "I".equalsIgnoreCase((String) get(MODE)); } /** - * Make this content type internal or not. + *

A hidden content type is one that is not user-defined but not meant + * to be used directly (p. ex. GenericArticle). in contrast they provide + * some basic features for different kind of content type to be extended + * from. Also, they are legit perents for UDCTs. * - * @param isInternal true if this content type should be internal, - * false otherwise + * @return Boolean.TRUE if this content type is internal, Boolean.FALSE + * otherwise. */ - public void setInternal(boolean isInternal) { - set(IS_INTERNAL, (isInternal ? Boolean.TRUE : Boolean.FALSE)); + public Boolean isHidden() { + return "H".equalsIgnoreCase((String) get(MODE)); + } + + /** + * Save the display / user mode of this content type + * + * @param mode string. ATM: "interal" or "hidden" or "" + */ + public void setMode(String mode) { + if (mode != null && !mode.isEmpty()) { + set(MODE, mode.toUpperCase().substring(0, 1)); + } else { + set(MODE, "default".toUpperCase().substring(0, 1)); + } + } + + public String getMode() { + return (String) get(MODE); } /** @@ -481,7 +501,19 @@ public class ContentType extends ACSObject { * @return A collection of all content types */ public static ContentTypeCollection getAllContentTypes() { - return getAllContentTypes(true); + return getAllContentTypes(true, true); + } + + /** + * Fetches a collection of all content types, including internal content + * types. + * + * @param hidden If false, fetch all content types, ecluding hidden + * content types + * @return A collection of all content types + */ + public static ContentTypeCollection getAllContentTypes(boolean hidden) { + return getAllContentTypes(true, hidden); } /** @@ -490,19 +522,25 @@ public class ContentType extends ACSObject { * @return A collection of user-defined content types */ public static ContentTypeCollection getUserDefinedContentTypes() { - return getAllContentTypes(false); + return getAllContentTypes(false, true); } /** - * @param internal If true, fetch all content types, including internal + * @param internal If false, fetch all content types, excluding internal + * content types. + * @param hidden If false, fetch all content types, excluding hidden * content types. */ - private static ContentTypeCollection getAllContentTypes(boolean internal) { + private static ContentTypeCollection getAllContentTypes(boolean internal, boolean hidden) { DataCollection da = SessionManager.getSession().retrieve(BASE_DATA_OBJECT_TYPE); ContentTypeCollection types = new ContentTypeCollection(da); if (!internal) { - types.addFilter("isInternal = '0'"); + types.addFilter("mode != 'I'"); + } + + if (!hidden) { + types.addFilter("mode != 'H'"); } return types; } @@ -545,8 +583,7 @@ public class ContentType extends ACSObject { ctc.addFilter(or); return ctc; } - - private static List s_xsl = new ArrayList(); + private static List s_xsl = new ArrayList(); /** * NB this interface is liable to change. diff --git a/ccm-cms/src/com/arsdigita/cms/Loader.java b/ccm-cms/src/com/arsdigita/cms/Loader.java index 9e3314584..2c360d19b 100755 --- a/ccm-cms/src/com/arsdigita/cms/Loader.java +++ b/ccm-cms/src/com/arsdigita/cms/Loader.java @@ -61,6 +61,7 @@ import com.arsdigita.xml.XML; // import java.io.IOException; // import java.io.InputStream; // import java.util.HashMap; +import java.util.ArrayList; import java.util.Iterator; import java.util.List; // import javax.xml.parsers.ParserConfigurationException; @@ -72,7 +73,6 @@ import java.util.List; import org.apache.log4j.Logger; - // Migration status // // The module in its complete version (i.e. all method invocations in run() @@ -83,8 +83,6 @@ import org.apache.log4j.Logger; // // Next Try // Refactor using legacy compatible web/Application and ApplicationSetup - - /** *

Executes nonrecurring at install time and loads (installs and initializes) * the Content Management System module,including the Content Center, CMS Service @@ -115,14 +113,11 @@ public class Loader extends PackageLoader { /** Creates a s_logging category with name = full name of class */ private static final Logger s_log = Logger.getLogger(Loader.class); - // Load main CMS configuration file private static final LoaderConfig s_conf = new LoaderConfig(); - // static { // requirred to actually read the config file // s_config.load(); // } - /** * Constant string used as key for creating CMS (content-section) as a * legacy application. @@ -139,7 +134,6 @@ public class Loader extends PackageLoader { */ private final static String CMS_STYLESHEET = "/packages/content-section/xsl/cms.xsl"; - // /** // * Constant string used as key for creating Workspace (content-center) as a // * legacy application. @@ -151,7 +145,7 @@ public class Loader extends PackageLoader { * to a legacy application). */ private static final String WORKSPACE_DISPATCHER_CLASS = - "com.arsdigita.cms.dispatcher.ContentCenterDispatcher"; + "com.arsdigita.cms.dispatcher.ContentCenterDispatcher"; // To be updated soon... // "com.arsdigita.dispatcher.DefaultPackageDispatcher"; /** @@ -160,7 +154,6 @@ public class Loader extends PackageLoader { */ private final static String WORKSPACE_STYLESHEET = "/packages/content-section/xsl/content-center.xsl"; - /** * Name of the CMS service package instance, i.e. its URL. */ @@ -170,9 +163,7 @@ public class Loader extends PackageLoader { // * legacy application. // */ // public final static String SERVICE_PACKAGE_KEY = "cms-service"; - - - + private ArrayList m_content_type_list = new ArrayList(); /** * Standard constructor. @@ -183,11 +174,11 @@ public class Loader extends PackageLoader { s_log.debug("CMS.loader (Constructor) completed"); } - public void run(final ScriptContext ctx) { s_log.debug("CMS.loader.run() invoked"); new KernelExcursion() { + public void excurse() { setEffectiveParty(Kernel.getSystemParty()); @@ -214,7 +205,7 @@ public class Loader extends PackageLoader { // 5) load content type definition(s) // Used to be step 2 in former enterprise.init file - loadContentTypeDefinitions(s_conf.getCTDefFiles() ); + loadContentTypeDefinitions(s_conf.getCTDefFiles()); // 6) Load CMS (content section) package application instance // Used to be step 4 in former enterprise.init file @@ -232,7 +223,7 @@ public class Loader extends PackageLoader { //ContentSectionsPortlet.loadPortletType(); TaskPortlet.loadPortletType(); - + } }.run(); } @@ -291,8 +282,6 @@ public class Loader extends PackageLoader { // // s_log.debug("Done creating the CMS package type."); // } - - /** * Loads and instantiates the Workspace package (content-center) in the * database using old style application. @@ -305,14 +294,14 @@ public class Loader extends PackageLoader { try { // workspaceInstaller.createPackageType(); PackageType type = PackageType.create(CMS.WORKSPACE_PACKAGE_KEY, - "Content Center", - "Content Centers", - "http://cms-workspace.arsdigita.com/"); + "Content Center", + "Content Centers", + "http://cms-workspace.arsdigita.com/"); type.setDispatcherClass(WORKSPACE_DISPATCHER_CLASS); // Register a stylesheet to the Content Center package. Stylesheet ss = - Stylesheet.createStylesheet(WORKSPACE_STYLESHEET); + Stylesheet.createStylesheet(WORKSPACE_STYLESHEET); ss.save(); type.addStylesheet(ss); @@ -330,22 +319,21 @@ public class Loader extends PackageLoader { // SiteNode node = SiteNode.createSiteNode(CMS.WORKSPACE_PACKAGE_KEY, // SiteNode.getRootSiteNode()); SiteNode node = SiteNode.createSiteNode(CMS.WORKSPACE_PACKAGE_KEY, - SiteNode.getRootSiteNode()); + SiteNode.getRootSiteNode()); node.mountPackage(instance); node.save(); - // m_workspaceURL == WORKSPACE_PACKAGE_KEY - // workspaceInstaller.mountPackageInstance(instance, m_workspaceURL); - // workspaceInstaller.mountPackageInstance(instance, CMS.WORKSPACE_PACKAGE_KEY); + // m_workspaceURL == WORKSPACE_PACKAGE_KEY + // workspaceInstaller.mountPackageInstance(instance, m_workspaceURL); + // workspaceInstaller.mountPackageInstance(instance, CMS.WORKSPACE_PACKAGE_KEY); - } catch (DataObjectNotFoundException e) { - throw new ConfigError( - "Failed to initialize the Workspace package: "); - } + } catch (DataObjectNotFoundException e) { + throw new ConfigError( + "Failed to initialize the Workspace package: "); + } } - /** * Loads and instantiates the Workspace package (content-center) in the * database. @@ -360,22 +348,24 @@ public class Loader extends PackageLoader { // create application type ApplicationSetup appsetup = new ApplicationSetup(s_log); // new style properties - appsetup.setApplicationObjectType( Workspace.BASE_DATA_OBJECT_TYPE ); - appsetup.setTitle( Workspace.INSTANCE_NAME ); // same as for instance - // there is only one + appsetup.setApplicationObjectType(Workspace.BASE_DATA_OBJECT_TYPE); + appsetup.setTitle(Workspace.INSTANCE_NAME); // same as for instance + // there is only one appsetup.setDescription("The content center workspace for content creators."); // old style / legacy compatible properties - appsetup.setKey( Workspace.PACKAGE_KEY ); - appsetup.setDispatcherClass( Workspace.DISPATCHER_CLASS ); + appsetup.setKey(Workspace.PACKAGE_KEY); + appsetup.setDispatcherClass(Workspace.DISPATCHER_CLASS); // should not be needed anymore, stypesheets handled by StylesheetResolver - appsetup.setStylesheet( Workspace.STYLESHEET ); + appsetup.setStylesheet(Workspace.STYLESHEET); appsetup.setSingleton(true); appsetup.setPortalApplication(false); appsetup.setInstantiator(new ACSObjectInstantiator() { - protected DomainObject doNewInstance(DataObject dataObject) { - return new Workspace(dataObject); - } - }); + + @Override + protected DomainObject doNewInstance(DataObject dataObject) { + return new Workspace(dataObject); + } + }); ApplicationType workspaceType = appsetup.run(); workspaceType.save(); @@ -383,16 +373,15 @@ public class Loader extends PackageLoader { // create legacy compatible application instance, // old-style package key used as url fragment where to install the instance Workspace app = (Workspace) Application.createApplication( - workspaceType, // type - Workspace.PACKAGE_KEY, // url fragment - Workspace.INSTANCE_NAME,// title - null); // parent + workspaceType, // type + Workspace.PACKAGE_KEY, // url fragment + Workspace.INSTANCE_NAME,// title + null); // parent app.save(); s_log.debug("Done loading CMS Workspace."); } - /** * CMS Service application is used by the Content Management System as a * store for global resources and assets. @@ -402,35 +391,32 @@ public class Loader extends PackageLoader { private void loadServicePackage() { s_log.debug("Loading CMS Servce Package..."); - try { - // from ServiceInstaller.createPackageType(); - PackageType type = PackageType.create - (CMS.SERVICE_PACKAGE_KEY, - "Content Management System Services", - "Content Management System Services", - "http://cms-service.arsdigita.com/"); - type.setDispatcherClass( - "com.arsdigita.cms.dispatcher.ServiceDispatcher"); - type.save(); + try { + // from ServiceInstaller.createPackageType(); + PackageType type = PackageType.create(CMS.SERVICE_PACKAGE_KEY, + "Content Management System Services", + "Content Management System Services", + "http://cms-service.arsdigita.com/"); + type.setDispatcherClass( + "com.arsdigita.cms.dispatcher.ServiceDispatcher"); + type.save(); - // from PackageInstance instance = ServiceInstaller.createPackageInstance(); - type = PackageType.findByKey(CMS.SERVICE_PACKAGE_KEY); - PackageInstance instance = type.createInstance(CMS.SERVICE_PACKAGE_KEY); - instance.save(); + // from PackageInstance instance = ServiceInstaller.createPackageInstance(); + type = PackageType.findByKey(CMS.SERVICE_PACKAGE_KEY); + PackageInstance instance = type.createInstance(CMS.SERVICE_PACKAGE_KEY); + instance.save(); - // from ServiceInstaller.mountPackageInstance(instance, url); - SiteNode node = SiteNode.createSiteNode(SERVICE_URL, - SiteNode.getRootSiteNode()); - node.mountPackage(instance); - node.save(); + // from ServiceInstaller.mountPackageInstance(instance, url); + SiteNode node = SiteNode.createSiteNode(SERVICE_URL, + SiteNode.getRootSiteNode()); + node.mountPackage(instance); + node.save(); - } catch (DataObjectNotFoundException e) { - throw new ConfigError - ("Failed to initialize CMS global services package."); - } + } catch (DataObjectNotFoundException e) { + throw new ConfigError("Failed to initialize CMS global services package."); + } } - /** * CMS Service application is used by the Content Management System as a * store for global resources and assets. @@ -447,22 +433,24 @@ public class Loader extends PackageLoader { // create application type ApplicationSetup appsetup = new ApplicationSetup(s_log); // new style properties - appsetup.setApplicationObjectType( Service.BASE_DATA_OBJECT_TYPE ); - appsetup.setTitle( Service.INSTANCE_NAME ); // same as for instance - // there is only one + appsetup.setApplicationObjectType(Service.BASE_DATA_OBJECT_TYPE); + appsetup.setTitle(Service.INSTANCE_NAME); // same as for instance + // there is only one appsetup.setDescription("Services to store global resources and assets."); // old style / legacy compatible properties - appsetup.setKey( Service.PACKAGE_KEY ); - appsetup.setDispatcherClass( Service.DISPATCHER_CLASS ); + appsetup.setKey(Service.PACKAGE_KEY); + appsetup.setDispatcherClass(Service.DISPATCHER_CLASS); // Service has no UI, therefore no stylesheet available // appsetup.setStylesheet( Workspace.STYLESHEET ); appsetup.setSingleton(true); appsetup.setPortalApplication(false); appsetup.setInstantiator(new ACSObjectInstantiator() { - protected DomainObject doNewInstance(DataObject dataObject) { - return new Service(dataObject); - } - }); + + @Override + protected DomainObject doNewInstance(DataObject dataObject) { + return new Service(dataObject); + } + }); ApplicationType serviceType = appsetup.run(); serviceType.save(); @@ -470,16 +458,15 @@ public class Loader extends PackageLoader { // create legacy compatible application instance, // old-style package key used as url fragment where to install the instance Service app = (Service) Application.createApplication( - serviceType, // type - Service.PACKAGE_KEY, // url fragment - Service.INSTANCE_NAME,// title - null); // parent + serviceType, // type + Service.PACKAGE_KEY, // url fragment + Service.INSTANCE_NAME,// title + null); // parent app.save(); s_log.debug("Done creating CMS Service Package."); } - /** * Load an content section application type and an initial default * content-section instance as specified in LoaderConfig. @@ -505,8 +492,9 @@ public class Loader extends PackageLoader { appType.setPortalApplication(false); //setup.setDispatcherClass(ContentItemDispatcher.class.getName()); appType.setStylesheet(CMS_STYLESHEET); // by default: /pack./c-s/xml/cms.xml - // contains the xsl to generate the page + // contains the xsl to generate the page appType.setInstantiator(new ACSObjectInstantiator() { + @Override public DomainObject doNewInstance(DataObject dataObject) { return new ContentSection(dataObject); @@ -547,16 +535,17 @@ public class Loader extends PackageLoader { // registers predefined "Authoring", "Approval", "Publishing' steps setup.registerWorkflowTemplates(); setup.registerResolvers(s_conf.getItemResolverClass(), - s_conf.getTemplateResolverClass() ); + s_conf.getTemplateResolverClass()); // XML generator class, set autonomously by ContentSection.create() + setup.registerContentTypes(m_content_type_list); 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. if (s_conf.getUseSectionCategories()) { Iterator files = ((List) s_conf.getCategoryFileList()).iterator(); - while ( files.hasNext() ) { + while (files.hasNext()) { setup.registerCategories((String) files.next()); } } @@ -569,7 +558,7 @@ public class Loader extends PackageLoader { // setup.loadTaskAlerts(s_conf.getTaskAlerts()); section.save(); //persists any changes in the database (DomainObject) - //i.e. creates an object (instance) + //i.e. creates an object (instance) } @@ -605,19 +594,29 @@ public class Loader extends PackageLoader { private void loadContentTypeDefinitions(List ctDefFiles) { s_log.debug("Loading content type definitions ..."); - if ( ctDefFiles != null) { + if (ctDefFiles != null) { + XMLContentTypeHandler handler = new XMLContentTypeHandler(); Iterator i = ctDefFiles.iterator(); while (i.hasNext()) { - String xmlFile = (String)i.next(); + String xmlFile = (String) i.next(); s_log.debug("Processing contentTypes in: " + xmlFile); - XML.parseResource(xmlFile, new XMLContentTypeHandler()); + XML.parseResource(xmlFile, handler); } + + Iterator iter = handler.getContentTypes().iterator(); + + while (iter.hasNext()) { + ContentType ct = (ContentType) iter.next(); + if (!ct.isInternal()) { + m_content_type_list.add(ct.getClassName()); + } + } + } s_log.debug("Done loading content type definitions."); } - /** * Integrates the CMS privileges into the Core permision system. * @@ -633,10 +632,10 @@ public class Loader extends PackageLoader { DataQuery dq = SessionManager.getSession().retrieveQuery(CMS_PRIVILEGES); try { - while ( dq.next() ) { + while (dq.next()) { String privilege = (String) dq.get(PRIVILEGE); s_log.debug(String.format("privilege = %s", privilege)); - if ( PrivilegeDescriptor.get(privilege) == null ) { + if (PrivilegeDescriptor.get(privilege) == null) { PrivilegeDescriptor.createPrivilege(privilege); } } @@ -646,6 +645,4 @@ public class Loader extends PackageLoader { } s_log.debug("Done creating Privileges."); } - - } diff --git a/ccm-cms/src/com/arsdigita/cms/contentsection/ContentSectionSetup.java b/ccm-cms/src/com/arsdigita/cms/contentsection/ContentSectionSetup.java index 6cac9ede9..a70241662 100644 --- a/ccm-cms/src/com/arsdigita/cms/contentsection/ContentSectionSetup.java +++ b/ccm-cms/src/com/arsdigita/cms/contentsection/ContentSectionSetup.java @@ -33,20 +33,14 @@ import com.arsdigita.cms.util.GlobalizationUtil; import com.arsdigita.cms.workflow.CMSTask; import com.arsdigita.cms.workflow.CMSTaskType; import com.arsdigita.domain.DataObjectNotFoundException; -// import com.arsdigita.domain.DomainObject; import com.arsdigita.initializer.InitializationException; -// import com.arsdigita.kernel.ACSObjectInstantiator; import com.arsdigita.kernel.Party; import com.arsdigita.kernel.PartyCollection; import com.arsdigita.kernel.Role; import com.arsdigita.kernel.permissions.PermissionService; import com.arsdigita.kernel.permissions.PrivilegeDescriptor; -// import com.arsdigita.persistence.DataObject; -// import com.arsdigita.runtime.AbstractConfig; -import com.arsdigita.cms.LoaderConfig; import com.arsdigita.util.Assert; import com.arsdigita.util.UncheckedWrapperException; -// import com.arsdigita.web.ApplicationSetup; import com.arsdigita.workflow.simple.WorkflowTemplate; import com.arsdigita.xml.XML; @@ -59,7 +53,6 @@ import java.util.EmptyStackException; import java.util.HashMap; import java.util.Iterator; import java.util.List; -// import java.util.NoSuchElementException; import java.util.Stack; import org.apache.log4j.Logger; @@ -78,13 +71,11 @@ import org.xml.sax.helpers.DefaultHandler; public final class ContentSectionSetup { private static Logger s_log = Logger.getLogger(ContentSectionSetup.class); - private final static String STYLESHEET = "/packages/content-section/xsl/cms.xsl"; private HashMap m_tasks = new HashMap(); private LifecycleDefinition m_lcd; private WorkflowTemplate m_wf; final ContentSection m_section; - /** * Constructor. Using this constructor the content section has to be @@ -98,21 +89,19 @@ public final class ContentSectionSetup { m_section = section; } - /** * Wrapper class to create and configure a content section instance * in one step. * */ public static void setupContentSectionAppInstance(String name, - List staffGroup, - Boolean isPubliclyViewable, - String itemResolverClassName, - String templateResolverClassName, - List sectionContentTypes, - Boolean useSectionCategories, - List categoryFileList - ) { + List staffGroup, + Boolean isPubliclyViewable, + String itemResolverClassName, + String templateResolverClassName, + List sectionContentTypes, + Boolean useSectionCategories, + List categoryFileList) { s_log.info("Creating content section on /" + name); ContentSection section = ContentSection.create(name); @@ -123,7 +112,7 @@ public final class ContentSectionSetup { setup.registerViewers(isPubliclyViewable); setup.registerPublicationCycles(); setup.registerWorkflowTemplates(); - setup.registerResolvers( itemResolverClassName,templateResolverClassName ); + setup.registerResolvers(itemResolverClassName, templateResolverClassName); // setup.registerContentTypes((List)m_conf.getParameter(TYPES)); setup.registerContentTypes(sectionContentTypes); @@ -131,7 +120,7 @@ public final class ContentSectionSetup { // section specific categories, usually not used. if (useSectionCategories) { Iterator files = categoryFileList.iterator(); - while ( files.hasNext() ) { + while (files.hasNext()) { setup.registerCategories((String) files.next()); } } @@ -143,8 +132,6 @@ public final class ContentSectionSetup { } - - /** * Steps through a list of roles which are part of a staff group and * delegates processing of each role. @@ -155,12 +142,12 @@ public final class ContentSectionSetup { Iterator i = roles.iterator(); while (i.hasNext()) { - List role = (List)i.next(); + List role = (List) i.next(); - String name = (String)role.get(0); - String desc = (String)role.get(1); - List privileges = (List)role.get(2); - String task = (role.size() > 3 ? (String)role.get(3) : null); + String name = (String) role.get(0); + String desc = (String) role.get(1); + List privileges = (List) role.get(2); + String task = (role.size() > 3 ? (String) role.get(3) : null); s_log.info("Creating role " + name); @@ -170,8 +157,9 @@ public final class ContentSectionSetup { desc, privileges); - if (task != null) + if (task != null) { m_tasks.put(task, group); + } } } @@ -192,22 +180,22 @@ public final class ContentSectionSetup { Iterator i = privileges.iterator(); while (i.hasNext()) { - String priv = (String)i.next(); + String priv = (String) i.next(); s_log.info("Granting privilege cms_" + priv); role.grantPermission(m_section, - PrivilegeDescriptor.get("cms_" + priv)); + PrivilegeDescriptor.get("cms_" + priv)); - if (priv.equals(SecurityManager.CATEGORY_ADMIN) || - priv.equals(SecurityManager.CATEGORIZE_ITEMS)) { + if (priv.equals(SecurityManager.CATEGORY_ADMIN) + || priv.equals(SecurityManager.CATEGORIZE_ITEMS)) { RootCategoryCollection coll = Category.getRootCategories(m_section); while (coll.next()) { if (priv.equals(SecurityManager.CATEGORY_ADMIN)) { role.grantPermission(coll.getCategory(), - PrivilegeDescriptor.ADMIN); + PrivilegeDescriptor.ADMIN); } else { role.grantPermission(coll.getCategory(), - Category.MAP_DESCRIPTOR); + Category.MAP_DESCRIPTOR); } } } @@ -232,16 +220,16 @@ public final class ContentSectionSetup { // XXX Shouldn't read permission granted depending on pub=true? viewers.grantPermission(m_section, - PrivilegeDescriptor.get("cms_read_item")); + PrivilegeDescriptor.get("cms_read_item")); String email = Boolean.TRUE.equals(pub) ? "public@nullhost" - : "registered@nullhost"; + : "registered@nullhost"; Party viewer = retrieveParty(email); - if (viewer == null) - throw new InitializationException( - (String) GlobalizationUtil.globalize( - "cms.installer.cannot_find_group_for_email").localize() + email); + if (viewer == null) { + throw new InitializationException((String) GlobalizationUtil.globalize( + "cms.installer.cannot_find_group_for_email").localize() + email); + } s_log.info("Adding " + email + " to viewers role"); viewers.getGroup().addMemberOrSubgroup(viewer); @@ -275,29 +263,25 @@ public final class ContentSectionSetup { * @param templateResolverClassName */ public void registerResolvers(String itemResolverClassName, - String templateResolverClassName) { + String templateResolverClassName) { - if (itemResolverClassName != null && itemResolverClassName.length()>0) { + if (itemResolverClassName != null && itemResolverClassName.length() > 0) { m_section.setItemResolverClass(itemResolverClassName); s_log.info("Registering " + itemResolverClassName - + " as the item resolver class"); + + " as the item resolver class"); } else { - m_section.setItemResolverClass(ContentSection.getConfig() - .getDefaultItemResolverClass() - .getName()); + m_section.setItemResolverClass(ContentSection.getConfig().getDefaultItemResolverClass().getName()); s_log.info("Registering " + itemResolverClassName - + " as the item resolver class"); + + " as the item resolver class"); } - if (templateResolverClassName != null && templateResolverClassName.length()>0) { + if (templateResolverClassName != null && templateResolverClassName.length() > 0) { m_section.setTemplateResolverClass(templateResolverClassName); - s_log.info("Registering " + templateResolverClassName + - " as the template resolver class"); + s_log.info("Registering " + templateResolverClassName + + " as the template resolver class"); } else { - m_section.setTemplateResolverClass(ContentSection.getConfig() - .getDefaultTemplateResolverClass() - .getName()); - s_log.info("Registering " + templateResolverClassName + - " as the template resolver class"); + m_section.setTemplateResolverClass(ContentSection.getConfig().getDefaultTemplateResolverClass().getName()); + s_log.info("Registering " + templateResolverClassName + + " as the template resolver class"); } m_section.save(); @@ -314,8 +298,8 @@ public final class ContentSectionSetup { // The feature lifecycle. LifecycleDefinition lcd = new LifecycleDefinition(); - lcd.setLabel( (String) GlobalizationUtil.globalize( - "cms.installer.simple_publication").localize()); + lcd.setLabel((String) GlobalizationUtil.globalize( + "cms.installer.simple_publication").localize()); lcd.setDescription("A one-phase lifecycle for items."); lcd.save(); @@ -339,40 +323,42 @@ public final class ContentSectionSetup { * @throws InitializationException */ public void registerWorkflowTemplates() - throws InitializationException { + throws InitializationException { // The 3-step production workflow. WorkflowTemplate wf = new WorkflowTemplate(); - wf.setLabel( (String) GlobalizationUtil.globalize( - "cms.installer.production_workflow").localize()); + wf.setLabel((String) GlobalizationUtil.globalize( + "cms.installer.production_workflow").localize()); wf.setDescription("A process that involves creating and approving content."); wf.save(); CMSTask authoring = new CMSTask(); authoring.setLabel((String) GlobalizationUtil.globalize( - "cms.installer.authoring").localize()); + "cms.installer.authoring").localize()); authoring.setDescription("Create content."); authoring.save(); - Role author = (Role)m_tasks.get("Authoring"); - if (author != null) + Role author = (Role) m_tasks.get("Authoring"); + if (author != null) { authoring.assignGroup(author.getGroup()); + } authoring.setTaskType(CMSTaskType.retrieve(CMSTaskType.AUTHOR)); authoring.save(); CMSTask approval = new CMSTask(); - approval.setLabel( (String) GlobalizationUtil.globalize( - "cms.installer.approval").localize()); + approval.setLabel((String) GlobalizationUtil.globalize( + "cms.installer.approval").localize()); approval.setDescription("Approve content."); approval.save(); approval.addDependency(authoring); approval.save(); - Role approver = (Role)m_tasks.get("Approval"); - if (approver != null) + Role approver = (Role) m_tasks.get("Approval"); + if (approver != null) { approval.assignGroup(approver.getGroup()); + } approval.setTaskType(CMSTaskType.retrieve(CMSTaskType.EDIT)); approval.save(); @@ -380,15 +366,16 @@ public final class ContentSectionSetup { CMSTask deploy = new CMSTask(); deploy.setLabel((String) GlobalizationUtil.globalize( - "cms.installer.deploy").localize()); + "cms.installer.deploy").localize()); deploy.setDescription("Deploy content."); deploy.save(); deploy.addDependency(approval); deploy.save(); - Role publisher = (Role)m_tasks.get("Publishing"); - if (publisher != null) + Role publisher = (Role) m_tasks.get("Publishing"); + if (publisher != null) { deploy.assignGroup(publisher.getGroup()); + } deploy.setTaskType(CMSTaskType.retrieve(CMSTaskType.DEPLOY)); deploy.save(); @@ -417,11 +404,11 @@ public final class ContentSectionSetup { while (i.hasNext()) { Object obj = i.next(); if (obj instanceof String) { - registerContentType((String)obj); + registerContentType((String) obj); } else { - List list = (List)obj; - String name = (String)list.get(0); - String file = (String)list.get(1); + List list = (List) obj; + String name = (String) list.get(0); + String file = (String) list.get(1); ContentType type = registerContentType(name); registerTemplate(type, file); @@ -440,22 +427,21 @@ public final class ContentSectionSetup { try { type = ContentType.findByAssociatedObjectType(name); } catch (DataObjectNotFoundException ex) { - throw new UncheckedWrapperException( - (String) GlobalizationUtil.globalize( - "cms.installer.cannot_find_content_type").localize() + name, ex); + throw new UncheckedWrapperException( + (String) GlobalizationUtil.globalize( + "cms.installer.cannot_find_content_type").localize() + name, ex); } s_log.info("Adding type " + name + " to " + m_section.getDisplayName()); m_section.addContentType(type); - s_log.info("Setting the default lifecycle for " + - name + " to " + m_lcd.getLabel()); - ContentTypeLifecycleDefinition. - updateLifecycleDefinition(m_section, type, m_lcd); + s_log.info("Setting the default lifecycle for " + + name + " to " + m_lcd.getLabel()); + ContentTypeLifecycleDefinition.updateLifecycleDefinition(m_section, type, m_lcd); m_lcd.save(); - s_log.info("Setting the default workflow template for " + name + - " to " + m_wf.getLabel()); + s_log.info("Setting the default workflow template for " + name + + " to " + m_wf.getLabel()); ContentTypeWorkflowTemplate.updateWorkflowTemplate(m_section, type, m_wf); m_wf.save(); @@ -468,14 +454,15 @@ public final class ContentSectionSetup { int pos1 = filename.lastIndexOf("/"); int pos2 = filename.lastIndexOf("."); - if (pos2 == -1) + if (pos2 == -1) { pos2 = filename.length(); + } - String label = filename.substring(pos1+1,pos2); + String label = filename.substring(pos1 + 1, pos2); String typename = type.getClassName(); int pos3 = typename.lastIndexOf("."); - String name = typename.substring(pos3+1, typename.length()) + "-" + label; + String name = typename.substring(pos3 + 1, typename.length()) + "-" + label; Template temp = new Template(); temp.setContentSection(m_section); @@ -483,32 +470,28 @@ public final class ContentSectionSetup { temp.setLabel(label); temp.setParent(m_section.getTemplatesFolder()); - final ClassLoader loader = Thread.currentThread - ().getContextClassLoader(); - final InputStream stream = loader.getResourceAsStream - (filename.substring(1)); + final ClassLoader loader = Thread.currentThread().getContextClassLoader(); + final InputStream stream = loader.getResourceAsStream(filename.substring(1)); if (stream == null) { - throw new IllegalStateException - ((String) GlobalizationUtil.globalize - ("cms.installer.cannot_find_file").localize() + filename); + throw new IllegalStateException((String) GlobalizationUtil.globalize("cms.installer.cannot_find_file").localize() + filename); } - final BufferedReader input = new BufferedReader - (new InputStreamReader(stream)); + final BufferedReader input = new BufferedReader(new InputStreamReader(stream)); - StringBuffer body = new StringBuffer(); + StringBuilder body = new StringBuilder(); String line; for (;;) { try { line = input.readLine(); } catch (IOException ex) { - throw new UncheckedWrapperException( - (String) GlobalizationUtil.globalize( - "cms.installer.cannot_read_line_of_data").localize(), ex); + throw new UncheckedWrapperException( + (String) GlobalizationUtil.globalize( + "cms.installer.cannot_read_line_of_data").localize(), ex); } - if (line == null) + if (line == null) { break; + } body.append(line); body.append("\n"); @@ -518,12 +501,9 @@ public final class ContentSectionSetup { temp.save(); - TemplateManagerFactory.getInstance() - .addTemplate(m_section, type, temp, "public"); + TemplateManagerFactory.getInstance().addTemplate(m_section, type, temp, "public"); temp.publish(m_lcd, new Date()); - // Dan said to comment this out - // temp.getLifecycle().start(); } /** @@ -553,7 +533,6 @@ public final class ContentSectionSetup { alert.save(); } - // // Currently there is no way to persists alert preferemces, therefore // // currently not a loader or setup task. // /** @@ -607,14 +586,13 @@ public final class ContentSectionSetup { // // return unfinished; // } - // ///////////////////// Private Class Section //////////////////////////// - /** * SAX Handler for category lists. Creates the categories as they are * defined, with structure, in the xml document. */ private class CategoryHandler extends DefaultHandler { + private Stack m_cats = new Stack(); private ContentSection m_section; @@ -623,8 +601,8 @@ public final class ContentSectionSetup { } @Override - public void startElement ( String uri, String local, - String qName, Attributes attrs ) { + public void startElement(String uri, String local, + String qName, Attributes attrs) { if ("categories".equals(qName)) { String name = attrs.getValue("name"); if (name == null) { @@ -634,7 +612,7 @@ public final class ContentSectionSetup { String context = attrs.getValue("context"); Category root = Category.getRootForObject(m_section, - context); + context); if (root == null) { root = new Category(); } @@ -643,18 +621,18 @@ public final class ContentSectionSetup { if (root.isNew()) { Category.setRootForObject(m_section, - root, - context); + root, + context); } m_cats.push(root); PermissionService.setContext(root, m_section); - } else if ( "category".equals(qName) ) { + } else if ("category".equals(qName)) { String name = attrs.getValue("name"); String description = attrs.getValue("description"); String url = attrs.getValue("url"); // set the default description to the name of the category - if ( description == null ) { + if (description == null) { description = name; } @@ -664,8 +642,8 @@ public final class ContentSectionSetup { Category parent = null; try { - parent = (Category)m_cats.peek(); - } catch ( EmptyStackException ex ) { + parent = (Category) m_cats.peek(); + } catch (EmptyStackException ex) { throw new UncheckedWrapperException("no root category", ex); } @@ -679,13 +657,12 @@ public final class ContentSectionSetup { } @Override - public void endElement ( String uri, String local, String qName ) { - if ( "category".equals(qName) ) { + public void endElement(String uri, String local, String qName) { + if ("category".equals(qName)) { m_cats.pop(); - } else if ( "categories".equals(qName)) { + } else if ("categories".equals(qName)) { m_cats.pop(); } } } - } diff --git a/ccm-cms/src/com/arsdigita/cms/contenttypes/AbstractContentTypeLoader.java b/ccm-cms/src/com/arsdigita/cms/contenttypes/AbstractContentTypeLoader.java index 3ce764b51..575420f8b 100755 --- a/ccm-cms/src/com/arsdigita/cms/contenttypes/AbstractContentTypeLoader.java +++ b/ccm-cms/src/com/arsdigita/cms/contenttypes/AbstractContentTypeLoader.java @@ -86,14 +86,13 @@ public abstract class AbstractContentTypeLoader extends PackageLoader { ContentSection.BASE_DATA_OBJECT_TYPE); while (sections.next()) { - ContentSection section = (ContentSection) DomainObjectFactory. - newInstance(sections.getDataObject()); + ContentSection section = (ContentSection) DomainObjectFactory.newInstance(sections.getDataObject()); if (!isLoadableInto(section)) { continue; } LifecycleDefinitionCollection ldc = - section.getLifecycleDefinitions(); + section.getLifecycleDefinitions(); LifecycleDefinition ld = null; if (ldc.next()) { ld = ldc.getLifecycleDefinition(); @@ -118,11 +117,11 @@ public abstract class AbstractContentTypeLoader extends PackageLoader { } protected void prepareSection(final ContentSection section, - final ContentType type, - final LifecycleDefinition ld, - final WorkflowTemplate wf) { + final ContentType type, + final LifecycleDefinition ld, + final WorkflowTemplate wf) { ContentTypeLifecycleDefinition.updateLifecycleDefinition(section, type, - ld); + ld); ContentTypeWorkflowTemplate.updateWorkflowTemplate(section, type, wf); } @@ -164,12 +163,12 @@ public abstract class AbstractContentTypeLoader extends PackageLoader { * be called by the loader class by overriding prepareSection */ protected Template setDefaultTemplate(final String name, - final String label, - final InputStream templateIs, - final ContentSection section, - final ContentType type, - final LifecycleDefinition ld, - final WorkflowTemplate wf) { + final String label, + final InputStream templateIs, + final ContentSection section, + final ContentType type, + final LifecycleDefinition ld, + final WorkflowTemplate wf) { final Template template = new Template(); template.setName(name); template.setLabel(label); @@ -197,7 +196,7 @@ public abstract class AbstractContentTypeLoader extends PackageLoader { template.setText(body.toString()); TemplateManagerFactory.getInstance().addTemplate(section, type, template, - TemplateManager.PUBLIC_CONTEXT); + TemplateManager.PUBLIC_CONTEXT); template.publish(ld, new Date()); return template; diff --git a/ccm-cms/src/com/arsdigita/cms/installer/xml/ContentTypeHelper.java b/ccm-cms/src/com/arsdigita/cms/installer/xml/ContentTypeHelper.java index d1f356423..20215272f 100755 --- a/ccm-cms/src/com/arsdigita/cms/installer/xml/ContentTypeHelper.java +++ b/ccm-cms/src/com/arsdigita/cms/installer/xml/ContentTypeHelper.java @@ -45,7 +45,8 @@ public interface ContentTypeHelper { public void setLabelKey(String labelKey); public String getLabelKey(); public boolean isInternal(); - public void setInternal(boolean internal); + public boolean isHidden(); + public void setMode(String mode); /** @deprecated */ public void setDescription(String description) ; /** @deprecated */ diff --git a/ccm-cms/src/com/arsdigita/cms/installer/xml/ContentTypeHelperImpl.java b/ccm-cms/src/com/arsdigita/cms/installer/xml/ContentTypeHelperImpl.java index 52b322fa4..2c84c4671 100755 --- a/ccm-cms/src/com/arsdigita/cms/installer/xml/ContentTypeHelperImpl.java +++ b/ccm-cms/src/com/arsdigita/cms/installer/xml/ContentTypeHelperImpl.java @@ -50,7 +50,7 @@ public class ContentTypeHelperImpl implements ContentTypeHelper { private String m_className; private String m_createComponent; private AuthoringKit m_kit; - private boolean m_internal; + private String m_mode; public ContentTypeHelperImpl() { } @@ -95,12 +95,16 @@ public class ContentTypeHelperImpl implements ContentTypeHelper { return m_labelKey; } - public void setInternal(boolean internal) { - m_internal = internal; + public void setMode(String mode) { + m_mode = mode.toLowerCase(); } public boolean isInternal() { - return m_internal; + return m_mode.equalsIgnoreCase("internal"); + } + + public boolean isHidden() { + return m_mode.equalsIgnoreCase("hidden"); } /** @@ -210,7 +214,7 @@ public class ContentTypeHelperImpl implements ContentTypeHelper { m_type.setDescription(m_description); m_type.setClassName(m_className); m_type.setAssociatedObjectType(m_objectType); - m_type.setInternal(m_internal); + m_type.setMode(m_mode); // create pedigree for this content type createPedigree(m_type); @@ -221,7 +225,7 @@ public class ContentTypeHelperImpl implements ContentTypeHelper { // Turn on search indexing for this type ObjectType type = SessionManager.getMetadataRoot().getObjectType(m_objectType); if (type.isSubtypeOf(ContentPage.BASE_DATA_OBJECT_TYPE) - && !m_internal) { + && !isInternal()) { s_log.debug("Registering search adapter for " + m_objectType); MetadataProviderRegistry.registerAdapter( diff --git a/ccm-cms/src/com/arsdigita/cms/installer/xml/XMLContentTypeHandler.java b/ccm-cms/src/com/arsdigita/cms/installer/xml/XMLContentTypeHandler.java index adf71f951..d6d181b34 100755 --- a/ccm-cms/src/com/arsdigita/cms/installer/xml/XMLContentTypeHandler.java +++ b/ccm-cms/src/com/arsdigita/cms/installer/xml/XMLContentTypeHandler.java @@ -18,9 +18,9 @@ */ package com.arsdigita.cms.installer.xml; - import com.arsdigita.cms.AuthoringKit; import com.arsdigita.cms.ContentType; +import com.arsdigita.cms.contenttypes.ContentTypeInitializer; import com.arsdigita.xml.XML; import org.apache.log4j.Logger; @@ -38,34 +38,30 @@ import java.util.List; * * @see ContentTypeInitializer * @author Nobuko Asakai */ - public class XMLContentTypeHandler extends DefaultHandler { + private static Logger s_log = - Logger.getLogger(XMLContentTypeHandler.class.getName()); - - - + Logger.getLogger(XMLContentTypeHandler.class.getName()); private ArrayList m_types = new ArrayList(); - private ContentTypeHelper m_type; private ContentType m_contentType; private AuthoringKit m_authoringKit; private int m_nextOrder; - private boolean m_including; public List getContentTypes() { return m_types; } - public void startElement( String uri, String name, - String qName, Attributes atts) { - if (name.equals("content-types") ) { + @Override + public void startElement(String uri, String name, + String qName, Attributes atts) { + if (name.equals("content-types")) { s_log.debug("matched content-types"); } else if (name.equals("content-type")) { s_log.debug("matched content-type"); String parentType = atts.getValue("parentType"); - if (parentType != null ) { + if (parentType != null) { m_type = new UDCTHelper(); s_log.debug("Creating UDCT"); } else { @@ -85,17 +81,20 @@ public class XMLContentTypeHandler extends DefaultHandler { m_type.setObjectType(atts.getValue("objectType")); m_type.setClassName(atts.getValue("classname")); - String internal = atts.getValue("isInternal"); - if (internal != null && - "yes".equals(internal)) { - m_type.setInternal(true); + String mode = atts.getValue("mode"); + if (mode != null && !mode.isEmpty()) { + m_type.setMode(mode.trim()); + } else { + m_type.setMode("default"); } + // UDCT stuff m_type.setParentType(parentType); m_type.setName(atts.getValue("name")); + m_contentType = m_type.createType(); m_types.add(m_contentType); - } else if ( name.equals("authoring-kit") ) { + } else if (name.equals("authoring-kit")) { if (!m_including) { s_log.debug("matched authoring-kit"); if (atts.getValue("createComponent") != null) { @@ -104,7 +103,7 @@ public class XMLContentTypeHandler extends DefaultHandler { m_authoringKit = m_type.createAuthoringKit(); m_nextOrder = 1; } - } else if ( name.equals("authoring-step" )) { + } else if (name.equals("authoring-step")) { String label = atts.getValue("label"); String labelKey = atts.getValue("labelKey"); String labelBundle = atts.getValue("labelBundle"); @@ -118,10 +117,9 @@ public class XMLContentTypeHandler extends DefaultHandler { descriptionKey = description; } m_type.addAuthoringStep(labelKey, labelBundle, - descriptionKey, descriptionBundle, - atts.getValue("component"), - new BigDecimal(m_nextOrder++) - ); + descriptionKey, descriptionBundle, + atts.getValue("component"), + new BigDecimal(m_nextOrder++)); } else if (name.equals("include")) { String file = atts.getValue("href"); m_including = true; @@ -129,12 +127,12 @@ public class XMLContentTypeHandler extends DefaultHandler { m_including = false; } else { s_log.error("None of the elements match! name: " + name - + " qName: " + qName + " URI: " + uri); + + " qName: " + qName + " URI: " + uri); } } - public void endElement( String uri, String name, - String qName, Attributes atts) { + public void endElement(String uri, String name, + String qName, Attributes atts) { if (name.equals("content-type")) { // reset the helper m_contentType.save(); diff --git a/ccm-cms/src/com/arsdigita/cms/ui/type/AddContentItemElement.java b/ccm-cms/src/com/arsdigita/cms/ui/type/AddContentItemElement.java index a3fd0870a..a1c6b41d2 100755 --- a/ccm-cms/src/com/arsdigita/cms/ui/type/AddContentItemElement.java +++ b/ccm-cms/src/com/arsdigita/cms/ui/type/AddContentItemElement.java @@ -18,7 +18,6 @@ */ package com.arsdigita.cms.ui.type; - import com.arsdigita.bebop.ColumnPanel; import com.arsdigita.bebop.FormProcessException; import com.arsdigita.bebop.Label; @@ -57,19 +56,17 @@ import java.util.TooManyListenersException; public class AddContentItemElement extends ElementAddForm { private static final Logger s_log = - Logger.getLogger(AddContentItemElement.class); - + Logger.getLogger(AddContentItemElement.class); private SingleSelect m_itemTypeSelect; + /** * Constructor */ public AddContentItemElement(ACSObjectSelectionModel types) { super("ContentTypeAddContentItemElement", "Add a ContentItem Element", types); - add(new Label(GlobalizationUtil.globalize - ("cms.ui.type.association_content_type"))); - m_itemTypeSelect = new SingleSelect - (new BigDecimalParameter("AddContentItemTypeSelect")); + add(new Label(GlobalizationUtil.globalize("cms.ui.type.association_content_type"))); + m_itemTypeSelect = new SingleSelect(new BigDecimalParameter("AddContentItemTypeSelect")); try { m_itemTypeSelect.addPrintListener(new ItemTypeSelectPrintListener()); } catch (TooManyListenersException ex) { @@ -78,49 +75,45 @@ public class AddContentItemElement extends ElementAddForm { } add(m_itemTypeSelect); - add(m_buttons, ColumnPanel.FULL_WIDTH|ColumnPanel.CENTER); + add(m_buttons, ColumnPanel.FULL_WIDTH | ColumnPanel.CENTER); } private ContentType getItemType(PageState state) - throws FormProcessException { + throws FormProcessException { BigDecimal itemTypeID = - (BigDecimal) m_itemTypeSelect.getValue(state); + (BigDecimal) m_itemTypeSelect.getValue(state); ContentType itemType = null; Assert.exists(itemTypeID, "itemTypeID"); try { itemType = new ContentType(itemTypeID); } catch (DataObjectNotFoundException ex) { - throw new FormProcessException - ((String) GlobalizationUtil.globalize - ("cms.ui.type.invalid").localize()); + throw new FormProcessException((String) GlobalizationUtil.globalize("cms.ui.type.invalid").localize()); } return itemType; } protected final void addAttribute(DynamicObjectType dot, String label, - PageState state) - throws FormProcessException { + PageState state) + throws FormProcessException { ContentType itemType = getItemType(state); dot.addOptionalAssociation(label, - MetadataRoot.getMetadataRoot().getObjectType - (itemType.getAssociatedObjectType())); + MetadataRoot.getMetadataRoot().getObjectType(itemType.getAssociatedObjectType())); } protected final void addFormComponent(PersistentForm pForm, String label, - PageState state) - throws FormProcessException { + PageState state) + throws FormProcessException { ContentType itemType = getItemType(state); - PersistentHidden pContentTypeName = PersistentHidden.create(label+"Type"); + PersistentHidden pContentTypeName = PersistentHidden.create(label + "Type"); pContentTypeName.setDefaultValue(itemType.getAssociatedObjectType()); pContentTypeName.save(); pForm.addComponent(pContentTypeName); PersistentSingleSelect pSelect = PersistentSingleSelect.create(label); - pSelect.setParameterModel - ("com.arsdigita.bebop.parameters.BigDecimalParameter"); + pSelect.setParameterModel("com.arsdigita.bebop.parameters.BigDecimalParameter"); pSelect.save(); pForm.addComponent(pSelect); } @@ -137,9 +130,9 @@ public class AddContentItemElement extends ElementAddForm { // Get the current content section ContentSection section = CMS.getContext().getContentSection(); - ContentTypeCollection contentTypes = section.getCreatableContentTypes(); + ContentTypeCollection contentTypes = section.getCreatableContentTypes(true); contentTypes.addOrder(ContentType.LABEL); - while ( contentTypes.next() ) { + while (contentTypes.next()) { ContentType type = contentTypes.getContentType(); t.addOption(new Option(type.getID().toString(), type.getLabel())); } diff --git a/ccm-cms/src/com/arsdigita/cms/ui/type/ContentTypeAdminPane.java b/ccm-cms/src/com/arsdigita/cms/ui/type/ContentTypeAdminPane.java index 69e718f37..04f017acb 100755 --- a/ccm-cms/src/com/arsdigita/cms/ui/type/ContentTypeAdminPane.java +++ b/ccm-cms/src/com/arsdigita/cms/ui/type/ContentTypeAdminPane.java @@ -48,6 +48,7 @@ import com.arsdigita.toolbox.ui.Cancellable; import org.apache.log4j.Logger; import java.math.BigDecimal; + /** * This class contains the split pane for the ContentType * administration interface. @@ -60,15 +61,13 @@ import java.math.BigDecimal; */ public final class ContentTypeAdminPane extends BaseAdminPane { - private static final Logger s_log = Logger.getLogger - (ContentTypeAdminPane.class); - + private static final Logger s_log = Logger.getLogger(ContentTypeAdminPane.class); private final ACSObjectSelectionModel m_model; private final ContentTypeRequestLocal m_type; public ContentTypeAdminPane() { super(new Label(gz("cms.ui.types")), - new ContentTypeListModelBuilder()); + new ContentTypeListModelBuilder()); m_model = new ACSObjectSelectionModel(getSelectionModel()); m_type = new SelectionRequestLocal(); @@ -83,13 +82,13 @@ public final class ContentTypeAdminPane extends BaseAdminPane { new EditType(m_model)); setDelete(new ActionLink(new Label(gz("cms.ui.type.delete"))), - new DeleteForm()); + new DeleteForm()); setIntroPane(new Label(gz("cms.ui.type.intro"))); - setItemPane(new ContentTypeItemPane(m_model, - m_type, - getEditLink(), - getDeleteLink())); + setItemPane(new ContentTypeItemPane(m_model, + m_type, + getEditLink(), + getDeleteLink())); addAction(new TypeSecurityContainer(addTypeLink), ActionGroup.ADD); } @@ -98,53 +97,54 @@ public final class ContentTypeAdminPane extends BaseAdminPane { super.register(p); p.addActionListener(new ActionListener() { - public void actionPerformed(ActionEvent e) { - final PageState state = e.getPageState(); - ContentType contentType = (ContentType) m_model.getSelectedObject(state); - ContentSection section = CMS.getContext().getContentSection(); - if ( contentType == null ) { - final String template = state.getRequest().getParameter - (ContentSectionPage.SET_TEMPLATE); - if (template != null) { - DataCollection da = SessionManager.getSession().retrieve(SectionTemplateMapping.BASE_DATA_OBJECT_TYPE); - DomainCollection c = new DomainCollection(da); - c.addEqualsFilter(SectionTemplateMapping.SECTION + "." + ACSObject.ID, - section.getID()); - c.addEqualsFilter(SectionTemplateMapping.TEMPLATE + "." + ACSObject.ID, - new BigDecimal(template)); - c.addOrder(SectionTemplateMapping.CONTENT_TYPE + "." + ContentType.LABEL); - if (c.next()) { - SectionTemplateMapping mapping = - (SectionTemplateMapping) c.getDomainObject(); - contentType = mapping.getContentType(); - } - c.close(); - } - if ( contentType == null ) { - ContentTypeCollection contentTypes = section.getContentTypes(); - contentTypes.addOrder("label asc"); - try { - if ( contentTypes.next() ) { - contentType = contentTypes.getContentType(); - } - } finally { - contentTypes.close(); - } - } - if (contentType != null) { - m_model.setSelectedObject(state,contentType); - getBody().push(state, getItemPane()); - } - + public void actionPerformed(ActionEvent e) { + final PageState state = e.getPageState(); + ContentType contentType = (ContentType) m_model.getSelectedObject(state); + ContentSection section = CMS.getContext().getContentSection(); + if (contentType == null) { + final String template = state.getRequest().getParameter(ContentSectionPage.SET_TEMPLATE); + if (template != null) { + DataCollection da = SessionManager.getSession().retrieve(SectionTemplateMapping.BASE_DATA_OBJECT_TYPE); + DomainCollection c = new DomainCollection(da); + c.addEqualsFilter(SectionTemplateMapping.SECTION + "." + ACSObject.ID, + section.getID()); + c.addEqualsFilter(SectionTemplateMapping.TEMPLATE + "." + ACSObject.ID, + new BigDecimal(template)); + c.addOrder(SectionTemplateMapping.CONTENT_TYPE + "." + ContentType.LABEL); + if (c.next()) { + SectionTemplateMapping mapping = + (SectionTemplateMapping) c.getDomainObject(); + contentType = mapping.getContentType(); + } + c.close(); } + if (contentType == null) { + ContentTypeCollection contentTypes = section.getContentTypes(); + contentTypes.addOrder("label asc"); + try { + if (contentTypes.next()) { + contentType = contentTypes.getContentType(); + } + } finally { + contentTypes.close(); + } + } + if (contentType != null) { + m_model.setSelectedObject(state, contentType); + getBody().push(state, getItemPane()); + } + + } - }); + } + }); } private class AddTypeContainer extends GridPanel implements ActionListener, FormProcessListener { - private Label m_noTypesAvailable = - new Label(gz("cms.ui.type.select.none")); + + private Label m_noTypesAvailable = + new Label(gz("cms.ui.type.select.none")); private SelectType m_selectType; private CreateType m_createType; @@ -157,44 +157,41 @@ public final class ContentTypeAdminPane extends BaseAdminPane { GridPanel container = new GridPanel(1); container.add(m_noTypesAvailable); m_selectType = new SelectType(); - m_selectType.addSubmissionListener - (new CancelListener(m_selectType)); + m_selectType.addSubmissionListener(new CancelListener(m_selectType)); m_selectType.addProcessListener(this); container.add(m_selectType); selectSection.setBody(container); Section addSection = new Section() { - public final boolean isVisible(final PageState state) { - return super.isVisible(state) && - !ContentSection.getConfig().getHideUDCTUI(); - } - }; + + public final boolean isVisible(final PageState state) { + return super.isVisible(state) + && !ContentSection.getConfig().getHideUDCTUI(); + } + }; addSection.setHeading(new Label(gz("cms.ui.type.define"))); m_createType = new CreateType(m_model); - m_createType.addSubmissionListener - (new CancelListener(m_createType)); + m_createType.addSubmissionListener(new CancelListener(m_createType)); m_createType.addProcessListener(this); addSection.setBody(m_createType); add(addSection); } - public void actionPerformed(ActionEvent e) { PageState s = e.getPageState(); ContentSection section = CMS.getContext().getContentSection(); ContentTypeCollection contentTypes = - section.getNotAssociatedContentTypes(); + section.getNotAssociatedContentTypes(); boolean hasAvailableTypes = !contentTypes.isEmpty(); m_selectType.setVisible(s, hasAvailableTypes); m_noTypesAvailable.setVisible(s, !hasAvailableTypes); } public final void process(final FormSectionEvent e) - throws FormProcessException { + throws FormProcessException { final PageState state = e.getPageState(); resetPane(state); } - } /** @@ -203,13 +200,15 @@ public final class ContentTypeAdminPane extends BaseAdminPane { * becaue it was protected */ private final class CancelListener implements FormSubmissionListener { + Cancellable m_form; + CancelListener(Cancellable form) { m_form = form; } - public void submitted(FormSectionEvent event) - throws FormProcessException { + public void submitted(FormSectionEvent event) + throws FormProcessException { PageState state = event.getPageState(); if (m_form.isCancelled(state)) { getBody().pop(state); @@ -221,20 +220,22 @@ public final class ContentTypeAdminPane extends BaseAdminPane { private void resetPane(PageState state) { getBody().reset(state); if (getSelectionModel().isSelected(state)) { - s_log.debug("The selection model is selected; displaying " + - "the item pane"); + s_log.debug("The selection model is selected; displaying " + + "the item pane"); getBody().push(state, getItemPane()); } } private class SelectionRequestLocal extends ContentTypeRequestLocal { + protected final Object initialValue(final PageState state) { - ContentType contentType = (ContentType) m_model.getSelectedObject(state); + ContentType contentType = (ContentType) m_model.getSelectedObject(state); return contentType; } } private class DeleteForm extends BaseDeleteForm { + DeleteForm() { super(new Label(gz("cms.ui.type.delete_prompt"))); @@ -245,7 +246,7 @@ public final class ContentTypeAdminPane extends BaseAdminPane { throws FormProcessException { final PageState state = e.getPageState(); final ContentSection section = - CMS.getContext().getContentSection(); + CMS.getContext().getContentSection(); section.removeContentType(m_type.getContentType(state)); section.save(); diff --git a/ccm-cms/src/com/arsdigita/cms/ui/type/ContentTypeListModelBuilder.java b/ccm-cms/src/com/arsdigita/cms/ui/type/ContentTypeListModelBuilder.java index b00d6f8ff..f3adc478c 100755 --- a/ccm-cms/src/com/arsdigita/cms/ui/type/ContentTypeListModelBuilder.java +++ b/ccm-cms/src/com/arsdigita/cms/ui/type/ContentTypeListModelBuilder.java @@ -46,7 +46,7 @@ class ContentTypeListModelBuilder extends LockableImpl final ContentSection section = CMS.getContext().getContentSection(); - m_types = section.getContentTypes(); + m_types = section.getContentTypes(true); m_types.addOrder(ContentType.LABEL); m_types.rewind(); } diff --git a/ccm-cms/src/com/arsdigita/cms/ui/type/CreateType.java b/ccm-cms/src/com/arsdigita/cms/ui/type/CreateType.java index 1d16c296c..e3df1d0f3 100755 --- a/ccm-cms/src/com/arsdigita/cms/ui/type/CreateType.java +++ b/ccm-cms/src/com/arsdigita/cms/ui/type/CreateType.java @@ -18,7 +18,6 @@ */ package com.arsdigita.cms.ui.type; - import com.arsdigita.bebop.ColumnPanel; import com.arsdigita.bebop.FormData; import com.arsdigita.bebop.FormProcessException; @@ -85,21 +84,16 @@ import java.util.TooManyListenersException; * @author Xixi D'Moon (xdmoon@arsdigita.com) * @version $Revision: #21 $ $Date: 2004/08/17 $ */ - public class CreateType extends CMSForm - implements FormProcessListener, FormInitListener, FormSubmissionListener, FormValidationListener { + implements FormProcessListener, FormInitListener, FormSubmissionListener, FormValidationListener { private static final String DEFAULT_UDITEM_TYPE = ContentPage.BASE_DATA_OBJECT_TYPE; private static final String CATEGORIZATION_COMPONENT = - "com.arsdigita.cms.ui.authoring.ItemCategoryStep"; - + "com.arsdigita.cms.ui.authoring.ItemCategoryStep"; private final static Logger s_log = - Logger.getLogger(CreateType.class.getName()); - + Logger.getLogger(CreateType.class.getName()); //private static final ObjectType TEST_TYPE = SessionManager.getMetadataRoot().getObjectType("com.arsdigita.kernel.Party"); - private static final String CREATION_COMPONENT = "com.arsdigita.cms.ui.authoring.PageCreateDynamic"; - private Hidden m_id; private TextField m_name; private TextField m_label; @@ -110,12 +104,12 @@ public class CreateType extends CMSForm private Submit m_submit; private Submit m_cancel; private SingleSelectionModel m_types = null; - DynamicObjectType dot; public CreateType() { this(null); } + public CreateType(SingleSelectionModel m) { super("NewContentItemDefinition"); if (m != null) { @@ -190,7 +184,7 @@ public class CreateType extends CMSForm m_cancel = new Submit("cancel"); m_cancel.setButtonLabel("Cancel"); s.add(m_cancel); - add(s, ColumnPanel.FULL_WIDTH|ColumnPanel.CENTER); + add(s, ColumnPanel.FULL_WIDTH | ColumnPanel.CENTER); //add the listeners addProcessListener(this); @@ -201,6 +195,7 @@ public class CreateType extends CMSForm } // if this form is cancelled + @Override public boolean isCancelled(PageState s) { return m_cancel.isSelected(s); } @@ -210,7 +205,7 @@ public class CreateType extends CMSForm * the particular content section, and if the new type name is * legal dynamic object type name */ - public void validate (FormSectionEvent e) throws FormProcessException { + public void validate(FormSectionEvent e) throws FormProcessException { PageState s = e.getPageState(); String typeLabel = (String) m_label.getValue(s); String typeName = (String) m_name.getValue(s); @@ -220,23 +215,22 @@ public class CreateType extends CMSForm boolean dupe = false; - while (contentTypes.next() && dupe==false) { - if (contentTypes.getContentType().getLabel().compareTo(typeLabel)==0) { + while (contentTypes.next() && dupe == false) { + if (contentTypes.getContentType().getLabel().compareTo(typeLabel) == 0) { dupe = true; } } if (dupe == true) { - throw new FormProcessException - ((String) GlobalizationUtil.globalize("cms.ui.type.name_not_unique", new Object[] { typeLabel }).localize()); + throw new FormProcessException((String) GlobalizationUtil.globalize("cms.ui.type.name_not_unique", new Object[]{typeLabel}).localize()); } else { for (int i = 0; i < typeName.length(); i++) { char c = typeName.charAt(i); if (Character.isWhitespace(c)) { - throw new FormProcessException( (String) GlobalizationUtil.globalize("cms.ui.type.name_has_whitespace").localize()); + throw new FormProcessException((String) GlobalizationUtil.globalize("cms.ui.type.name_has_whitespace").localize()); } else if (!Character.isLetterOrDigit(c)) { - throw new FormProcessException( (String) GlobalizationUtil.globalize("cms.ui.type.name_not_alphanumeric").localize()); + throw new FormProcessException((String) GlobalizationUtil.globalize("cms.ui.type.name_not_alphanumeric").localize()); } } @@ -278,12 +272,10 @@ public class CreateType extends CMSForm if (parentContentType != null) { parentContentClassname = parentContentType.getClassName(); parentObjectType = - SessionManager.getMetadataRoot().getObjectType - (parentContentType.getAssociatedObjectType()); + SessionManager.getMetadataRoot().getObjectType(parentContentType.getAssociatedObjectType()); } else { try { - parentContentType = ContentType.findByAssociatedObjectType - (DEFAULT_UDITEM_TYPE); + parentContentType = ContentType.findByAssociatedObjectType(DEFAULT_UDITEM_TYPE); parentContentClassname = parentContentType.getClassName(); } catch (DataObjectNotFoundException ex) { // If parent content type isn't found, don't add @@ -291,18 +283,15 @@ public class CreateType extends CMSForm //classname parentContentClassname = "com.arsdigita.cms.ContentPage"; } - parentObjectType = SessionManager.getMetadataRoot().getObjectType - (DEFAULT_UDITEM_TYPE); + parentObjectType = SessionManager.getMetadataRoot().getObjectType(DEFAULT_UDITEM_TYPE); } String qname = parentObjectType.getModel().getName() + "." + name; MetadataRoot root = MetadataRoot.getMetadataRoot(); if (root.getObjectType(qname) != null || root.hasTable(name)) { - throw new FormValidationException - (m_name, (String) GlobalizationUtil.globalize - ("cms.ui.type.duplicate_type", - new Object[] { name }).localize()); + throw new FormValidationException(m_name, (String) GlobalizationUtil.globalize("cms.ui.type.duplicate_type", + new Object[]{name}).localize()); } //create a new dynamic object type with @@ -317,8 +306,7 @@ public class CreateType extends CMSForm try { contentType = new ContentType(key); } catch (DataObjectNotFoundException ex) { - contentType = new ContentType(SessionManager.getSession().create - (new OID(ContentType.BASE_DATA_OBJECT_TYPE, key))); + contentType = new ContentType(SessionManager.getSession().create(new OID(ContentType.BASE_DATA_OBJECT_TYPE, key))); isNew = true; } @@ -339,10 +327,10 @@ public class CreateType extends CMSForm } //associate a default lifecycle - setDefaultLifecycle (lifecycleID, section, contentType); + setDefaultLifecycle(lifecycleID, section, contentType); //associate a default workflow - setDefaultWorkflow (workflowID, section, contentType); + setDefaultWorkflow(workflowID, section, contentType); //drop the page to refresh content center, admin and item ui Utilities.refreshItemUI(state); @@ -378,7 +366,7 @@ public class CreateType extends CMSForm * return true if this form is cancelled, false otherwise */ public void submitted(FormSectionEvent e) throws FormProcessException { - if(m_cancel.isSelected(e.getPageState())) { + if (m_cancel.isSelected(e.getPageState())) { throw new FormProcessException("cancelled"); } } @@ -389,16 +377,17 @@ public class CreateType extends CMSForm * With no parent type sent, the parent type authoring kit steps won't be added */ protected void updateContentTypeAssociation(ContentSection section, - ContentType type) { + ContentType type) { updateContentTypeAssociation(section, type, null); } + /** * registers the new type to this content section * and creates authoring kit for the content type */ protected void updateContentTypeAssociation(ContentSection section, - ContentType type, - ContentType parentType) { + ContentType type, + ContentType parentType) { section.addContentType(type); section.save(); @@ -417,29 +406,29 @@ public class CreateType extends CMSForm hasCategoryStep = true; } kit.createStep(step.getLabel(), - step.getDescription(), - step.getComponent(), - new BigDecimal(stepOrdering)); + step.getDescription(), + step.getComponent(), + new BigDecimal(stepOrdering)); stepOrdering++; } } if (stepOrdering == 1) { kit.createStep(type.getLabel() + " Basic Properties", - type.getAssociatedObjectType(), - "com.arsdigita.cms.ui.authoring.PageEditDynamic", - new BigDecimal(stepOrdering)); + type.getAssociatedObjectType(), + "com.arsdigita.cms.ui.authoring.PageEditDynamic", + new BigDecimal(stepOrdering)); } else { kit.createStep(type.getLabel() + " Basic Properties", - type.getAssociatedObjectType(), - "com.arsdigita.cms.ui.authoring.SecondaryPageEditDynamic", - new BigDecimal(stepOrdering)); + type.getAssociatedObjectType(), + "com.arsdigita.cms.ui.authoring.SecondaryPageEditDynamic", + new BigDecimal(stepOrdering)); } stepOrdering++; if (!hasCategoryStep) { kit.createStep("Categories", - "", - CATEGORIZATION_COMPONENT, - new BigDecimal(stepOrdering)); + "", + CATEGORIZATION_COMPONENT, + new BigDecimal(stepOrdering)); } kit.save(); @@ -462,13 +451,17 @@ public class CreateType extends CMSForm // Get the current content section ContentSection section = CMS.getContext().getContentSection(); - t.addOption(new Option("-1","-- select --")); + t.addOption(new Option("-1", "-- select --")); - ContentTypeCollection contentTypes = section.getCreatableContentTypes(); + ContentTypeCollection contentTypes = section.getCreatableContentTypes(true); contentTypes.addOrder(ContentType.LABEL); - while ( contentTypes.next() ) { + while (contentTypes.next()) { ContentType type = contentTypes.getContentType(); - t.addOption(new Option(type.getID().toString(), type.getLabel())); + Label label = new Label(type.getLabel()); + if (type.isHidden()) { + label.setFontWeight(Label.ITALIC); + } + t.addOption(new Option(type.getID().toString(), label)); } } } @@ -485,10 +478,10 @@ public class CreateType extends CMSForm // Get the current content section ContentSection section = CMS.getContext().getContentSection(); - t.addOption(new Option("-1","-- select --")); + t.addOption(new Option("-1", "-- select --")); LifecycleDefinitionCollection cycles = section.getLifecycleDefinitions(); - while ( cycles.next() ) { + while (cycles.next()) { LifecycleDefinition cycle = cycles.getLifecycleDefinition(); t.addOption(new Option(cycle.getID().toString(), cycle.getLabel())); } @@ -507,22 +500,22 @@ public class CreateType extends CMSForm // Get the current content section ContentSection section = CMS.getContext().getContentSection(); - t.addOption(new Option("-1","-- select --")); + t.addOption(new Option("-1", "-- select --")); TaskCollection templates = section.getWorkflowTemplates(); - while ( templates.next() ) { + while (templates.next()) { WorkflowTemplate template = - (WorkflowTemplate) templates.getDomainObject(); + (WorkflowTemplate) templates.getDomainObject(); t.addOption(new Option(template.getID().toString(), - template.getLabel())); + template.getLabel())); } } } private void setDefaultLifecycle(BigDecimal lifecycleID, - ContentSection section, - ContentType contentType) { + ContentSection section, + ContentType contentType) { //associate a default lifecycle try { @@ -530,11 +523,10 @@ public class CreateType extends CMSForm if (lifecycleID.intValue() != -1) { LifecycleDefinition lifecycle = new LifecycleDefinition(lifecycleID); ContentTypeLifecycleDefinition.updateLifecycleDefinition(section, - contentType, lifecycle); + contentType, lifecycle); } else { //remove the association - ContentTypeLifecycleDefinition.removeLifecycleDefinition - (section, contentType); + ContentTypeLifecycleDefinition.removeLifecycleDefinition(section, contentType); } } } catch (DataObjectNotFoundException ex) { @@ -544,17 +536,16 @@ public class CreateType extends CMSForm } private void setDefaultWorkflow(BigDecimal workflowID, - ContentSection section, - ContentType contentType) { + ContentSection section, + ContentType contentType) { //associate a default workflow try { - if ( workflowID != null) { - if(workflowID.intValue() != -1) { + if (workflowID != null) { + if (workflowID.intValue() != -1) { // Set default workflow definition association. WorkflowTemplate template = new WorkflowTemplate(new OID(WorkflowTemplate.BASE_DATA_OBJECT_TYPE, workflowID)); - ContentTypeWorkflowTemplate. - updateWorkflowTemplate(section, contentType, template); + ContentTypeWorkflowTemplate.updateWorkflowTemplate(section, contentType, template); } else { // Remove the association. ContentTypeWorkflowTemplate.removeWorkflowTemplate(section, contentType); @@ -565,5 +556,4 @@ public class CreateType extends CMSForm } } - } diff --git a/ccm-cms/src/com/arsdigita/cms/ui/type/SelectType.java b/ccm-cms/src/com/arsdigita/cms/ui/type/SelectType.java index 614afa300..38fed9aba 100755 --- a/ccm-cms/src/com/arsdigita/cms/ui/type/SelectType.java +++ b/ccm-cms/src/com/arsdigita/cms/ui/type/SelectType.java @@ -18,7 +18,6 @@ */ package com.arsdigita.cms.ui.type; - import com.arsdigita.bebop.ColumnPanel; import com.arsdigita.bebop.FormData; import com.arsdigita.bebop.FormProcessException; @@ -45,7 +44,6 @@ import com.arsdigita.util.UncheckedWrapperException; import java.math.BigDecimal; import java.util.TooManyListenersException; - /** * This class contains a form component to that allows adding * already-existing content type to a content section. @@ -55,10 +53,9 @@ import java.util.TooManyListenersException; * @version $Id: SelectType.java 287 2005-02-22 00:29:02Z sskracic $ */ public class SelectType extends CMSForm - implements PrintListener, FormSubmissionListener, FormProcessListener { + implements PrintListener, FormSubmissionListener, FormProcessListener { private final static String TYPES = "types"; - private CheckboxGroup m_typesCheckbox; private Submit m_submit; private Submit m_cancel; @@ -83,14 +80,13 @@ public class SelectType extends CMSForm m_cancel = new Submit("cancel"); m_cancel.setButtonLabel("Cancel"); s.add(m_cancel); - add(s, ColumnPanel.FULL_WIDTH|ColumnPanel.CENTER); + add(s, ColumnPanel.FULL_WIDTH | ColumnPanel.CENTER); addProcessListener(this); addSubmissionListener(new TypeSecurityListener()); addSubmissionListener(this); } - /** * Generate a checkbox list of all content type not associated * with the current content section @@ -103,13 +99,16 @@ public class SelectType extends CMSForm ContentSection section = CMS.getContext().getContentSection(); ContentTypeCollection contentTypes = - section.getNotAssociatedContentTypes(); + section.getNotAssociatedContentTypes(); contentTypes.addOrder(ContentType.LABEL); while (contentTypes.next()) { ContentType contentType = contentTypes.getContentType(); - t.addOption(new Option(contentType.getID().toString(), - contentType.getLabel())); + Label label = new Label(contentType.getLabel()); + if (contentType.isHidden()) { + label.setFontWeight(Label.ITALIC); + } + t.addOption(new Option(contentType.getID().toString(), label)); } } @@ -121,7 +120,7 @@ public class SelectType extends CMSForm */ public void submitted(FormSectionEvent event) throws FormProcessException { PageState state = event.getPageState(); - if ( isCancelled(state) ) { + if (isCancelled(state)) { throw new FormProcessException("cancelled"); } } @@ -135,7 +134,6 @@ public class SelectType extends CMSForm return m_cancel.isSelected(state); } - /** * Processes form listener which updates a life cycle */ @@ -146,14 +144,14 @@ public class SelectType extends CMSForm String[] types = (String[]) data.get(TYPES); ContentType type; - if ( types != null ) { - for ( int i = 0; i < types.length; i++ ) { + if (types != null) { + for (int i = 0; i < types.length; i++) { try { type = new ContentType(new BigDecimal(types[i])); section.addContentType(type); } catch (DataObjectNotFoundException ex) { - throw new UncheckedWrapperException("Content Type ID#" + types[i] + - " not found", ex); + throw new UncheckedWrapperException("Content Type ID#" + types[i] + + " not found", ex); } } @@ -162,5 +160,4 @@ public class SelectType extends CMSForm } } } - }