ContentType

Änderung an dem Statusfeld der ContentTypen. Es ist jetzt möglich, interne und versteckte ContentTypen anzulegen und zu unterscheiden. Die versteckten CTs werden in  der Liste zum Anlegen neuer CIs nicht angezeigt, sind aber im Reiter Dokumenttypen sichtbar, so daß sie aus einer ContentSection gelöscht oder ihr hinzugefügt werden können. Außerdem läßt sich ein versteckter CT als Vaterobject für einen UDCT verwenden.

CMS Loader

Beim Erstellen der ersten ContentSection werden nun auch die generischen CTs hinzugefügt. Diese Anpassung ist nötig, da die GCTs über den Loader von CMS geladen werden, der

 1. nicht von AbstractContentTypeLoader abgeleitet ist
 2. zum Zeitpunkt des Ladens der GCTs noch keine ContentSection angelegt ist.

git-svn-id: https://svn.libreccm.org/ccm/trunk@620 8810af33-2d31-482b-a856-94f89814c4df
master
quasi 2010-11-17 23:14:04 +00:00
parent 20e8d916f1
commit 4ca5cc9293
22 changed files with 586 additions and 599 deletions

View File

@ -32,7 +32,7 @@ object type ContentType extends ACSObject {
String[0..1] ancestors = content_types.ancestors VARCHAR(2000); String[0..1] ancestors = content_types.ancestors VARCHAR(2000);
String[0..1] siblings = content_types.siblings 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; BigDecimal[0..1] itemFormID = content_types.item_form_id INTEGER;
AuthoringKit[0..1] authoringKit = join content_types.type_id AuthoringKit[0..1] authoringKit = join content_types.type_id
to authoring_kits.type_id; to authoring_kits.type_id;
@ -64,7 +64,7 @@ association {
do { do {
select select
t.type_id, t.object_type, t.label, t.description, t.classname, 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 from
content_types t, content_section_type_map m, authoring_kits a content_types t, content_section_type_map m, authoring_kits a
where where
@ -80,7 +80,7 @@ association {
creatableContentTypes.className = t.classname; creatableContentTypes.className = t.classname;
creatableContentTypes.ancestors = t.ancestors; creatableContentTypes.ancestors = t.ancestors;
creatableContentTypes.siblings = t.siblings; creatableContentTypes.siblings = t.siblings;
creatableContentTypes.isInternal = t.is_internal; creatableContentTypes.mode = t.mode;
creatableContentTypes.itemFormID = t.item_form_id; creatableContentTypes.itemFormID = t.item_form_id;
} }
} }
@ -112,7 +112,7 @@ association {
do { do {
select select
t.type_id, t.object_type, t.label, t.description, t.classname, 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 from
content_types t content_types t
where where
@ -128,7 +128,7 @@ association {
notAssociatedContentTypes.className = t.classname; notAssociatedContentTypes.className = t.classname;
notAssociatedContentTypes.ancestors = t.ancestors; notAssociatedContentTypes.ancestors = t.ancestors;
notAssociatedContentTypes.siblings = t.siblings; notAssociatedContentTypes.siblings = t.siblings;
notAssociatedContentTypes.isInternal = t.is_internal; notAssociatedContentTypes.mode = t.mode;
notAssociatedContentTypes.itemFormID = t.item_form_id; notAssociatedContentTypes.itemFormID = t.item_form_id;
} }
} }
@ -157,9 +157,9 @@ query registeredContentTypes {
select select
t.type_id, t.object_type, t.label, t.type_id, t.object_type, t.label,
t.description, t.classname, t.ancestors, t.siblings, 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 from content_types t
where t.is_internal = '0' where t.mode != 'I'
and exists (select 1 from content_section_type_map and exists (select 1 from content_section_type_map
where type_id = t.type_id) where type_id = t.type_id)
} map { } map {
@ -170,7 +170,7 @@ query registeredContentTypes {
type.className = t.classname; type.className = t.classname;
type.ancestors = t.ancestors; type.ancestors = t.ancestors;
type.siblings = t.siblings; type.siblings = t.siblings;
type.isInternal = t.is_internal; type.mode = t.mode;
type.itemFormID = t.item_form_id; type.itemFormID = t.item_form_id;
} }
} }

View File

@ -30,13 +30,28 @@ comment on column content_types.classname is '
comment on column content_types.label is ' comment on column content_types.label is '
The pretty name for this content type 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 An internal content type is one that is not user-defined and maintained
internally. A content type should be made internal under the following internally. A content type should be made internal under the following
two conditions: two conditions:
1) The object type needs to take advantage of content type services 1) The object type needs to take advantage of content type services
(i.e., versioning, categorization, lifecycle, workflow) that are already (i.e., versioning, categorization, lifecycle, workflow) that are already
implemented in CMS. implemented in CMS.
2) The content type cannot be explicitly registered to a content section. 2) The content type cannot be explicitly registered to a content section.
The Template content type is one such internal content type. 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.
'; ';

View File

@ -31,9 +31,12 @@ create table content_types (
classname varchar(200), classname varchar(200),
ancestors varchar(2000), ancestors varchar(2000),
siblings varchar(2000), siblings varchar(2000),
is_internal char(1) default '0' not null -- is_internal char(1) default '0' not null
constraint content_types_is_internal_ck -- constraint content_types_is_internal_ck
check ( is_internal in ('0', '1') ), -- 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 item_form_id integer
constraint content_types_form_id_fk references constraint content_types_form_id_fk references
bebop_components (component_id) bebop_components (component_id)

View File

@ -9,7 +9,7 @@
description="A generic address type" description="A generic address type"
objectType="com.arsdigita.cms.contenttypes.GenericAddress" objectType="com.arsdigita.cms.contenttypes.GenericAddress"
classname="com.arsdigita.cms.contenttypes.GenericAddress" classname="com.arsdigita.cms.contenttypes.GenericAddress"
isInternal="yes"> mode="hidden">
<ctd:authoring-kit <ctd:authoring-kit
createComponent="com.arsdigita.cms.ui.authoring.PageCreate"> createComponent="com.arsdigita.cms.ui.authoring.PageCreate">

View File

@ -4,12 +4,12 @@
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://xmlns.redhat.com/cms/content-types content-types.xsd"> xsi:schemaLocation="http://xmlns.redhat.com/cms/content-types content-types.xsd">
<ctd:content-type <ctd:content-type
label="GenericArticle" label="GenericArticle"
description="A generic article type" description="A generic article type"
objectType="com.arsdigita.cms.contenttypes.GenericArticle" objectType="com.arsdigita.cms.contenttypes.GenericArticle"
classname="com.arsdigita.cms.contenttypes.GenericArticle" classname="com.arsdigita.cms.contenttypes.GenericArticle"
isInternal="yes"> mode="hidden">
</ctd:content-type> </ctd:content-type>
</ctd:content-types> </ctd:content-types>

View File

@ -9,7 +9,7 @@
description="A generic Contact type" description="A generic Contact type"
objectType="com.arsdigita.cms.contenttypes.GenericContact" objectType="com.arsdigita.cms.contenttypes.GenericContact"
classname="com.arsdigita.cms.contenttypes.GenericContact" classname="com.arsdigita.cms.contenttypes.GenericContact"
isInternal="yes"> mode="hidden">
<ctd:authoring-kit <ctd:authoring-kit
createComponent="com.arsdigita.cms.ui.authoring.PageCreate"> createComponent="com.arsdigita.cms.ui.authoring.PageCreate">

View File

@ -10,7 +10,7 @@
description="A generic content type for organizations and projects." description="A generic content type for organizations and projects."
objectType="com.arsdigita.cms.contenttypes.GenericOrganizationalUnit" objectType="com.arsdigita.cms.contenttypes.GenericOrganizationalUnit"
classname= "com.arsdigita.cms.contenttypes.GenericOrganizationalUnit" classname= "com.arsdigita.cms.contenttypes.GenericOrganizationalUnit"
isInternal="yes"> mode="hidden">
<ctd:authoring-kit createComponent="com.arsdigita.cms.ui.authoring.PageCreate"> <ctd:authoring-kit createComponent="com.arsdigita.cms.ui.authoring.PageCreate">

View File

@ -9,7 +9,7 @@
description="A generic Person type" description="A generic Person type"
objectType="com.arsdigita.cms.contenttypes.GenericPerson" objectType="com.arsdigita.cms.contenttypes.GenericPerson"
classname="com.arsdigita.cms.contenttypes.GenericPerson" classname="com.arsdigita.cms.contenttypes.GenericPerson"
isInternal="yes"> mode="hidden">
<ctd:authoring-kit createComponent="com.arsdigita.cms.contenttypes.ui.GenericPersonCreate"> <ctd:authoring-kit createComponent="com.arsdigita.cms.contenttypes.ui.GenericPersonCreate">

View File

@ -7,7 +7,7 @@
description="Templates for rendering content items" description="Templates for rendering content items"
objectType="com.arsdigita.cms.Template" objectType="com.arsdigita.cms.Template"
classname="com.arsdigita.cms.Template" classname="com.arsdigita.cms.Template"
isInternal="yes"> mode="internal">
<ctd:authoring-kit> <ctd:authoring-kit>
<ctd:authoring-step <ctd:authoring-step

View File

@ -18,7 +18,6 @@
*/ */
package com.arsdigita.cms; package com.arsdigita.cms;
import com.arsdigita.categorization.Category; import com.arsdigita.categorization.Category;
import com.arsdigita.cms.dispatcher.ItemResolver; import com.arsdigita.cms.dispatcher.ItemResolver;
import com.arsdigita.cms.dispatcher.PageResolver; import com.arsdigita.cms.dispatcher.PageResolver;
@ -55,7 +54,6 @@ import org.apache.log4j.Logger;
import javax.servlet.http.HttpServletRequest; import javax.servlet.http.HttpServletRequest;
import java.math.BigDecimal; import java.math.BigDecimal;
/** /**
* <p>A content section represents a collection of content that is * <p>A content section represents a collection of content that is
* managed as a unit. Content sections typically correspond to major * managed as a unit. Content sections typically correspond to major
@ -94,12 +92,10 @@ import java.math.BigDecimal;
public class ContentSection extends Application { public class ContentSection extends Application {
private static final Logger s_log = Logger.getLogger(ContentSection.class); private static final Logger s_log = Logger.getLogger(ContentSection.class);
public static final String BASE_DATA_OBJECT_TYPE = 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 static final String PACKAGE_TYPE = "content-section";
public final static String STYLESHEET = "/packages/content-section/xsl/cms.xsl"; public final static String STYLESHEET = "/packages/content-section/xsl/cms.xsl";
protected static final String ID = "id"; protected static final String ID = "id";
protected static final String PACKAGE = "package"; protected static final String PACKAGE = "package";
protected static final String NAME = "label"; 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 ITEM_RESOLVER_CLASS = "itemResolverClass";
protected static final String TEMPLATE_RESOLVER_CLASS = "templateResolverClass"; protected static final String TEMPLATE_RESOLVER_CLASS = "templateResolverClass";
protected static final String XML_GENERATOR_CLASS = "xmlGeneratorClass"; protected static final String XML_GENERATOR_CLASS = "xmlGeneratorClass";
protected static final String CONTENT_TYPES = "associatedContentTypes"; protected static final String CONTENT_TYPES = "associatedContentTypes";
protected static final String CREATABLE_CONTENT_TYPES = protected static final String CREATABLE_CONTENT_TYPES =
"creatableContentTypes"; "creatableContentTypes";
protected static final String CONTENT_TYPES_NOT_ASSOC = protected static final String CONTENT_TYPES_NOT_ASSOC =
"notAssociatedContentTypes"; "notAssociatedContentTypes";
protected static final String LIFECYCLE_DEFINITIONS = protected static final String LIFECYCLE_DEFINITIONS =
"associatedLifecycleDefinitions"; "associatedLifecycleDefinitions";
protected static final String WF_TEMPLATES = "associatedWorkflowTemplates"; protected static final String WF_TEMPLATES = "associatedWorkflowTemplates";
private final static String ITEM_QUERY = "com.arsdigita.cms.ItemsInSection"; private final static String ITEM_QUERY = "com.arsdigita.cms.ItemsInSection";
private final static String SECTION_ID = "sectionId"; private final static String SECTION_ID = "sectionId";
private static final CMSConfig s_config = new CMSConfig(); private static final CMSConfig s_config = new CMSConfig();
static { static {
s_config.load(); s_config.load();
} }
// Cached properties // Cached properties
PageResolver m_pageResolver = null; PageResolver m_pageResolver = null;
ItemResolver m_itemResolver = null; ItemResolver m_itemResolver = null;
@ -144,7 +134,6 @@ public class ContentSection extends Application {
// super(BASE_DATA_OBJECT_TYPE); // super(BASE_DATA_OBJECT_TYPE);
// } // }
// //
/** /**
* Constructor re-creating a content section object by retrieving its data * Constructor re-creating a content section object by retrieving its data
* object by OID * object by OID
@ -177,7 +166,6 @@ public class ContentSection extends Application {
super(new OID(BASE_DATA_OBJECT_TYPE, id)); super(new OID(BASE_DATA_OBJECT_TYPE, id));
} }
public static CMSConfig getConfig() { public static CMSConfig getConfig() {
return s_config; return s_config;
} }
@ -186,6 +174,7 @@ public class ContentSection extends Application {
* @return the base PDL object type for this section. Child classes should * @return the base PDL object type for this section. Child classes should
* override this method to return the correct value * override this method to return the correct value
*/ */
@Override
public String getBaseDataObjectType() { public String getBaseDataObjectType() {
return BASE_DATA_OBJECT_TYPE; return BASE_DATA_OBJECT_TYPE;
} }
@ -197,6 +186,7 @@ public class ContentSection extends Application {
* @param key The name of the attribute * @param key The name of the attribute
* @return The value of the attribute * @return The value of the attribute
*/ */
@Override
public Object get(String key) { public Object get(String key) {
return super.get(key); return super.get(key);
} }
@ -208,6 +198,7 @@ public class ContentSection extends Application {
* @param key The name of the attribute * @param key The name of the attribute
* @param value The value of the attribute * @param value The value of the attribute
*/ */
@Override
public void set(String key, Object value) { public void set(String key, Object value) {
super.set(key, 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. * Sets the content section of the root folder to this section.
*/ */
@Override
protected void afterSave() { protected void afterSave() {
super.afterSave(); super.afterSave();
// Set the root folder's content section. // Set the root folder's content section.
@ -238,6 +230,7 @@ public class ContentSection extends Application {
* *
* @return A title * @return A title
*/ */
@Override
public String getDisplayName() { public String getDisplayName() {
return getName(); return getName();
} }
@ -290,7 +283,6 @@ public class ContentSection extends Application {
// public SiteNode getSiteNode() { // public SiteNode getSiteNode() {
// return getPackageInstance().getDefaultMountPoint(); // return getPackageInstance().getDefaultMountPoint();
// } // }
/** /**
* Finds the location of the content section. * Finds the location of the content section.
* *
@ -337,7 +329,6 @@ public class ContentSection extends Application {
// //
// return path.substring(0, path.length() - 1); // return path.substring(0, path.length() - 1);
// } // }
/** /**
* Get the folder in which all draft items are contained, directly or * Get the folder in which all draft items are contained, directly or
* indirectly. This folder will in general contain different kinds of * 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 // sub-items/folders. The next step is to recursively update items
// under the root folder when fetching "all items in a section" is // under the root folder when fetching "all items in a section" is
// implemented. // implemented.
if ( !isNew() ) { if (!isNew()) {
Folder oldRoot = getRootFolder(); Folder oldRoot = getRootFolder();
oldRoot.setContentSection(null); oldRoot.setContentSection(null);
oldRoot.save(); oldRoot.save();
@ -506,8 +497,8 @@ public class ContentSection extends Application {
if (m_pageResolver == null) { if (m_pageResolver == null) {
if (s_log.isDebugEnabled()) { if (s_log.isDebugEnabled()) {
s_log.debug("The page resolver hasn't been loaded yet; " + s_log.debug("The page resolver hasn't been loaded yet; "
"loading it now"); + "loading it now");
} }
try { try {
@ -677,13 +668,10 @@ public class ContentSection extends Application {
m_xmlGenerator = null; m_xmlGenerator = null;
} }
////////////////////////////// //////////////////////////////
// //
// Globalization. // Globalization.
// //
/** /**
* Gets the default Locale. This is used for translating or creating * Gets the default Locale. This is used for translating or creating
* content if no locale is specified. * content if no locale is specified.
@ -692,7 +680,7 @@ public class ContentSection extends Application {
*/ */
public Locale getDefaultLocale() { public Locale getDefaultLocale() {
DataObject obj = (DataObject) get(DEFAULT_LOCALE); DataObject obj = (DataObject) get(DEFAULT_LOCALE);
if ( obj == null ) { if (obj == null) {
return null; return null;
} else { } else {
return new Locale(obj); return new Locale(obj);
@ -748,7 +736,7 @@ public class ContentSection extends Application {
DataAssociation da = (DataAssociation) get(LOCALES); DataAssociation da = (DataAssociation) get(LOCALES);
locale.addToAssociation(da); locale.addToAssociation(da);
if ( isDefault ) { if (isDefault) {
setDefaultLocale(locale); setDefaultLocale(locale);
} }
} }
@ -764,22 +752,27 @@ public class ContentSection extends Application {
locale.removeFromAssociation(da); locale.removeFromAssociation(da);
} }
////////////////////////////// //////////////////////////////
// //
// Content types. // Content types.
// //
/** /**
* Get all user-defined content types registered to the content section. * Get all user-defined content types registered to the content section.
* *
* @return A ContentTypeCollection of registered content types * @return A ContentTypeCollection of registered content types
*/ */
public ContentTypeCollection getContentTypes() { public ContentTypeCollection getContentTypes() {
return getContentTypes(false);
}
public ContentTypeCollection getContentTypes(boolean hidden) {
DataAssociation da = (DataAssociation) get(CONTENT_TYPES); DataAssociation da = (DataAssociation) get(CONTENT_TYPES);
ContentTypeCollection types = new ContentTypeCollection(da); ContentTypeCollection types = new ContentTypeCollection(da);
// Filter out internal contentt types. // Filter out internal content types.
types.addFilter("isInternal = '0'"); types.addFilter("mode != 'I'");
if (!hidden) {
types.addFilter("mode != 'H'");
}
return types; return types;
} }
@ -793,10 +786,17 @@ public class ContentSection extends Application {
* 3) possess a non-empty creation component in its AuthoringKit. * 3) possess a non-empty creation component in its AuthoringKit.
*/ */
public ContentTypeCollection getCreatableContentTypes() { public ContentTypeCollection getCreatableContentTypes() {
return getCreatableContentTypes(false);
}
public ContentTypeCollection getCreatableContentTypes(boolean hidden) {
DataAssociation da = (DataAssociation) get(CREATABLE_CONTENT_TYPES); DataAssociation da = (DataAssociation) get(CREATABLE_CONTENT_TYPES);
ContentTypeCollection types = new ContentTypeCollection(da); ContentTypeCollection types = new ContentTypeCollection(da);
// Filter out internal content types. // Filter out internal content types.
types.addFilter("isInternal = '0'"); types.addFilter("mode != 'I'");
if (!hidden) {
types.addFilter("mode != 'H'");
}
return types; return types;
} }
@ -807,7 +807,7 @@ public class ContentSection extends Application {
* @param type The content type * @param type The content type
*/ */
public void addContentType(ContentType type) { public void addContentType(ContentType type) {
if ( ! hasContentType(type) ) { if (!hasContentType(type)) {
DataAssociation da = (DataAssociation) get(CONTENT_TYPES); DataAssociation da = (DataAssociation) get(CONTENT_TYPES);
type.addToAssociation(da); type.addToAssociation(da);
} }
@ -835,7 +835,7 @@ public class ContentSection extends Application {
DataAssociation da = (DataAssociation) get(CONTENT_TYPES); DataAssociation da = (DataAssociation) get(CONTENT_TYPES);
DataAssociationCursor cursor = da.cursor(); DataAssociationCursor cursor = da.cursor();
cursor.addEqualsFilter(ID, type.getID()); 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); DataAssociation da = (DataAssociation) get(CONTENT_TYPES_NOT_ASSOC);
ContentTypeCollection types = new ContentTypeCollection(da); ContentTypeCollection types = new ContentTypeCollection(da);
// Filter out internal content types. // Filter out internal content types.
types.addFilter("isInternal = '0'"); types.addFilter("mode != 'I'");
return types; return types;
} }
////////////////////////////// //////////////////////////////
// //
// Lifecycle definitions. // Lifecycle definitions.
// //
/** /**
* Get all lifecycle definitions registered to the content section. * Get all lifecycle definitions registered to the content section.
* *
@ -866,8 +864,7 @@ public class ContentSection extends Application {
* lifecycle definition. * lifecycle definition.
*/ */
public LifecycleDefinitionCollection getLifecycleDefinitions() { public LifecycleDefinitionCollection getLifecycleDefinitions() {
return return new LifecycleDefinitionCollection(getLifecycleDefinitionsAssociation());
new LifecycleDefinitionCollection(getLifecycleDefinitionsAssociation());
} }
/** /**
@ -892,12 +889,10 @@ public class ContentSection extends Application {
return (DataAssociation) get(LIFECYCLE_DEFINITIONS); return (DataAssociation) get(LIFECYCLE_DEFINITIONS);
} }
////////////////////////////// //////////////////////////////
// //
// Workflow templates. // Workflow templates.
// //
/** /**
* Get all workflow templates registered to the content section. * Get all workflow templates registered to the content section.
* *
@ -931,13 +926,10 @@ public class ContentSection extends Application {
return (DataAssociation) get(WF_TEMPLATES); return (DataAssociation) get(WF_TEMPLATES);
} }
////////////////////////////// //////////////////////////////
// //
// Finding a content section. // Finding a content section.
// //
/** /**
* Looks up the section given the SiteNode. * Looks up the section given the SiteNode.
* *
@ -947,9 +939,9 @@ public class ContentSection extends Application {
* @post ( return != null ) * @post ( return != null )
*/ */
public static ContentSection getSectionFromNode(SiteNode node) public static ContentSection getSectionFromNode(SiteNode node)
throws DataObjectNotFoundException { throws DataObjectNotFoundException {
return (ContentSection)retrieveApplicationForSiteNode(node); return (ContentSection) retrieveApplicationForSiteNode(node);
// BigDecimal sectionId = null; // BigDecimal sectionId = null;
// //
@ -991,7 +983,6 @@ public class ContentSection extends Application {
// } // }
// return section; // return section;
// } // }
/** /**
* Get the content section for an item. * Get the content section for an item.
* *
@ -1003,7 +994,7 @@ public class ContentSection extends Application {
* @return The content section of an item * @return The content section of an item
*/ */
public static ContentSection getContentSection(ContentItem item) public static ContentSection getContentSection(ContentItem item)
throws DataObjectNotFoundException { throws DataObjectNotFoundException {
return item.getContentSection(); return item.getContentSection();
} }
@ -1018,7 +1009,7 @@ public class ContentSection extends Application {
* @return The content section of the folder * @return The content section of the folder
*/ */
public static ContentSection getContentSection(Folder folder) public static ContentSection getContentSection(Folder folder)
throws DataObjectNotFoundException { throws DataObjectNotFoundException {
return folder.getContentSection(); return folder.getContentSection();
} }
@ -1029,13 +1020,10 @@ public class ContentSection extends Application {
* @return A collection of content sections * @return A collection of content sections
*/ */
public static ContentSectionCollection getAllSections() { public static ContentSectionCollection getAllSections() {
DataCollection da = SessionManager.getSession().retrieve DataCollection da = SessionManager.getSession().retrieve(BASE_DATA_OBJECT_TYPE);
(BASE_DATA_OBJECT_TYPE);
return new ContentSectionCollection(da); return new ContentSectionCollection(da);
} }
/** /**
* Creates a content section of the given name using default values and * Creates a content section of the given name using default values and
* returns it. * returns it.
@ -1055,27 +1043,20 @@ public class ContentSection extends Application {
String xgc = "com.arsdigita.cms.dispatcher.SimpleXMLGenerator"; String xgc = "com.arsdigita.cms.dispatcher.SimpleXMLGenerator";
String trc = "com.arsdigita.cms.dispatcher.DefaultTemplateResolver"; String trc = "com.arsdigita.cms.dispatcher.DefaultTemplateResolver";
ContentSection section = ContentSection.create( name, ContentSection section = ContentSection.create(name,
folder, folder,
category, category,
staff, staff,
prc, prc,
irc, irc,
xgc, xgc,
trc); trc);
// Set the default context on the root folder to // Set the default context on the root folder to
// the content section // the content section
PermissionService.setContext(folder.getOID(), section.getOID()); PermissionService.setContext(folder.getOID(), section.getOID());
createDefaultResources(section); createDefaultResources(section);
// Left over, see above
// }
// };
// rootExcursion.run();
//
// //now retrieve the created content section and return it
// return (ContentSection) Application.retrieveApplicationForPath("/" + name + "/");
return section; return section;
} }
@ -1093,22 +1074,21 @@ public class ContentSection extends Application {
* @return The new content section * @return The new content section
*/ */
public static ContentSection create(String name, public static ContentSection create(String name,
Folder folder, Folder folder,
Category category, Category category,
Group staff, Group staff,
String prc, String prc,
String irc, String irc,
String xgc) { String xgc) {
return ContentSection.create( return ContentSection.create(
name, name,
folder, folder,
category, category,
staff, staff,
prc, prc,
irc, irc,
xgc, xgc,
"com.arsdigita.cms.dispatcher.DefaultTemplateResolver" "com.arsdigita.cms.dispatcher.DefaultTemplateResolver");
);
} }
/** /**
@ -1126,13 +1106,13 @@ public class ContentSection extends Application {
* @return The new content section * @return The new content section
*/ */
public static ContentSection create(String name, public static ContentSection create(String name,
Folder folder, Folder folder,
Category category, Category category,
Group staff, Group staff,
String prc, String prc,
String irc, String irc,
String xgc, String xgc,
String trc) { String trc) {
// This could be moved out of here and into the Installer // This could be moved out of here and into the Installer
// (passing it into a modified version of create) // (passing it into a modified version of create)
@ -1143,28 +1123,26 @@ public class ContentSection extends Application {
// Create template root folder. // Create template root folder.
Folder templates = new Folder(); Folder templates = new Folder();
templates.setName("templates"); templates.setName("templates");
templates.setLabel( (String) GlobalizationUtil.globalize( templates.setLabel((String) GlobalizationUtil.globalize(
"cms.templates").localize()); "cms.templates").localize());
templates.save(); templates.save();
//create and initialize the content section application //create and initialize the content section application
ContentSection section = (ContentSection) Application.createApplication ContentSection section = (ContentSection) Application.createApplication(BASE_DATA_OBJECT_TYPE, name, name, null);
(BASE_DATA_OBJECT_TYPE, name, name, null ); section.initialize(name,
section.initialize( name, folder,
folder, category,
category, staff,
staff, prc,
prc, irc,
irc, xgc,
xgc, trc,
trc, templates,
templates, viewers);
viewers);
return section; return section;
} }
/** /**
* Creates and maps default resources to the content 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 = r.createInstance(section, "admin/index");
rm.save(); 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 = rt.createInstance("com.arsdigita.cms.user.ItemIndexPage");
//r.save(); //r.save();
//rm = r.createInstance(section, "index"); //rm = r.createInstance(section, "index");
@ -1207,8 +1185,8 @@ public class ContentSection extends Application {
protected static Folder createRootFolder(String name) { protected static Folder createRootFolder(String name) {
Folder root = new Folder(); Folder root = new Folder();
root.setName("/"); root.setName("/");
root.setLabel( (String) GlobalizationUtil.globalize( root.setLabel((String) GlobalizationUtil.globalize(
"cms.installer.root_folder").localize()); "cms.installer.root_folder").localize());
root.save(); root.save();
return root; return root;
} }
@ -1239,7 +1217,6 @@ public class ContentSection extends Application {
return staff; return staff;
} }
/** /**
* Initialize a newly created content section. * Initialize a newly created content section.
* *
@ -1254,16 +1231,16 @@ public class ContentSection extends Application {
* @return The new content section * @return The new content section
*/ */
public ContentSection initialize( public ContentSection initialize(
String name, String name,
Folder folder, Folder folder,
Category category, Category category,
Group staff, Group staff,
String prc, String prc,
String irc, String irc,
String xgc, String xgc,
String trc, String trc,
Folder templates, Folder templates,
Group viewers) { Group viewers) {
setName(name); setName(name);
//setPackageInstance(pkg); //setPackageInstance(pkg);
@ -1281,7 +1258,6 @@ public class ContentSection extends Application {
return this; return this;
} }
/** /**
* Fetches the child items of this section. An item is defined to be "in" * 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 * 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() { public String getStylesheetPath() {
return STYLESHEET; return STYLESHEET;
} }
} }

View File

@ -65,7 +65,7 @@ public class ContentType extends ACSObject {
public static final String LABEL = "label"; public static final String LABEL = "label";
public static final String DESCRIPTION = "description"; public static final String DESCRIPTION = "description";
public static final String CLASSNAME = "className"; 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 AUTHORING_KIT = "authoringKit";
public static final String ITEM_FORM_ID = "itemFormID"; public static final String ITEM_FORM_ID = "itemFormID";
public static final String ITEM_FORM = "itemForm"; public static final String ITEM_FORM = "itemForm";
@ -123,8 +123,8 @@ public class ContentType extends ACSObject {
@Override @Override
protected void beforeSave() { protected void beforeSave() {
if (isInternal() == null) { if (getMode() == null) {
setInternal(false); setMode("default");
} }
super.beforeSave(); super.beforeSave();
} }
@ -224,17 +224,37 @@ public class ContentType extends ACSObject {
* otherwise. * otherwise.
*/ */
public Boolean isInternal() { public Boolean isInternal() {
return (Boolean) get(IS_INTERNAL); return "I".equalsIgnoreCase((String) get(MODE));
} }
/** /**
* Make this content type internal or not. * <p>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, * @return Boolean.TRUE if this content type is internal, Boolean.FALSE
* false otherwise * otherwise.
*/ */
public void setInternal(boolean isInternal) { public Boolean isHidden() {
set(IS_INTERNAL, (isInternal ? Boolean.TRUE : Boolean.FALSE)); 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 * @return A collection of all content types
*/ */
public static ContentTypeCollection getAllContentTypes() { 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 * @return A collection of user-defined content types
*/ */
public static ContentTypeCollection getUserDefinedContentTypes() { 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. * 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); DataCollection da = SessionManager.getSession().retrieve(BASE_DATA_OBJECT_TYPE);
ContentTypeCollection types = new ContentTypeCollection(da); ContentTypeCollection types = new ContentTypeCollection(da);
if (!internal) { if (!internal) {
types.addFilter("isInternal = '0'"); types.addFilter("mode != 'I'");
}
if (!hidden) {
types.addFilter("mode != 'H'");
} }
return types; return types;
} }
@ -545,8 +583,7 @@ public class ContentType extends ACSObject {
ctc.addFilter(or); ctc.addFilter(or);
return ctc; return ctc;
} }
private static List s_xsl = new ArrayList();
private static List s_xsl = new ArrayList();
/** /**
* NB this interface is liable to change. * NB this interface is liable to change.

View File

@ -61,6 +61,7 @@ import com.arsdigita.xml.XML;
// import java.io.IOException; // import java.io.IOException;
// import java.io.InputStream; // import java.io.InputStream;
// import java.util.HashMap; // import java.util.HashMap;
import java.util.ArrayList;
import java.util.Iterator; import java.util.Iterator;
import java.util.List; import java.util.List;
// import javax.xml.parsers.ParserConfigurationException; // import javax.xml.parsers.ParserConfigurationException;
@ -72,7 +73,6 @@ import java.util.List;
import org.apache.log4j.Logger; import org.apache.log4j.Logger;
// Migration status // Migration status
// //
// The module in its complete version (i.e. all method invocations in run() // The module in its complete version (i.e. all method invocations in run()
@ -83,8 +83,6 @@ import org.apache.log4j.Logger;
// //
// Next Try // Next Try
// Refactor using legacy compatible web/Application and ApplicationSetup // Refactor using legacy compatible web/Application and ApplicationSetup
/** /**
* <p>Executes nonrecurring at install time and loads (installs and initializes) * <p>Executes nonrecurring at install time and loads (installs and initializes)
* the Content Management System module,including the Content Center, CMS Service * 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 */ /** Creates a s_logging category with name = full name of class */
private static final Logger s_log = Logger.getLogger(Loader.class); private static final Logger s_log = Logger.getLogger(Loader.class);
// Load main CMS configuration file // Load main CMS configuration file
private static final LoaderConfig s_conf = new LoaderConfig(); private static final LoaderConfig s_conf = new LoaderConfig();
// static { // requirred to actually read the config file // static { // requirred to actually read the config file
// s_config.load(); // s_config.load();
// } // }
/** /**
* Constant string used as key for creating CMS (content-section) as a * Constant string used as key for creating CMS (content-section) as a
* legacy application. * legacy application.
@ -139,7 +134,6 @@ public class Loader extends PackageLoader {
*/ */
private final static String CMS_STYLESHEET = private final static String CMS_STYLESHEET =
"/packages/content-section/xsl/cms.xsl"; "/packages/content-section/xsl/cms.xsl";
// /** // /**
// * Constant string used as key for creating Workspace (content-center) as a // * Constant string used as key for creating Workspace (content-center) as a
// * legacy application. // * legacy application.
@ -151,7 +145,7 @@ public class Loader extends PackageLoader {
* to a legacy application). * to a legacy application).
*/ */
private static final String WORKSPACE_DISPATCHER_CLASS = private static final String WORKSPACE_DISPATCHER_CLASS =
"com.arsdigita.cms.dispatcher.ContentCenterDispatcher"; "com.arsdigita.cms.dispatcher.ContentCenterDispatcher";
// To be updated soon... // To be updated soon...
// "com.arsdigita.dispatcher.DefaultPackageDispatcher"; // "com.arsdigita.dispatcher.DefaultPackageDispatcher";
/** /**
@ -160,7 +154,6 @@ public class Loader extends PackageLoader {
*/ */
private final static String WORKSPACE_STYLESHEET = private final static String WORKSPACE_STYLESHEET =
"/packages/content-section/xsl/content-center.xsl"; "/packages/content-section/xsl/content-center.xsl";
/** /**
* Name of the CMS service package instance, i.e. its URL. * Name of the CMS service package instance, i.e. its URL.
*/ */
@ -170,9 +163,7 @@ public class Loader extends PackageLoader {
// * legacy application. // * legacy application.
// */ // */
// public final static String SERVICE_PACKAGE_KEY = "cms-service"; // public final static String SERVICE_PACKAGE_KEY = "cms-service";
private ArrayList m_content_type_list = new ArrayList();
/** /**
* Standard constructor. * Standard constructor.
@ -183,11 +174,11 @@ public class Loader extends PackageLoader {
s_log.debug("CMS.loader (Constructor) completed"); s_log.debug("CMS.loader (Constructor) completed");
} }
public void run(final ScriptContext ctx) { public void run(final ScriptContext ctx) {
s_log.debug("CMS.loader.run() invoked"); s_log.debug("CMS.loader.run() invoked");
new KernelExcursion() { new KernelExcursion() {
public void excurse() { public void excurse() {
setEffectiveParty(Kernel.getSystemParty()); setEffectiveParty(Kernel.getSystemParty());
@ -214,7 +205,7 @@ public class Loader extends PackageLoader {
// 5) load content type definition(s) // 5) load content type definition(s)
// Used to be step 2 in former enterprise.init file // 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 // 6) Load CMS (content section) package application instance
// Used to be step 4 in former enterprise.init file // Used to be step 4 in former enterprise.init file
@ -232,7 +223,7 @@ public class Loader extends PackageLoader {
//ContentSectionsPortlet.loadPortletType(); //ContentSectionsPortlet.loadPortletType();
TaskPortlet.loadPortletType(); TaskPortlet.loadPortletType();
} }
}.run(); }.run();
} }
@ -291,8 +282,6 @@ public class Loader extends PackageLoader {
// //
// s_log.debug("Done creating the CMS package type."); // s_log.debug("Done creating the CMS package type.");
// } // }
/** /**
* Loads and instantiates the Workspace package (content-center) in the * Loads and instantiates the Workspace package (content-center) in the
* database using old style application. * database using old style application.
@ -305,14 +294,14 @@ public class Loader extends PackageLoader {
try { try {
// workspaceInstaller.createPackageType(); // workspaceInstaller.createPackageType();
PackageType type = PackageType.create(CMS.WORKSPACE_PACKAGE_KEY, PackageType type = PackageType.create(CMS.WORKSPACE_PACKAGE_KEY,
"Content Center", "Content Center",
"Content Centers", "Content Centers",
"http://cms-workspace.arsdigita.com/"); "http://cms-workspace.arsdigita.com/");
type.setDispatcherClass(WORKSPACE_DISPATCHER_CLASS); type.setDispatcherClass(WORKSPACE_DISPATCHER_CLASS);
// Register a stylesheet to the Content Center package. // Register a stylesheet to the Content Center package.
Stylesheet ss = Stylesheet ss =
Stylesheet.createStylesheet(WORKSPACE_STYLESHEET); Stylesheet.createStylesheet(WORKSPACE_STYLESHEET);
ss.save(); ss.save();
type.addStylesheet(ss); type.addStylesheet(ss);
@ -330,22 +319,21 @@ public class Loader extends PackageLoader {
// SiteNode node = SiteNode.createSiteNode(CMS.WORKSPACE_PACKAGE_KEY, // SiteNode node = SiteNode.createSiteNode(CMS.WORKSPACE_PACKAGE_KEY,
// SiteNode.getRootSiteNode()); // SiteNode.getRootSiteNode());
SiteNode node = SiteNode.createSiteNode(CMS.WORKSPACE_PACKAGE_KEY, SiteNode node = SiteNode.createSiteNode(CMS.WORKSPACE_PACKAGE_KEY,
SiteNode.getRootSiteNode()); SiteNode.getRootSiteNode());
node.mountPackage(instance); node.mountPackage(instance);
node.save(); node.save();
// m_workspaceURL == WORKSPACE_PACKAGE_KEY // m_workspaceURL == WORKSPACE_PACKAGE_KEY
// workspaceInstaller.mountPackageInstance(instance, m_workspaceURL); // workspaceInstaller.mountPackageInstance(instance, m_workspaceURL);
// workspaceInstaller.mountPackageInstance(instance, CMS.WORKSPACE_PACKAGE_KEY); // workspaceInstaller.mountPackageInstance(instance, CMS.WORKSPACE_PACKAGE_KEY);
} catch (DataObjectNotFoundException e) { } catch (DataObjectNotFoundException e) {
throw new ConfigError( throw new ConfigError(
"Failed to initialize the Workspace package: "); "Failed to initialize the Workspace package: ");
} }
} }
/** /**
* Loads and instantiates the Workspace package (content-center) in the * Loads and instantiates the Workspace package (content-center) in the
* database. * database.
@ -360,22 +348,24 @@ public class Loader extends PackageLoader {
// create application type // create application type
ApplicationSetup appsetup = new ApplicationSetup(s_log); ApplicationSetup appsetup = new ApplicationSetup(s_log);
// new style properties // new style properties
appsetup.setApplicationObjectType( Workspace.BASE_DATA_OBJECT_TYPE ); appsetup.setApplicationObjectType(Workspace.BASE_DATA_OBJECT_TYPE);
appsetup.setTitle( Workspace.INSTANCE_NAME ); // same as for instance appsetup.setTitle(Workspace.INSTANCE_NAME); // same as for instance
// there is only one // there is only one
appsetup.setDescription("The content center workspace for content creators."); appsetup.setDescription("The content center workspace for content creators.");
// old style / legacy compatible properties // old style / legacy compatible properties
appsetup.setKey( Workspace.PACKAGE_KEY ); appsetup.setKey(Workspace.PACKAGE_KEY);
appsetup.setDispatcherClass( Workspace.DISPATCHER_CLASS ); appsetup.setDispatcherClass(Workspace.DISPATCHER_CLASS);
// should not be needed anymore, stypesheets handled by StylesheetResolver // should not be needed anymore, stypesheets handled by StylesheetResolver
appsetup.setStylesheet( Workspace.STYLESHEET ); appsetup.setStylesheet(Workspace.STYLESHEET);
appsetup.setSingleton(true); appsetup.setSingleton(true);
appsetup.setPortalApplication(false); appsetup.setPortalApplication(false);
appsetup.setInstantiator(new ACSObjectInstantiator() { 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(); ApplicationType workspaceType = appsetup.run();
workspaceType.save(); workspaceType.save();
@ -383,16 +373,15 @@ public class Loader extends PackageLoader {
// create legacy compatible application instance, // create legacy compatible application instance,
// old-style package key used as url fragment where to install the instance // old-style package key used as url fragment where to install the instance
Workspace app = (Workspace) Application.createApplication( Workspace app = (Workspace) Application.createApplication(
workspaceType, // type workspaceType, // type
Workspace.PACKAGE_KEY, // url fragment Workspace.PACKAGE_KEY, // url fragment
Workspace.INSTANCE_NAME,// title Workspace.INSTANCE_NAME,// title
null); // parent null); // parent
app.save(); app.save();
s_log.debug("Done loading CMS Workspace."); s_log.debug("Done loading CMS Workspace.");
} }
/** /**
* CMS Service application is used by the Content Management System as a * CMS Service application is used by the Content Management System as a
* store for global resources and assets. * store for global resources and assets.
@ -402,35 +391,32 @@ public class Loader extends PackageLoader {
private void loadServicePackage() { private void loadServicePackage() {
s_log.debug("Loading CMS Servce Package..."); s_log.debug("Loading CMS Servce Package...");
try { try {
// from ServiceInstaller.createPackageType(); // from ServiceInstaller.createPackageType();
PackageType type = PackageType.create PackageType type = PackageType.create(CMS.SERVICE_PACKAGE_KEY,
(CMS.SERVICE_PACKAGE_KEY, "Content Management System Services",
"Content Management System Services", "Content Management System Services",
"Content Management System Services", "http://cms-service.arsdigita.com/");
"http://cms-service.arsdigita.com/"); type.setDispatcherClass(
type.setDispatcherClass( "com.arsdigita.cms.dispatcher.ServiceDispatcher");
"com.arsdigita.cms.dispatcher.ServiceDispatcher"); type.save();
type.save();
// from PackageInstance instance = ServiceInstaller.createPackageInstance(); // from PackageInstance instance = ServiceInstaller.createPackageInstance();
type = PackageType.findByKey(CMS.SERVICE_PACKAGE_KEY); type = PackageType.findByKey(CMS.SERVICE_PACKAGE_KEY);
PackageInstance instance = type.createInstance(CMS.SERVICE_PACKAGE_KEY); PackageInstance instance = type.createInstance(CMS.SERVICE_PACKAGE_KEY);
instance.save(); instance.save();
// from ServiceInstaller.mountPackageInstance(instance, url); // from ServiceInstaller.mountPackageInstance(instance, url);
SiteNode node = SiteNode.createSiteNode(SERVICE_URL, SiteNode node = SiteNode.createSiteNode(SERVICE_URL,
SiteNode.getRootSiteNode()); SiteNode.getRootSiteNode());
node.mountPackage(instance); node.mountPackage(instance);
node.save(); node.save();
} catch (DataObjectNotFoundException e) { } catch (DataObjectNotFoundException e) {
throw new ConfigError throw new ConfigError("Failed to initialize CMS global services package.");
("Failed to initialize CMS global services package."); }
}
} }
/** /**
* CMS Service application is used by the Content Management System as a * CMS Service application is used by the Content Management System as a
* store for global resources and assets. * store for global resources and assets.
@ -447,22 +433,24 @@ public class Loader extends PackageLoader {
// create application type // create application type
ApplicationSetup appsetup = new ApplicationSetup(s_log); ApplicationSetup appsetup = new ApplicationSetup(s_log);
// new style properties // new style properties
appsetup.setApplicationObjectType( Service.BASE_DATA_OBJECT_TYPE ); appsetup.setApplicationObjectType(Service.BASE_DATA_OBJECT_TYPE);
appsetup.setTitle( Service.INSTANCE_NAME ); // same as for instance appsetup.setTitle(Service.INSTANCE_NAME); // same as for instance
// there is only one // there is only one
appsetup.setDescription("Services to store global resources and assets."); appsetup.setDescription("Services to store global resources and assets.");
// old style / legacy compatible properties // old style / legacy compatible properties
appsetup.setKey( Service.PACKAGE_KEY ); appsetup.setKey(Service.PACKAGE_KEY);
appsetup.setDispatcherClass( Service.DISPATCHER_CLASS ); appsetup.setDispatcherClass(Service.DISPATCHER_CLASS);
// Service has no UI, therefore no stylesheet available // Service has no UI, therefore no stylesheet available
// appsetup.setStylesheet( Workspace.STYLESHEET ); // appsetup.setStylesheet( Workspace.STYLESHEET );
appsetup.setSingleton(true); appsetup.setSingleton(true);
appsetup.setPortalApplication(false); appsetup.setPortalApplication(false);
appsetup.setInstantiator(new ACSObjectInstantiator() { 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(); ApplicationType serviceType = appsetup.run();
serviceType.save(); serviceType.save();
@ -470,16 +458,15 @@ public class Loader extends PackageLoader {
// create legacy compatible application instance, // create legacy compatible application instance,
// old-style package key used as url fragment where to install the instance // old-style package key used as url fragment where to install the instance
Service app = (Service) Application.createApplication( Service app = (Service) Application.createApplication(
serviceType, // type serviceType, // type
Service.PACKAGE_KEY, // url fragment Service.PACKAGE_KEY, // url fragment
Service.INSTANCE_NAME,// title Service.INSTANCE_NAME,// title
null); // parent null); // parent
app.save(); app.save();
s_log.debug("Done creating CMS Service Package."); s_log.debug("Done creating CMS Service Package.");
} }
/** /**
* Load an content section application type and an initial default * Load an content section application type and an initial default
* content-section instance as specified in LoaderConfig. * content-section instance as specified in LoaderConfig.
@ -505,8 +492,9 @@ public class Loader extends PackageLoader {
appType.setPortalApplication(false); appType.setPortalApplication(false);
//setup.setDispatcherClass(ContentItemDispatcher.class.getName()); //setup.setDispatcherClass(ContentItemDispatcher.class.getName());
appType.setStylesheet(CMS_STYLESHEET); // by default: /pack./c-s/xml/cms.xml 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() { appType.setInstantiator(new ACSObjectInstantiator() {
@Override @Override
public DomainObject doNewInstance(DataObject dataObject) { public DomainObject doNewInstance(DataObject dataObject) {
return new ContentSection(dataObject); return new ContentSection(dataObject);
@ -547,16 +535,17 @@ public class Loader extends PackageLoader {
// registers predefined "Authoring", "Approval", "Publishing' steps // registers predefined "Authoring", "Approval", "Publishing' steps
setup.registerWorkflowTemplates(); setup.registerWorkflowTemplates();
setup.registerResolvers(s_conf.getItemResolverClass(), setup.registerResolvers(s_conf.getItemResolverClass(),
s_conf.getTemplateResolverClass() ); s_conf.getTemplateResolverClass());
// XML generator class, set autonomously by ContentSection.create() // XML generator class, set autonomously by ContentSection.create()
setup.registerContentTypes(m_content_type_list);
setup.registerContentTypes(s_conf.getContentSectionsContentTypes()); setup.registerContentTypes(s_conf.getContentSectionsContentTypes());
// Section specific categories, usually not used. // Section specific categories, usually not used.
// During initial load at install time nor used at all! // During initial load at install time nor used at all!
// default value is false so no categories get loaded. // default value is false so no categories get loaded.
if (s_conf.getUseSectionCategories()) { if (s_conf.getUseSectionCategories()) {
Iterator files = ((List) s_conf.getCategoryFileList()).iterator(); Iterator files = ((List) s_conf.getCategoryFileList()).iterator();
while ( files.hasNext() ) { while (files.hasNext()) {
setup.registerCategories((String) files.next()); setup.registerCategories((String) files.next());
} }
} }
@ -569,7 +558,7 @@ public class Loader extends PackageLoader {
// setup.loadTaskAlerts(s_conf.getTaskAlerts()); // setup.loadTaskAlerts(s_conf.getTaskAlerts());
section.save(); //persists any changes in the database (DomainObject) 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) { private void loadContentTypeDefinitions(List ctDefFiles) {
s_log.debug("Loading content type definitions ..."); s_log.debug("Loading content type definitions ...");
if ( ctDefFiles != null) { if (ctDefFiles != null) {
XMLContentTypeHandler handler = new XMLContentTypeHandler();
Iterator i = ctDefFiles.iterator(); Iterator i = ctDefFiles.iterator();
while (i.hasNext()) { while (i.hasNext()) {
String xmlFile = (String)i.next(); String xmlFile = (String) i.next();
s_log.debug("Processing contentTypes in: " + xmlFile); 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."); s_log.debug("Done loading content type definitions.");
} }
/** /**
* Integrates the CMS privileges into the Core permision system. * 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); DataQuery dq = SessionManager.getSession().retrieveQuery(CMS_PRIVILEGES);
try { try {
while ( dq.next() ) { while (dq.next()) {
String privilege = (String) dq.get(PRIVILEGE); String privilege = (String) dq.get(PRIVILEGE);
s_log.debug(String.format("privilege = %s", privilege)); s_log.debug(String.format("privilege = %s", privilege));
if ( PrivilegeDescriptor.get(privilege) == null ) { if (PrivilegeDescriptor.get(privilege) == null) {
PrivilegeDescriptor.createPrivilege(privilege); PrivilegeDescriptor.createPrivilege(privilege);
} }
} }
@ -646,6 +645,4 @@ public class Loader extends PackageLoader {
} }
s_log.debug("Done creating Privileges."); s_log.debug("Done creating Privileges.");
} }
} }

View File

@ -33,20 +33,14 @@ import com.arsdigita.cms.util.GlobalizationUtil;
import com.arsdigita.cms.workflow.CMSTask; import com.arsdigita.cms.workflow.CMSTask;
import com.arsdigita.cms.workflow.CMSTaskType; import com.arsdigita.cms.workflow.CMSTaskType;
import com.arsdigita.domain.DataObjectNotFoundException; import com.arsdigita.domain.DataObjectNotFoundException;
// import com.arsdigita.domain.DomainObject;
import com.arsdigita.initializer.InitializationException; import com.arsdigita.initializer.InitializationException;
// import com.arsdigita.kernel.ACSObjectInstantiator;
import com.arsdigita.kernel.Party; import com.arsdigita.kernel.Party;
import com.arsdigita.kernel.PartyCollection; import com.arsdigita.kernel.PartyCollection;
import com.arsdigita.kernel.Role; import com.arsdigita.kernel.Role;
import com.arsdigita.kernel.permissions.PermissionService; import com.arsdigita.kernel.permissions.PermissionService;
import com.arsdigita.kernel.permissions.PrivilegeDescriptor; 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.Assert;
import com.arsdigita.util.UncheckedWrapperException; import com.arsdigita.util.UncheckedWrapperException;
// import com.arsdigita.web.ApplicationSetup;
import com.arsdigita.workflow.simple.WorkflowTemplate; import com.arsdigita.workflow.simple.WorkflowTemplate;
import com.arsdigita.xml.XML; import com.arsdigita.xml.XML;
@ -59,7 +53,6 @@ import java.util.EmptyStackException;
import java.util.HashMap; import java.util.HashMap;
import java.util.Iterator; import java.util.Iterator;
import java.util.List; import java.util.List;
// import java.util.NoSuchElementException;
import java.util.Stack; import java.util.Stack;
import org.apache.log4j.Logger; import org.apache.log4j.Logger;
@ -78,13 +71,11 @@ import org.xml.sax.helpers.DefaultHandler;
public final class ContentSectionSetup { public final class ContentSectionSetup {
private static Logger s_log = Logger.getLogger(ContentSectionSetup.class); private static Logger s_log = Logger.getLogger(ContentSectionSetup.class);
private final static String STYLESHEET = "/packages/content-section/xsl/cms.xsl"; private final static String STYLESHEET = "/packages/content-section/xsl/cms.xsl";
private HashMap m_tasks = new HashMap(); private HashMap m_tasks = new HashMap();
private LifecycleDefinition m_lcd; private LifecycleDefinition m_lcd;
private WorkflowTemplate m_wf; private WorkflowTemplate m_wf;
final ContentSection m_section; final ContentSection m_section;
/** /**
* Constructor. Using this constructor the content section has to be * Constructor. Using this constructor the content section has to be
@ -98,21 +89,19 @@ public final class ContentSectionSetup {
m_section = section; m_section = section;
} }
/** /**
* Wrapper class to create and configure a content section instance * Wrapper class to create and configure a content section instance
* in one step. * in one step.
* *
*/ */
public static void setupContentSectionAppInstance(String name, public static void setupContentSectionAppInstance(String name,
List staffGroup, List staffGroup,
Boolean isPubliclyViewable, Boolean isPubliclyViewable,
String itemResolverClassName, String itemResolverClassName,
String templateResolverClassName, String templateResolverClassName,
List sectionContentTypes, List sectionContentTypes,
Boolean useSectionCategories, Boolean useSectionCategories,
List categoryFileList List categoryFileList) {
) {
s_log.info("Creating content section on /" + name); s_log.info("Creating content section on /" + name);
ContentSection section = ContentSection.create(name); ContentSection section = ContentSection.create(name);
@ -123,7 +112,7 @@ public final class ContentSectionSetup {
setup.registerViewers(isPubliclyViewable); setup.registerViewers(isPubliclyViewable);
setup.registerPublicationCycles(); setup.registerPublicationCycles();
setup.registerWorkflowTemplates(); setup.registerWorkflowTemplates();
setup.registerResolvers( itemResolverClassName,templateResolverClassName ); setup.registerResolvers(itemResolverClassName, templateResolverClassName);
// setup.registerContentTypes((List)m_conf.getParameter(TYPES)); // setup.registerContentTypes((List)m_conf.getParameter(TYPES));
setup.registerContentTypes(sectionContentTypes); setup.registerContentTypes(sectionContentTypes);
@ -131,7 +120,7 @@ public final class ContentSectionSetup {
// section specific categories, usually not used. // section specific categories, usually not used.
if (useSectionCategories) { if (useSectionCategories) {
Iterator files = categoryFileList.iterator(); Iterator files = categoryFileList.iterator();
while ( files.hasNext() ) { while (files.hasNext()) {
setup.registerCategories((String) files.next()); 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 * Steps through a list of roles which are part of a staff group and
* delegates processing of each role. * delegates processing of each role.
@ -155,12 +142,12 @@ public final class ContentSectionSetup {
Iterator i = roles.iterator(); Iterator i = roles.iterator();
while (i.hasNext()) { while (i.hasNext()) {
List role = (List)i.next(); List role = (List) i.next();
String name = (String)role.get(0); String name = (String) role.get(0);
String desc = (String)role.get(1); String desc = (String) role.get(1);
List privileges = (List)role.get(2); List privileges = (List) role.get(2);
String task = (role.size() > 3 ? (String)role.get(3) : null); String task = (role.size() > 3 ? (String) role.get(3) : null);
s_log.info("Creating role " + name); s_log.info("Creating role " + name);
@ -170,8 +157,9 @@ public final class ContentSectionSetup {
desc, desc,
privileges); privileges);
if (task != null) if (task != null) {
m_tasks.put(task, group); m_tasks.put(task, group);
}
} }
} }
@ -192,22 +180,22 @@ public final class ContentSectionSetup {
Iterator i = privileges.iterator(); Iterator i = privileges.iterator();
while (i.hasNext()) { while (i.hasNext()) {
String priv = (String)i.next(); String priv = (String) i.next();
s_log.info("Granting privilege cms_" + priv); s_log.info("Granting privilege cms_" + priv);
role.grantPermission(m_section, role.grantPermission(m_section,
PrivilegeDescriptor.get("cms_" + priv)); PrivilegeDescriptor.get("cms_" + priv));
if (priv.equals(SecurityManager.CATEGORY_ADMIN) || if (priv.equals(SecurityManager.CATEGORY_ADMIN)
priv.equals(SecurityManager.CATEGORIZE_ITEMS)) { || priv.equals(SecurityManager.CATEGORIZE_ITEMS)) {
RootCategoryCollection coll = Category.getRootCategories(m_section); RootCategoryCollection coll = Category.getRootCategories(m_section);
while (coll.next()) { while (coll.next()) {
if (priv.equals(SecurityManager.CATEGORY_ADMIN)) { if (priv.equals(SecurityManager.CATEGORY_ADMIN)) {
role.grantPermission(coll.getCategory(), role.grantPermission(coll.getCategory(),
PrivilegeDescriptor.ADMIN); PrivilegeDescriptor.ADMIN);
} else { } else {
role.grantPermission(coll.getCategory(), 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? // XXX Shouldn't read permission granted depending on pub=true?
viewers.grantPermission(m_section, viewers.grantPermission(m_section,
PrivilegeDescriptor.get("cms_read_item")); PrivilegeDescriptor.get("cms_read_item"));
String email = Boolean.TRUE.equals(pub) ? "public@nullhost" String email = Boolean.TRUE.equals(pub) ? "public@nullhost"
: "registered@nullhost"; : "registered@nullhost";
Party viewer = retrieveParty(email); Party viewer = retrieveParty(email);
if (viewer == null) if (viewer == null) {
throw new InitializationException( throw new InitializationException((String) GlobalizationUtil.globalize(
(String) GlobalizationUtil.globalize( "cms.installer.cannot_find_group_for_email").localize() + email);
"cms.installer.cannot_find_group_for_email").localize() + email); }
s_log.info("Adding " + email + " to viewers role"); s_log.info("Adding " + email + " to viewers role");
viewers.getGroup().addMemberOrSubgroup(viewer); viewers.getGroup().addMemberOrSubgroup(viewer);
@ -275,29 +263,25 @@ public final class ContentSectionSetup {
* @param templateResolverClassName * @param templateResolverClassName
*/ */
public void registerResolvers(String itemResolverClassName, 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); m_section.setItemResolverClass(itemResolverClassName);
s_log.info("Registering " + itemResolverClassName s_log.info("Registering " + itemResolverClassName
+ " as the item resolver class"); + " as the item resolver class");
} else { } else {
m_section.setItemResolverClass(ContentSection.getConfig() m_section.setItemResolverClass(ContentSection.getConfig().getDefaultItemResolverClass().getName());
.getDefaultItemResolverClass()
.getName());
s_log.info("Registering " + itemResolverClassName 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); m_section.setTemplateResolverClass(templateResolverClassName);
s_log.info("Registering " + templateResolverClassName + s_log.info("Registering " + templateResolverClassName
" as the template resolver class"); + " as the template resolver class");
} else { } else {
m_section.setTemplateResolverClass(ContentSection.getConfig() m_section.setTemplateResolverClass(ContentSection.getConfig().getDefaultTemplateResolverClass().getName());
.getDefaultTemplateResolverClass() s_log.info("Registering " + templateResolverClassName
.getName()); + " as the template resolver class");
s_log.info("Registering " + templateResolverClassName +
" as the template resolver class");
} }
m_section.save(); m_section.save();
@ -314,8 +298,8 @@ public final class ContentSectionSetup {
// The feature lifecycle. // The feature lifecycle.
LifecycleDefinition lcd = new LifecycleDefinition(); LifecycleDefinition lcd = new LifecycleDefinition();
lcd.setLabel( (String) GlobalizationUtil.globalize( lcd.setLabel((String) GlobalizationUtil.globalize(
"cms.installer.simple_publication").localize()); "cms.installer.simple_publication").localize());
lcd.setDescription("A one-phase lifecycle for items."); lcd.setDescription("A one-phase lifecycle for items.");
lcd.save(); lcd.save();
@ -339,40 +323,42 @@ public final class ContentSectionSetup {
* @throws InitializationException * @throws InitializationException
*/ */
public void registerWorkflowTemplates() public void registerWorkflowTemplates()
throws InitializationException { throws InitializationException {
// The 3-step production workflow. // The 3-step production workflow.
WorkflowTemplate wf = new WorkflowTemplate(); WorkflowTemplate wf = new WorkflowTemplate();
wf.setLabel( (String) GlobalizationUtil.globalize( wf.setLabel((String) GlobalizationUtil.globalize(
"cms.installer.production_workflow").localize()); "cms.installer.production_workflow").localize());
wf.setDescription("A process that involves creating and approving content."); wf.setDescription("A process that involves creating and approving content.");
wf.save(); wf.save();
CMSTask authoring = new CMSTask(); CMSTask authoring = new CMSTask();
authoring.setLabel((String) GlobalizationUtil.globalize( authoring.setLabel((String) GlobalizationUtil.globalize(
"cms.installer.authoring").localize()); "cms.installer.authoring").localize());
authoring.setDescription("Create content."); authoring.setDescription("Create content.");
authoring.save(); authoring.save();
Role author = (Role)m_tasks.get("Authoring"); Role author = (Role) m_tasks.get("Authoring");
if (author != null) if (author != null) {
authoring.assignGroup(author.getGroup()); authoring.assignGroup(author.getGroup());
}
authoring.setTaskType(CMSTaskType.retrieve(CMSTaskType.AUTHOR)); authoring.setTaskType(CMSTaskType.retrieve(CMSTaskType.AUTHOR));
authoring.save(); authoring.save();
CMSTask approval = new CMSTask(); CMSTask approval = new CMSTask();
approval.setLabel( (String) GlobalizationUtil.globalize( approval.setLabel((String) GlobalizationUtil.globalize(
"cms.installer.approval").localize()); "cms.installer.approval").localize());
approval.setDescription("Approve content."); approval.setDescription("Approve content.");
approval.save(); approval.save();
approval.addDependency(authoring); approval.addDependency(authoring);
approval.save(); approval.save();
Role approver = (Role)m_tasks.get("Approval"); Role approver = (Role) m_tasks.get("Approval");
if (approver != null) if (approver != null) {
approval.assignGroup(approver.getGroup()); approval.assignGroup(approver.getGroup());
}
approval.setTaskType(CMSTaskType.retrieve(CMSTaskType.EDIT)); approval.setTaskType(CMSTaskType.retrieve(CMSTaskType.EDIT));
approval.save(); approval.save();
@ -380,15 +366,16 @@ public final class ContentSectionSetup {
CMSTask deploy = new CMSTask(); CMSTask deploy = new CMSTask();
deploy.setLabel((String) GlobalizationUtil.globalize( deploy.setLabel((String) GlobalizationUtil.globalize(
"cms.installer.deploy").localize()); "cms.installer.deploy").localize());
deploy.setDescription("Deploy content."); deploy.setDescription("Deploy content.");
deploy.save(); deploy.save();
deploy.addDependency(approval); deploy.addDependency(approval);
deploy.save(); deploy.save();
Role publisher = (Role)m_tasks.get("Publishing"); Role publisher = (Role) m_tasks.get("Publishing");
if (publisher != null) if (publisher != null) {
deploy.assignGroup(publisher.getGroup()); deploy.assignGroup(publisher.getGroup());
}
deploy.setTaskType(CMSTaskType.retrieve(CMSTaskType.DEPLOY)); deploy.setTaskType(CMSTaskType.retrieve(CMSTaskType.DEPLOY));
deploy.save(); deploy.save();
@ -417,11 +404,11 @@ public final class ContentSectionSetup {
while (i.hasNext()) { while (i.hasNext()) {
Object obj = i.next(); Object obj = i.next();
if (obj instanceof String) { if (obj instanceof String) {
registerContentType((String)obj); registerContentType((String) obj);
} else { } else {
List list = (List)obj; List list = (List) obj;
String name = (String)list.get(0); String name = (String) list.get(0);
String file = (String)list.get(1); String file = (String) list.get(1);
ContentType type = registerContentType(name); ContentType type = registerContentType(name);
registerTemplate(type, file); registerTemplate(type, file);
@ -440,22 +427,21 @@ public final class ContentSectionSetup {
try { try {
type = ContentType.findByAssociatedObjectType(name); type = ContentType.findByAssociatedObjectType(name);
} catch (DataObjectNotFoundException ex) { } catch (DataObjectNotFoundException ex) {
throw new UncheckedWrapperException( throw new UncheckedWrapperException(
(String) GlobalizationUtil.globalize( (String) GlobalizationUtil.globalize(
"cms.installer.cannot_find_content_type").localize() + name, ex); "cms.installer.cannot_find_content_type").localize() + name, ex);
} }
s_log.info("Adding type " + name + " to " + m_section.getDisplayName()); s_log.info("Adding type " + name + " to " + m_section.getDisplayName());
m_section.addContentType(type); m_section.addContentType(type);
s_log.info("Setting the default lifecycle for " + s_log.info("Setting the default lifecycle for "
name + " to " + m_lcd.getLabel()); + name + " to " + m_lcd.getLabel());
ContentTypeLifecycleDefinition. ContentTypeLifecycleDefinition.updateLifecycleDefinition(m_section, type, m_lcd);
updateLifecycleDefinition(m_section, type, m_lcd);
m_lcd.save(); m_lcd.save();
s_log.info("Setting the default workflow template for " + name + s_log.info("Setting the default workflow template for " + name
" to " + m_wf.getLabel()); + " to " + m_wf.getLabel());
ContentTypeWorkflowTemplate.updateWorkflowTemplate(m_section, type, m_wf); ContentTypeWorkflowTemplate.updateWorkflowTemplate(m_section, type, m_wf);
m_wf.save(); m_wf.save();
@ -468,14 +454,15 @@ public final class ContentSectionSetup {
int pos1 = filename.lastIndexOf("/"); int pos1 = filename.lastIndexOf("/");
int pos2 = filename.lastIndexOf("."); int pos2 = filename.lastIndexOf(".");
if (pos2 == -1) if (pos2 == -1) {
pos2 = filename.length(); pos2 = filename.length();
}
String label = filename.substring(pos1+1,pos2); String label = filename.substring(pos1 + 1, pos2);
String typename = type.getClassName(); String typename = type.getClassName();
int pos3 = typename.lastIndexOf("."); 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(); Template temp = new Template();
temp.setContentSection(m_section); temp.setContentSection(m_section);
@ -483,32 +470,28 @@ public final class ContentSectionSetup {
temp.setLabel(label); temp.setLabel(label);
temp.setParent(m_section.getTemplatesFolder()); temp.setParent(m_section.getTemplatesFolder());
final ClassLoader loader = Thread.currentThread final ClassLoader loader = Thread.currentThread().getContextClassLoader();
().getContextClassLoader(); final InputStream stream = loader.getResourceAsStream(filename.substring(1));
final InputStream stream = loader.getResourceAsStream
(filename.substring(1));
if (stream == null) { if (stream == null) {
throw new IllegalStateException throw new IllegalStateException((String) GlobalizationUtil.globalize("cms.installer.cannot_find_file").localize() + filename);
((String) GlobalizationUtil.globalize
("cms.installer.cannot_find_file").localize() + filename);
} }
final BufferedReader input = new BufferedReader final BufferedReader input = new BufferedReader(new InputStreamReader(stream));
(new InputStreamReader(stream));
StringBuffer body = new StringBuffer(); StringBuilder body = new StringBuilder();
String line; String line;
for (;;) { for (;;) {
try { try {
line = input.readLine(); line = input.readLine();
} catch (IOException ex) { } catch (IOException ex) {
throw new UncheckedWrapperException( throw new UncheckedWrapperException(
(String) GlobalizationUtil.globalize( (String) GlobalizationUtil.globalize(
"cms.installer.cannot_read_line_of_data").localize(), ex); "cms.installer.cannot_read_line_of_data").localize(), ex);
} }
if (line == null) if (line == null) {
break; break;
}
body.append(line); body.append(line);
body.append("\n"); body.append("\n");
@ -518,12 +501,9 @@ public final class ContentSectionSetup {
temp.save(); temp.save();
TemplateManagerFactory.getInstance() TemplateManagerFactory.getInstance().addTemplate(m_section, type, temp, "public");
.addTemplate(m_section, type, temp, "public");
temp.publish(m_lcd, new Date()); 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(); alert.save();
} }
// // Currently there is no way to persists alert preferemces, therefore // // Currently there is no way to persists alert preferemces, therefore
// // currently not a loader or setup task. // // currently not a loader or setup task.
// /** // /**
@ -607,14 +586,13 @@ public final class ContentSectionSetup {
// //
// return unfinished; // return unfinished;
// } // }
// ///////////////////// Private Class Section //////////////////////////// // ///////////////////// Private Class Section ////////////////////////////
/** /**
* SAX Handler for category lists. Creates the categories as they are * SAX Handler for category lists. Creates the categories as they are
* defined, with structure, in the xml document. * defined, with structure, in the xml document.
*/ */
private class CategoryHandler extends DefaultHandler { private class CategoryHandler extends DefaultHandler {
private Stack m_cats = new Stack(); private Stack m_cats = new Stack();
private ContentSection m_section; private ContentSection m_section;
@ -623,8 +601,8 @@ public final class ContentSectionSetup {
} }
@Override @Override
public void startElement ( String uri, String local, public void startElement(String uri, String local,
String qName, Attributes attrs ) { String qName, Attributes attrs) {
if ("categories".equals(qName)) { if ("categories".equals(qName)) {
String name = attrs.getValue("name"); String name = attrs.getValue("name");
if (name == null) { if (name == null) {
@ -634,7 +612,7 @@ public final class ContentSectionSetup {
String context = attrs.getValue("context"); String context = attrs.getValue("context");
Category root = Category.getRootForObject(m_section, Category root = Category.getRootForObject(m_section,
context); context);
if (root == null) { if (root == null) {
root = new Category(); root = new Category();
} }
@ -643,18 +621,18 @@ public final class ContentSectionSetup {
if (root.isNew()) { if (root.isNew()) {
Category.setRootForObject(m_section, Category.setRootForObject(m_section,
root, root,
context); context);
} }
m_cats.push(root); m_cats.push(root);
PermissionService.setContext(root, m_section); PermissionService.setContext(root, m_section);
} else if ( "category".equals(qName) ) { } else if ("category".equals(qName)) {
String name = attrs.getValue("name"); String name = attrs.getValue("name");
String description = attrs.getValue("description"); String description = attrs.getValue("description");
String url = attrs.getValue("url"); String url = attrs.getValue("url");
// set the default description to the name of the category // set the default description to the name of the category
if ( description == null ) { if (description == null) {
description = name; description = name;
} }
@ -664,8 +642,8 @@ public final class ContentSectionSetup {
Category parent = null; Category parent = null;
try { try {
parent = (Category)m_cats.peek(); parent = (Category) m_cats.peek();
} catch ( EmptyStackException ex ) { } catch (EmptyStackException ex) {
throw new UncheckedWrapperException("no root category", ex); throw new UncheckedWrapperException("no root category", ex);
} }
@ -679,13 +657,12 @@ public final class ContentSectionSetup {
} }
@Override @Override
public void endElement ( String uri, String local, String qName ) { public void endElement(String uri, String local, String qName) {
if ( "category".equals(qName) ) { if ("category".equals(qName)) {
m_cats.pop(); m_cats.pop();
} else if ( "categories".equals(qName)) { } else if ("categories".equals(qName)) {
m_cats.pop(); m_cats.pop();
} }
} }
} }
} }

View File

@ -86,14 +86,13 @@ public abstract class AbstractContentTypeLoader extends PackageLoader {
ContentSection.BASE_DATA_OBJECT_TYPE); ContentSection.BASE_DATA_OBJECT_TYPE);
while (sections.next()) { while (sections.next()) {
ContentSection section = (ContentSection) DomainObjectFactory. ContentSection section = (ContentSection) DomainObjectFactory.newInstance(sections.getDataObject());
newInstance(sections.getDataObject());
if (!isLoadableInto(section)) { if (!isLoadableInto(section)) {
continue; continue;
} }
LifecycleDefinitionCollection ldc = LifecycleDefinitionCollection ldc =
section.getLifecycleDefinitions(); section.getLifecycleDefinitions();
LifecycleDefinition ld = null; LifecycleDefinition ld = null;
if (ldc.next()) { if (ldc.next()) {
ld = ldc.getLifecycleDefinition(); ld = ldc.getLifecycleDefinition();
@ -118,11 +117,11 @@ public abstract class AbstractContentTypeLoader extends PackageLoader {
} }
protected void prepareSection(final ContentSection section, protected void prepareSection(final ContentSection section,
final ContentType type, final ContentType type,
final LifecycleDefinition ld, final LifecycleDefinition ld,
final WorkflowTemplate wf) { final WorkflowTemplate wf) {
ContentTypeLifecycleDefinition.updateLifecycleDefinition(section, type, ContentTypeLifecycleDefinition.updateLifecycleDefinition(section, type,
ld); ld);
ContentTypeWorkflowTemplate.updateWorkflowTemplate(section, type, wf); ContentTypeWorkflowTemplate.updateWorkflowTemplate(section, type, wf);
} }
@ -164,12 +163,12 @@ public abstract class AbstractContentTypeLoader extends PackageLoader {
* be called by the loader class by overriding prepareSection * be called by the loader class by overriding prepareSection
*/ */
protected Template setDefaultTemplate(final String name, protected Template setDefaultTemplate(final String name,
final String label, final String label,
final InputStream templateIs, final InputStream templateIs,
final ContentSection section, final ContentSection section,
final ContentType type, final ContentType type,
final LifecycleDefinition ld, final LifecycleDefinition ld,
final WorkflowTemplate wf) { final WorkflowTemplate wf) {
final Template template = new Template(); final Template template = new Template();
template.setName(name); template.setName(name);
template.setLabel(label); template.setLabel(label);
@ -197,7 +196,7 @@ public abstract class AbstractContentTypeLoader extends PackageLoader {
template.setText(body.toString()); template.setText(body.toString());
TemplateManagerFactory.getInstance().addTemplate(section, type, template, TemplateManagerFactory.getInstance().addTemplate(section, type, template,
TemplateManager.PUBLIC_CONTEXT); TemplateManager.PUBLIC_CONTEXT);
template.publish(ld, new Date()); template.publish(ld, new Date());
return template; return template;

View File

@ -45,7 +45,8 @@ public interface ContentTypeHelper {
public void setLabelKey(String labelKey); public void setLabelKey(String labelKey);
public String getLabelKey(); public String getLabelKey();
public boolean isInternal(); public boolean isInternal();
public void setInternal(boolean internal); public boolean isHidden();
public void setMode(String mode);
/** @deprecated */ /** @deprecated */
public void setDescription(String description) ; public void setDescription(String description) ;
/** @deprecated */ /** @deprecated */

View File

@ -50,7 +50,7 @@ public class ContentTypeHelperImpl implements ContentTypeHelper {
private String m_className; private String m_className;
private String m_createComponent; private String m_createComponent;
private AuthoringKit m_kit; private AuthoringKit m_kit;
private boolean m_internal; private String m_mode;
public ContentTypeHelperImpl() { public ContentTypeHelperImpl() {
} }
@ -95,12 +95,16 @@ public class ContentTypeHelperImpl implements ContentTypeHelper {
return m_labelKey; return m_labelKey;
} }
public void setInternal(boolean internal) { public void setMode(String mode) {
m_internal = internal; m_mode = mode.toLowerCase();
} }
public boolean isInternal() { 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.setDescription(m_description);
m_type.setClassName(m_className); m_type.setClassName(m_className);
m_type.setAssociatedObjectType(m_objectType); m_type.setAssociatedObjectType(m_objectType);
m_type.setInternal(m_internal); m_type.setMode(m_mode);
// create pedigree for this content type // create pedigree for this content type
createPedigree(m_type); createPedigree(m_type);
@ -221,7 +225,7 @@ public class ContentTypeHelperImpl implements ContentTypeHelper {
// Turn on search indexing for this type // Turn on search indexing for this type
ObjectType type = SessionManager.getMetadataRoot().getObjectType(m_objectType); ObjectType type = SessionManager.getMetadataRoot().getObjectType(m_objectType);
if (type.isSubtypeOf(ContentPage.BASE_DATA_OBJECT_TYPE) if (type.isSubtypeOf(ContentPage.BASE_DATA_OBJECT_TYPE)
&& !m_internal) { && !isInternal()) {
s_log.debug("Registering search adapter for " s_log.debug("Registering search adapter for "
+ m_objectType); + m_objectType);
MetadataProviderRegistry.registerAdapter( MetadataProviderRegistry.registerAdapter(

View File

@ -18,9 +18,9 @@
*/ */
package com.arsdigita.cms.installer.xml; package com.arsdigita.cms.installer.xml;
import com.arsdigita.cms.AuthoringKit; import com.arsdigita.cms.AuthoringKit;
import com.arsdigita.cms.ContentType; import com.arsdigita.cms.ContentType;
import com.arsdigita.cms.contenttypes.ContentTypeInitializer;
import com.arsdigita.xml.XML; import com.arsdigita.xml.XML;
import org.apache.log4j.Logger; import org.apache.log4j.Logger;
@ -38,34 +38,30 @@ import java.util.List;
* *
* @see ContentTypeInitializer * @see ContentTypeInitializer
* @author Nobuko Asakai <nasakai@redhat.com> */ * @author Nobuko Asakai <nasakai@redhat.com> */
public class XMLContentTypeHandler extends DefaultHandler { public class XMLContentTypeHandler extends DefaultHandler {
private static Logger s_log = private static Logger s_log =
Logger.getLogger(XMLContentTypeHandler.class.getName()); Logger.getLogger(XMLContentTypeHandler.class.getName());
private ArrayList m_types = new ArrayList(); private ArrayList m_types = new ArrayList();
private ContentTypeHelper m_type; private ContentTypeHelper m_type;
private ContentType m_contentType; private ContentType m_contentType;
private AuthoringKit m_authoringKit; private AuthoringKit m_authoringKit;
private int m_nextOrder; private int m_nextOrder;
private boolean m_including; private boolean m_including;
public List getContentTypes() { public List getContentTypes() {
return m_types; return m_types;
} }
public void startElement( String uri, String name, @Override
String qName, Attributes atts) { public void startElement(String uri, String name,
if (name.equals("content-types") ) { String qName, Attributes atts) {
if (name.equals("content-types")) {
s_log.debug("matched content-types"); s_log.debug("matched content-types");
} else if (name.equals("content-type")) { } else if (name.equals("content-type")) {
s_log.debug("matched content-type"); s_log.debug("matched content-type");
String parentType = atts.getValue("parentType"); String parentType = atts.getValue("parentType");
if (parentType != null ) { if (parentType != null) {
m_type = new UDCTHelper(); m_type = new UDCTHelper();
s_log.debug("Creating UDCT"); s_log.debug("Creating UDCT");
} else { } else {
@ -85,17 +81,20 @@ public class XMLContentTypeHandler extends DefaultHandler {
m_type.setObjectType(atts.getValue("objectType")); m_type.setObjectType(atts.getValue("objectType"));
m_type.setClassName(atts.getValue("classname")); m_type.setClassName(atts.getValue("classname"));
String internal = atts.getValue("isInternal"); String mode = atts.getValue("mode");
if (internal != null && if (mode != null && !mode.isEmpty()) {
"yes".equals(internal)) { m_type.setMode(mode.trim());
m_type.setInternal(true); } else {
m_type.setMode("default");
} }
// UDCT stuff // UDCT stuff
m_type.setParentType(parentType); m_type.setParentType(parentType);
m_type.setName(atts.getValue("name")); m_type.setName(atts.getValue("name"));
m_contentType = m_type.createType(); m_contentType = m_type.createType();
m_types.add(m_contentType); m_types.add(m_contentType);
} else if ( name.equals("authoring-kit") ) { } else if (name.equals("authoring-kit")) {
if (!m_including) { if (!m_including) {
s_log.debug("matched authoring-kit"); s_log.debug("matched authoring-kit");
if (atts.getValue("createComponent") != null) { if (atts.getValue("createComponent") != null) {
@ -104,7 +103,7 @@ public class XMLContentTypeHandler extends DefaultHandler {
m_authoringKit = m_type.createAuthoringKit(); m_authoringKit = m_type.createAuthoringKit();
m_nextOrder = 1; m_nextOrder = 1;
} }
} else if ( name.equals("authoring-step" )) { } else if (name.equals("authoring-step")) {
String label = atts.getValue("label"); String label = atts.getValue("label");
String labelKey = atts.getValue("labelKey"); String labelKey = atts.getValue("labelKey");
String labelBundle = atts.getValue("labelBundle"); String labelBundle = atts.getValue("labelBundle");
@ -118,10 +117,9 @@ public class XMLContentTypeHandler extends DefaultHandler {
descriptionKey = description; descriptionKey = description;
} }
m_type.addAuthoringStep(labelKey, labelBundle, m_type.addAuthoringStep(labelKey, labelBundle,
descriptionKey, descriptionBundle, descriptionKey, descriptionBundle,
atts.getValue("component"), atts.getValue("component"),
new BigDecimal(m_nextOrder++) new BigDecimal(m_nextOrder++));
);
} else if (name.equals("include")) { } else if (name.equals("include")) {
String file = atts.getValue("href"); String file = atts.getValue("href");
m_including = true; m_including = true;
@ -129,12 +127,12 @@ public class XMLContentTypeHandler extends DefaultHandler {
m_including = false; m_including = false;
} else { } else {
s_log.error("None of the elements match! name: " + name 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, public void endElement(String uri, String name,
String qName, Attributes atts) { String qName, Attributes atts) {
if (name.equals("content-type")) { if (name.equals("content-type")) {
// reset the helper // reset the helper
m_contentType.save(); m_contentType.save();

View File

@ -18,7 +18,6 @@
*/ */
package com.arsdigita.cms.ui.type; package com.arsdigita.cms.ui.type;
import com.arsdigita.bebop.ColumnPanel; import com.arsdigita.bebop.ColumnPanel;
import com.arsdigita.bebop.FormProcessException; import com.arsdigita.bebop.FormProcessException;
import com.arsdigita.bebop.Label; import com.arsdigita.bebop.Label;
@ -57,19 +56,17 @@ import java.util.TooManyListenersException;
public class AddContentItemElement extends ElementAddForm { public class AddContentItemElement extends ElementAddForm {
private static final Logger s_log = private static final Logger s_log =
Logger.getLogger(AddContentItemElement.class); Logger.getLogger(AddContentItemElement.class);
private SingleSelect m_itemTypeSelect; private SingleSelect m_itemTypeSelect;
/** /**
* Constructor * Constructor
*/ */
public AddContentItemElement(ACSObjectSelectionModel types) { public AddContentItemElement(ACSObjectSelectionModel types) {
super("ContentTypeAddContentItemElement", "Add a ContentItem Element", types); super("ContentTypeAddContentItemElement", "Add a ContentItem Element", types);
add(new Label(GlobalizationUtil.globalize add(new Label(GlobalizationUtil.globalize("cms.ui.type.association_content_type")));
("cms.ui.type.association_content_type"))); m_itemTypeSelect = new SingleSelect(new BigDecimalParameter("AddContentItemTypeSelect"));
m_itemTypeSelect = new SingleSelect
(new BigDecimalParameter("AddContentItemTypeSelect"));
try { try {
m_itemTypeSelect.addPrintListener(new ItemTypeSelectPrintListener()); m_itemTypeSelect.addPrintListener(new ItemTypeSelectPrintListener());
} catch (TooManyListenersException ex) { } catch (TooManyListenersException ex) {
@ -78,49 +75,45 @@ public class AddContentItemElement extends ElementAddForm {
} }
add(m_itemTypeSelect); add(m_itemTypeSelect);
add(m_buttons, ColumnPanel.FULL_WIDTH|ColumnPanel.CENTER); add(m_buttons, ColumnPanel.FULL_WIDTH | ColumnPanel.CENTER);
} }
private ContentType getItemType(PageState state) private ContentType getItemType(PageState state)
throws FormProcessException { throws FormProcessException {
BigDecimal itemTypeID = BigDecimal itemTypeID =
(BigDecimal) m_itemTypeSelect.getValue(state); (BigDecimal) m_itemTypeSelect.getValue(state);
ContentType itemType = null; ContentType itemType = null;
Assert.exists(itemTypeID, "itemTypeID"); Assert.exists(itemTypeID, "itemTypeID");
try { try {
itemType = new ContentType(itemTypeID); itemType = new ContentType(itemTypeID);
} catch (DataObjectNotFoundException ex) { } catch (DataObjectNotFoundException ex) {
throw new FormProcessException throw new FormProcessException((String) GlobalizationUtil.globalize("cms.ui.type.invalid").localize());
((String) GlobalizationUtil.globalize
("cms.ui.type.invalid").localize());
} }
return itemType; return itemType;
} }
protected final void addAttribute(DynamicObjectType dot, String label, protected final void addAttribute(DynamicObjectType dot, String label,
PageState state) PageState state)
throws FormProcessException { throws FormProcessException {
ContentType itemType = getItemType(state); ContentType itemType = getItemType(state);
dot.addOptionalAssociation(label, dot.addOptionalAssociation(label,
MetadataRoot.getMetadataRoot().getObjectType MetadataRoot.getMetadataRoot().getObjectType(itemType.getAssociatedObjectType()));
(itemType.getAssociatedObjectType()));
} }
protected final void addFormComponent(PersistentForm pForm, String label, protected final void addFormComponent(PersistentForm pForm, String label,
PageState state) PageState state)
throws FormProcessException { throws FormProcessException {
ContentType itemType = getItemType(state); ContentType itemType = getItemType(state);
PersistentHidden pContentTypeName = PersistentHidden.create(label+"Type"); PersistentHidden pContentTypeName = PersistentHidden.create(label + "Type");
pContentTypeName.setDefaultValue(itemType.getAssociatedObjectType()); pContentTypeName.setDefaultValue(itemType.getAssociatedObjectType());
pContentTypeName.save(); pContentTypeName.save();
pForm.addComponent(pContentTypeName); pForm.addComponent(pContentTypeName);
PersistentSingleSelect pSelect = PersistentSingleSelect.create(label); PersistentSingleSelect pSelect = PersistentSingleSelect.create(label);
pSelect.setParameterModel pSelect.setParameterModel("com.arsdigita.bebop.parameters.BigDecimalParameter");
("com.arsdigita.bebop.parameters.BigDecimalParameter");
pSelect.save(); pSelect.save();
pForm.addComponent(pSelect); pForm.addComponent(pSelect);
} }
@ -137,9 +130,9 @@ public class AddContentItemElement extends ElementAddForm {
// Get the current content section // Get the current content section
ContentSection section = CMS.getContext().getContentSection(); ContentSection section = CMS.getContext().getContentSection();
ContentTypeCollection contentTypes = section.getCreatableContentTypes(); ContentTypeCollection contentTypes = section.getCreatableContentTypes(true);
contentTypes.addOrder(ContentType.LABEL); contentTypes.addOrder(ContentType.LABEL);
while ( contentTypes.next() ) { while (contentTypes.next()) {
ContentType type = contentTypes.getContentType(); ContentType type = contentTypes.getContentType();
t.addOption(new Option(type.getID().toString(), type.getLabel())); t.addOption(new Option(type.getID().toString(), type.getLabel()));
} }

View File

@ -48,6 +48,7 @@ import com.arsdigita.toolbox.ui.Cancellable;
import org.apache.log4j.Logger; import org.apache.log4j.Logger;
import java.math.BigDecimal; import java.math.BigDecimal;
/** /**
* This class contains the split pane for the ContentType * This class contains the split pane for the ContentType
* administration interface. * administration interface.
@ -60,15 +61,13 @@ import java.math.BigDecimal;
*/ */
public final class ContentTypeAdminPane extends BaseAdminPane { public final class ContentTypeAdminPane extends BaseAdminPane {
private static final Logger s_log = Logger.getLogger private static final Logger s_log = Logger.getLogger(ContentTypeAdminPane.class);
(ContentTypeAdminPane.class);
private final ACSObjectSelectionModel m_model; private final ACSObjectSelectionModel m_model;
private final ContentTypeRequestLocal m_type; private final ContentTypeRequestLocal m_type;
public ContentTypeAdminPane() { public ContentTypeAdminPane() {
super(new Label(gz("cms.ui.types")), super(new Label(gz("cms.ui.types")),
new ContentTypeListModelBuilder()); new ContentTypeListModelBuilder());
m_model = new ACSObjectSelectionModel(getSelectionModel()); m_model = new ACSObjectSelectionModel(getSelectionModel());
m_type = new SelectionRequestLocal(); m_type = new SelectionRequestLocal();
@ -83,13 +82,13 @@ public final class ContentTypeAdminPane extends BaseAdminPane {
new EditType(m_model)); new EditType(m_model));
setDelete(new ActionLink(new Label(gz("cms.ui.type.delete"))), setDelete(new ActionLink(new Label(gz("cms.ui.type.delete"))),
new DeleteForm()); new DeleteForm());
setIntroPane(new Label(gz("cms.ui.type.intro"))); setIntroPane(new Label(gz("cms.ui.type.intro")));
setItemPane(new ContentTypeItemPane(m_model, setItemPane(new ContentTypeItemPane(m_model,
m_type, m_type,
getEditLink(), getEditLink(),
getDeleteLink())); getDeleteLink()));
addAction(new TypeSecurityContainer(addTypeLink), ActionGroup.ADD); addAction(new TypeSecurityContainer(addTypeLink), ActionGroup.ADD);
} }
@ -98,53 +97,54 @@ public final class ContentTypeAdminPane extends BaseAdminPane {
super.register(p); super.register(p);
p.addActionListener(new ActionListener() { 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 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 SelectType m_selectType;
private CreateType m_createType; private CreateType m_createType;
@ -157,44 +157,41 @@ public final class ContentTypeAdminPane extends BaseAdminPane {
GridPanel container = new GridPanel(1); GridPanel container = new GridPanel(1);
container.add(m_noTypesAvailable); container.add(m_noTypesAvailable);
m_selectType = new SelectType(); m_selectType = new SelectType();
m_selectType.addSubmissionListener m_selectType.addSubmissionListener(new CancelListener(m_selectType));
(new CancelListener(m_selectType));
m_selectType.addProcessListener(this); m_selectType.addProcessListener(this);
container.add(m_selectType); container.add(m_selectType);
selectSection.setBody(container); selectSection.setBody(container);
Section addSection = new Section() { Section addSection = new Section() {
public final boolean isVisible(final PageState state) {
return super.isVisible(state) && public final boolean isVisible(final PageState state) {
!ContentSection.getConfig().getHideUDCTUI(); return super.isVisible(state)
} && !ContentSection.getConfig().getHideUDCTUI();
}; }
};
addSection.setHeading(new Label(gz("cms.ui.type.define"))); addSection.setHeading(new Label(gz("cms.ui.type.define")));
m_createType = new CreateType(m_model); m_createType = new CreateType(m_model);
m_createType.addSubmissionListener m_createType.addSubmissionListener(new CancelListener(m_createType));
(new CancelListener(m_createType));
m_createType.addProcessListener(this); m_createType.addProcessListener(this);
addSection.setBody(m_createType); addSection.setBody(m_createType);
add(addSection); add(addSection);
} }
public void actionPerformed(ActionEvent e) { public void actionPerformed(ActionEvent e) {
PageState s = e.getPageState(); PageState s = e.getPageState();
ContentSection section = CMS.getContext().getContentSection(); ContentSection section = CMS.getContext().getContentSection();
ContentTypeCollection contentTypes = ContentTypeCollection contentTypes =
section.getNotAssociatedContentTypes(); section.getNotAssociatedContentTypes();
boolean hasAvailableTypes = !contentTypes.isEmpty(); boolean hasAvailableTypes = !contentTypes.isEmpty();
m_selectType.setVisible(s, hasAvailableTypes); m_selectType.setVisible(s, hasAvailableTypes);
m_noTypesAvailable.setVisible(s, !hasAvailableTypes); m_noTypesAvailable.setVisible(s, !hasAvailableTypes);
} }
public final void process(final FormSectionEvent e) public final void process(final FormSectionEvent e)
throws FormProcessException { throws FormProcessException {
final PageState state = e.getPageState(); final PageState state = e.getPageState();
resetPane(state); resetPane(state);
} }
} }
/** /**
@ -203,13 +200,15 @@ public final class ContentTypeAdminPane extends BaseAdminPane {
* becaue it was protected * becaue it was protected
*/ */
private final class CancelListener implements FormSubmissionListener { private final class CancelListener implements FormSubmissionListener {
Cancellable m_form; Cancellable m_form;
CancelListener(Cancellable form) { CancelListener(Cancellable form) {
m_form = form; m_form = form;
} }
public void submitted(FormSectionEvent event) public void submitted(FormSectionEvent event)
throws FormProcessException { throws FormProcessException {
PageState state = event.getPageState(); PageState state = event.getPageState();
if (m_form.isCancelled(state)) { if (m_form.isCancelled(state)) {
getBody().pop(state); getBody().pop(state);
@ -221,20 +220,22 @@ public final class ContentTypeAdminPane extends BaseAdminPane {
private void resetPane(PageState state) { private void resetPane(PageState state) {
getBody().reset(state); getBody().reset(state);
if (getSelectionModel().isSelected(state)) { if (getSelectionModel().isSelected(state)) {
s_log.debug("The selection model is selected; displaying " + s_log.debug("The selection model is selected; displaying "
"the item pane"); + "the item pane");
getBody().push(state, getItemPane()); getBody().push(state, getItemPane());
} }
} }
private class SelectionRequestLocal extends ContentTypeRequestLocal { private class SelectionRequestLocal extends ContentTypeRequestLocal {
protected final Object initialValue(final PageState state) { protected final Object initialValue(final PageState state) {
ContentType contentType = (ContentType) m_model.getSelectedObject(state); ContentType contentType = (ContentType) m_model.getSelectedObject(state);
return contentType; return contentType;
} }
} }
private class DeleteForm extends BaseDeleteForm { private class DeleteForm extends BaseDeleteForm {
DeleteForm() { DeleteForm() {
super(new Label(gz("cms.ui.type.delete_prompt"))); super(new Label(gz("cms.ui.type.delete_prompt")));
@ -245,7 +246,7 @@ public final class ContentTypeAdminPane extends BaseAdminPane {
throws FormProcessException { throws FormProcessException {
final PageState state = e.getPageState(); final PageState state = e.getPageState();
final ContentSection section = final ContentSection section =
CMS.getContext().getContentSection(); CMS.getContext().getContentSection();
section.removeContentType(m_type.getContentType(state)); section.removeContentType(m_type.getContentType(state));
section.save(); section.save();

View File

@ -46,7 +46,7 @@ class ContentTypeListModelBuilder extends LockableImpl
final ContentSection section = final ContentSection section =
CMS.getContext().getContentSection(); CMS.getContext().getContentSection();
m_types = section.getContentTypes(); m_types = section.getContentTypes(true);
m_types.addOrder(ContentType.LABEL); m_types.addOrder(ContentType.LABEL);
m_types.rewind(); m_types.rewind();
} }

View File

@ -18,7 +18,6 @@
*/ */
package com.arsdigita.cms.ui.type; package com.arsdigita.cms.ui.type;
import com.arsdigita.bebop.ColumnPanel; import com.arsdigita.bebop.ColumnPanel;
import com.arsdigita.bebop.FormData; import com.arsdigita.bebop.FormData;
import com.arsdigita.bebop.FormProcessException; import com.arsdigita.bebop.FormProcessException;
@ -85,21 +84,16 @@ import java.util.TooManyListenersException;
* @author Xixi D'Moon (xdmoon@arsdigita.com) * @author Xixi D'Moon (xdmoon@arsdigita.com)
* @version $Revision: #21 $ $Date: 2004/08/17 $ * @version $Revision: #21 $ $Date: 2004/08/17 $
*/ */
public class CreateType extends CMSForm 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 DEFAULT_UDITEM_TYPE = ContentPage.BASE_DATA_OBJECT_TYPE;
private static final String CATEGORIZATION_COMPONENT = private static final String CATEGORIZATION_COMPONENT =
"com.arsdigita.cms.ui.authoring.ItemCategoryStep"; "com.arsdigita.cms.ui.authoring.ItemCategoryStep";
private final static Logger s_log = 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 ObjectType TEST_TYPE = SessionManager.getMetadataRoot().getObjectType("com.arsdigita.kernel.Party");
private static final String CREATION_COMPONENT = "com.arsdigita.cms.ui.authoring.PageCreateDynamic"; private static final String CREATION_COMPONENT = "com.arsdigita.cms.ui.authoring.PageCreateDynamic";
private Hidden m_id; private Hidden m_id;
private TextField m_name; private TextField m_name;
private TextField m_label; private TextField m_label;
@ -110,12 +104,12 @@ public class CreateType extends CMSForm
private Submit m_submit; private Submit m_submit;
private Submit m_cancel; private Submit m_cancel;
private SingleSelectionModel m_types = null; private SingleSelectionModel m_types = null;
DynamicObjectType dot; DynamicObjectType dot;
public CreateType() { public CreateType() {
this(null); this(null);
} }
public CreateType(SingleSelectionModel m) { public CreateType(SingleSelectionModel m) {
super("NewContentItemDefinition"); super("NewContentItemDefinition");
if (m != null) { if (m != null) {
@ -190,7 +184,7 @@ public class CreateType extends CMSForm
m_cancel = new Submit("cancel"); m_cancel = new Submit("cancel");
m_cancel.setButtonLabel("Cancel"); m_cancel.setButtonLabel("Cancel");
s.add(m_cancel); s.add(m_cancel);
add(s, ColumnPanel.FULL_WIDTH|ColumnPanel.CENTER); add(s, ColumnPanel.FULL_WIDTH | ColumnPanel.CENTER);
//add the listeners //add the listeners
addProcessListener(this); addProcessListener(this);
@ -201,6 +195,7 @@ public class CreateType extends CMSForm
} }
// if this form is cancelled // if this form is cancelled
@Override
public boolean isCancelled(PageState s) { public boolean isCancelled(PageState s) {
return m_cancel.isSelected(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 * the particular content section, and if the new type name is
* legal dynamic object type name * legal dynamic object type name
*/ */
public void validate (FormSectionEvent e) throws FormProcessException { public void validate(FormSectionEvent e) throws FormProcessException {
PageState s = e.getPageState(); PageState s = e.getPageState();
String typeLabel = (String) m_label.getValue(s); String typeLabel = (String) m_label.getValue(s);
String typeName = (String) m_name.getValue(s); String typeName = (String) m_name.getValue(s);
@ -220,23 +215,22 @@ public class CreateType extends CMSForm
boolean dupe = false; boolean dupe = false;
while (contentTypes.next() && dupe==false) { while (contentTypes.next() && dupe == false) {
if (contentTypes.getContentType().getLabel().compareTo(typeLabel)==0) { if (contentTypes.getContentType().getLabel().compareTo(typeLabel) == 0) {
dupe = true; dupe = true;
} }
} }
if (dupe == true) { if (dupe == true) {
throw new FormProcessException throw new FormProcessException((String) GlobalizationUtil.globalize("cms.ui.type.name_not_unique", new Object[]{typeLabel}).localize());
((String) GlobalizationUtil.globalize("cms.ui.type.name_not_unique", new Object[] { typeLabel }).localize());
} else { } else {
for (int i = 0; i < typeName.length(); i++) { for (int i = 0; i < typeName.length(); i++) {
char c = typeName.charAt(i); char c = typeName.charAt(i);
if (Character.isWhitespace(c)) { 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)) { } 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) { if (parentContentType != null) {
parentContentClassname = parentContentType.getClassName(); parentContentClassname = parentContentType.getClassName();
parentObjectType = parentObjectType =
SessionManager.getMetadataRoot().getObjectType SessionManager.getMetadataRoot().getObjectType(parentContentType.getAssociatedObjectType());
(parentContentType.getAssociatedObjectType());
} else { } else {
try { try {
parentContentType = ContentType.findByAssociatedObjectType parentContentType = ContentType.findByAssociatedObjectType(DEFAULT_UDITEM_TYPE);
(DEFAULT_UDITEM_TYPE);
parentContentClassname = parentContentType.getClassName(); parentContentClassname = parentContentType.getClassName();
} catch (DataObjectNotFoundException ex) { } catch (DataObjectNotFoundException ex) {
// If parent content type isn't found, don't add // If parent content type isn't found, don't add
@ -291,18 +283,15 @@ public class CreateType extends CMSForm
//classname //classname
parentContentClassname = "com.arsdigita.cms.ContentPage"; parentContentClassname = "com.arsdigita.cms.ContentPage";
} }
parentObjectType = SessionManager.getMetadataRoot().getObjectType parentObjectType = SessionManager.getMetadataRoot().getObjectType(DEFAULT_UDITEM_TYPE);
(DEFAULT_UDITEM_TYPE);
} }
String qname = parentObjectType.getModel().getName() + "." + name; String qname = parentObjectType.getModel().getName() + "." + name;
MetadataRoot root = MetadataRoot.getMetadataRoot(); MetadataRoot root = MetadataRoot.getMetadataRoot();
if (root.getObjectType(qname) != null || root.hasTable(name)) { if (root.getObjectType(qname) != null || root.hasTable(name)) {
throw new FormValidationException throw new FormValidationException(m_name, (String) GlobalizationUtil.globalize("cms.ui.type.duplicate_type",
(m_name, (String) GlobalizationUtil.globalize new Object[]{name}).localize());
("cms.ui.type.duplicate_type",
new Object[] { name }).localize());
} }
//create a new dynamic object type with //create a new dynamic object type with
@ -317,8 +306,7 @@ public class CreateType extends CMSForm
try { try {
contentType = new ContentType(key); contentType = new ContentType(key);
} catch (DataObjectNotFoundException ex) { } catch (DataObjectNotFoundException ex) {
contentType = new ContentType(SessionManager.getSession().create contentType = new ContentType(SessionManager.getSession().create(new OID(ContentType.BASE_DATA_OBJECT_TYPE, key)));
(new OID(ContentType.BASE_DATA_OBJECT_TYPE, key)));
isNew = true; isNew = true;
} }
@ -339,10 +327,10 @@ public class CreateType extends CMSForm
} }
//associate a default lifecycle //associate a default lifecycle
setDefaultLifecycle (lifecycleID, section, contentType); setDefaultLifecycle(lifecycleID, section, contentType);
//associate a default workflow //associate a default workflow
setDefaultWorkflow (workflowID, section, contentType); setDefaultWorkflow(workflowID, section, contentType);
//drop the page to refresh content center, admin and item ui //drop the page to refresh content center, admin and item ui
Utilities.refreshItemUI(state); Utilities.refreshItemUI(state);
@ -378,7 +366,7 @@ public class CreateType extends CMSForm
* return true if this form is cancelled, false otherwise * return true if this form is cancelled, false otherwise
*/ */
public void submitted(FormSectionEvent e) throws FormProcessException { public void submitted(FormSectionEvent e) throws FormProcessException {
if(m_cancel.isSelected(e.getPageState())) { if (m_cancel.isSelected(e.getPageState())) {
throw new FormProcessException("cancelled"); 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 * With no parent type sent, the parent type authoring kit steps won't be added
*/ */
protected void updateContentTypeAssociation(ContentSection section, protected void updateContentTypeAssociation(ContentSection section,
ContentType type) { ContentType type) {
updateContentTypeAssociation(section, type, null); updateContentTypeAssociation(section, type, null);
} }
/** /**
* registers the new type to this content section * registers the new type to this content section
* and creates authoring kit for the content type * and creates authoring kit for the content type
*/ */
protected void updateContentTypeAssociation(ContentSection section, protected void updateContentTypeAssociation(ContentSection section,
ContentType type, ContentType type,
ContentType parentType) { ContentType parentType) {
section.addContentType(type); section.addContentType(type);
section.save(); section.save();
@ -417,29 +406,29 @@ public class CreateType extends CMSForm
hasCategoryStep = true; hasCategoryStep = true;
} }
kit.createStep(step.getLabel(), kit.createStep(step.getLabel(),
step.getDescription(), step.getDescription(),
step.getComponent(), step.getComponent(),
new BigDecimal(stepOrdering)); new BigDecimal(stepOrdering));
stepOrdering++; stepOrdering++;
} }
} }
if (stepOrdering == 1) { if (stepOrdering == 1) {
kit.createStep(type.getLabel() + " Basic Properties", kit.createStep(type.getLabel() + " Basic Properties",
type.getAssociatedObjectType(), type.getAssociatedObjectType(),
"com.arsdigita.cms.ui.authoring.PageEditDynamic", "com.arsdigita.cms.ui.authoring.PageEditDynamic",
new BigDecimal(stepOrdering)); new BigDecimal(stepOrdering));
} else { } else {
kit.createStep(type.getLabel() + " Basic Properties", kit.createStep(type.getLabel() + " Basic Properties",
type.getAssociatedObjectType(), type.getAssociatedObjectType(),
"com.arsdigita.cms.ui.authoring.SecondaryPageEditDynamic", "com.arsdigita.cms.ui.authoring.SecondaryPageEditDynamic",
new BigDecimal(stepOrdering)); new BigDecimal(stepOrdering));
} }
stepOrdering++; stepOrdering++;
if (!hasCategoryStep) { if (!hasCategoryStep) {
kit.createStep("Categories", kit.createStep("Categories",
"", "",
CATEGORIZATION_COMPONENT, CATEGORIZATION_COMPONENT,
new BigDecimal(stepOrdering)); new BigDecimal(stepOrdering));
} }
kit.save(); kit.save();
@ -462,13 +451,17 @@ public class CreateType extends CMSForm
// Get the current content section // Get the current content section
ContentSection section = CMS.getContext().getContentSection(); 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); contentTypes.addOrder(ContentType.LABEL);
while ( contentTypes.next() ) { while (contentTypes.next()) {
ContentType type = contentTypes.getContentType(); 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 // Get the current content section
ContentSection section = CMS.getContext().getContentSection(); ContentSection section = CMS.getContext().getContentSection();
t.addOption(new Option("-1","-- select --")); t.addOption(new Option("-1", "-- select --"));
LifecycleDefinitionCollection cycles = section.getLifecycleDefinitions(); LifecycleDefinitionCollection cycles = section.getLifecycleDefinitions();
while ( cycles.next() ) { while (cycles.next()) {
LifecycleDefinition cycle = cycles.getLifecycleDefinition(); LifecycleDefinition cycle = cycles.getLifecycleDefinition();
t.addOption(new Option(cycle.getID().toString(), cycle.getLabel())); t.addOption(new Option(cycle.getID().toString(), cycle.getLabel()));
} }
@ -507,22 +500,22 @@ public class CreateType extends CMSForm
// Get the current content section // Get the current content section
ContentSection section = CMS.getContext().getContentSection(); ContentSection section = CMS.getContext().getContentSection();
t.addOption(new Option("-1","-- select --")); t.addOption(new Option("-1", "-- select --"));
TaskCollection templates = section.getWorkflowTemplates(); TaskCollection templates = section.getWorkflowTemplates();
while ( templates.next() ) { while (templates.next()) {
WorkflowTemplate template = WorkflowTemplate template =
(WorkflowTemplate) templates.getDomainObject(); (WorkflowTemplate) templates.getDomainObject();
t.addOption(new Option(template.getID().toString(), t.addOption(new Option(template.getID().toString(),
template.getLabel())); template.getLabel()));
} }
} }
} }
private void setDefaultLifecycle(BigDecimal lifecycleID, private void setDefaultLifecycle(BigDecimal lifecycleID,
ContentSection section, ContentSection section,
ContentType contentType) { ContentType contentType) {
//associate a default lifecycle //associate a default lifecycle
try { try {
@ -530,11 +523,10 @@ public class CreateType extends CMSForm
if (lifecycleID.intValue() != -1) { if (lifecycleID.intValue() != -1) {
LifecycleDefinition lifecycle = new LifecycleDefinition(lifecycleID); LifecycleDefinition lifecycle = new LifecycleDefinition(lifecycleID);
ContentTypeLifecycleDefinition.updateLifecycleDefinition(section, ContentTypeLifecycleDefinition.updateLifecycleDefinition(section,
contentType, lifecycle); contentType, lifecycle);
} else { } else {
//remove the association //remove the association
ContentTypeLifecycleDefinition.removeLifecycleDefinition ContentTypeLifecycleDefinition.removeLifecycleDefinition(section, contentType);
(section, contentType);
} }
} }
} catch (DataObjectNotFoundException ex) { } catch (DataObjectNotFoundException ex) {
@ -544,17 +536,16 @@ public class CreateType extends CMSForm
} }
private void setDefaultWorkflow(BigDecimal workflowID, private void setDefaultWorkflow(BigDecimal workflowID,
ContentSection section, ContentSection section,
ContentType contentType) { ContentType contentType) {
//associate a default workflow //associate a default workflow
try { try {
if ( workflowID != null) { if (workflowID != null) {
if(workflowID.intValue() != -1) { if (workflowID.intValue() != -1) {
// Set default workflow definition association. // Set default workflow definition association.
WorkflowTemplate template = new WorkflowTemplate(new OID(WorkflowTemplate.BASE_DATA_OBJECT_TYPE, workflowID)); WorkflowTemplate template = new WorkflowTemplate(new OID(WorkflowTemplate.BASE_DATA_OBJECT_TYPE, workflowID));
ContentTypeWorkflowTemplate. ContentTypeWorkflowTemplate.updateWorkflowTemplate(section, contentType, template);
updateWorkflowTemplate(section, contentType, template);
} else { } else {
// Remove the association. // Remove the association.
ContentTypeWorkflowTemplate.removeWorkflowTemplate(section, contentType); ContentTypeWorkflowTemplate.removeWorkflowTemplate(section, contentType);
@ -565,5 +556,4 @@ public class CreateType extends CMSForm
} }
} }
} }

View File

@ -18,7 +18,6 @@
*/ */
package com.arsdigita.cms.ui.type; package com.arsdigita.cms.ui.type;
import com.arsdigita.bebop.ColumnPanel; import com.arsdigita.bebop.ColumnPanel;
import com.arsdigita.bebop.FormData; import com.arsdigita.bebop.FormData;
import com.arsdigita.bebop.FormProcessException; import com.arsdigita.bebop.FormProcessException;
@ -45,7 +44,6 @@ import com.arsdigita.util.UncheckedWrapperException;
import java.math.BigDecimal; import java.math.BigDecimal;
import java.util.TooManyListenersException; import java.util.TooManyListenersException;
/** /**
* This class contains a form component to that allows adding * This class contains a form component to that allows adding
* already-existing content type to a content section. * 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 $ * @version $Id: SelectType.java 287 2005-02-22 00:29:02Z sskracic $
*/ */
public class SelectType extends CMSForm public class SelectType extends CMSForm
implements PrintListener, FormSubmissionListener, FormProcessListener { implements PrintListener, FormSubmissionListener, FormProcessListener {
private final static String TYPES = "types"; private final static String TYPES = "types";
private CheckboxGroup m_typesCheckbox; private CheckboxGroup m_typesCheckbox;
private Submit m_submit; private Submit m_submit;
private Submit m_cancel; private Submit m_cancel;
@ -83,14 +80,13 @@ public class SelectType extends CMSForm
m_cancel = new Submit("cancel"); m_cancel = new Submit("cancel");
m_cancel.setButtonLabel("Cancel"); m_cancel.setButtonLabel("Cancel");
s.add(m_cancel); s.add(m_cancel);
add(s, ColumnPanel.FULL_WIDTH|ColumnPanel.CENTER); add(s, ColumnPanel.FULL_WIDTH | ColumnPanel.CENTER);
addProcessListener(this); addProcessListener(this);
addSubmissionListener(new TypeSecurityListener()); addSubmissionListener(new TypeSecurityListener());
addSubmissionListener(this); addSubmissionListener(this);
} }
/** /**
* Generate a checkbox list of all content type not associated * Generate a checkbox list of all content type not associated
* with the current content section * with the current content section
@ -103,13 +99,16 @@ public class SelectType extends CMSForm
ContentSection section = CMS.getContext().getContentSection(); ContentSection section = CMS.getContext().getContentSection();
ContentTypeCollection contentTypes = ContentTypeCollection contentTypes =
section.getNotAssociatedContentTypes(); section.getNotAssociatedContentTypes();
contentTypes.addOrder(ContentType.LABEL); contentTypes.addOrder(ContentType.LABEL);
while (contentTypes.next()) { while (contentTypes.next()) {
ContentType contentType = contentTypes.getContentType(); ContentType contentType = contentTypes.getContentType();
t.addOption(new Option(contentType.getID().toString(), Label label = new Label(contentType.getLabel());
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 { public void submitted(FormSectionEvent event) throws FormProcessException {
PageState state = event.getPageState(); PageState state = event.getPageState();
if ( isCancelled(state) ) { if (isCancelled(state)) {
throw new FormProcessException("cancelled"); throw new FormProcessException("cancelled");
} }
} }
@ -135,7 +134,6 @@ public class SelectType extends CMSForm
return m_cancel.isSelected(state); return m_cancel.isSelected(state);
} }
/** /**
* Processes form listener which updates a life cycle * Processes form listener which updates a life cycle
*/ */
@ -146,14 +144,14 @@ public class SelectType extends CMSForm
String[] types = (String[]) data.get(TYPES); String[] types = (String[]) data.get(TYPES);
ContentType type; ContentType type;
if ( types != null ) { if (types != null) {
for ( int i = 0; i < types.length; i++ ) { for (int i = 0; i < types.length; i++) {
try { try {
type = new ContentType(new BigDecimal(types[i])); type = new ContentType(new BigDecimal(types[i]));
section.addContentType(type); section.addContentType(type);
} catch (DataObjectNotFoundException ex) { } catch (DataObjectNotFoundException ex) {
throw new UncheckedWrapperException("Content Type ID#" + types[i] + throw new UncheckedWrapperException("Content Type ID#" + types[i]
" not found", ex); + " not found", ex);
} }
} }
@ -162,5 +160,4 @@ public class SelectType extends CMSForm
} }
} }
} }
} }