From dc8305911495f1aa214e3529944b9a3e36c5fbbc Mon Sep 17 00:00:00 2001 From: jensp Date: Wed, 27 May 2009 12:28:57 +0000 Subject: [PATCH] =?UTF-8?q?Aktueller=20Code=20von=20GenericOrganization.?= =?UTF-8?q?=20Einf=C3=BCgen=20von=20Funktionen=20(Rollen)=20funktoniert=20?= =?UTF-8?q?nicht.=20Der=20Code=20hierf=C3=BCr=20basiert=20derzeit=20auf=20?= =?UTF-8?q?ccm-cms-types-contact=20(phones).=20Dieser=20Code=20ist=20jedoc?= =?UTF-8?q?h=20ein=20wenig=20seltsam.=20Ich=20werde=20jetzt=20Multipartart?= =?UTF-8?q?icle=20analysieren=20und=20GenericOrganization=20auf=20dieser?= =?UTF-8?q?=20Basis=20anpassen.=20Auf=20den=20ersten=20Blick=20schein=20de?= =?UTF-8?q?r=20Code=20f=C3=BCr=20die=20Verkn=C3=BCpfung=20zwischen=20dem?= =?UTF-8?q?=20Multipartarticle=20und=20seinen=20Sections=20einfacher=20zu?= =?UTF-8?q?=20verstehen=20zu=20sein=20(und=20wahrscheinlich=20auch=20saube?= =?UTF-8?q?rer...)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit git-svn-id: https://svn.libreccm.org/ccm/trunk@181 8810af33-2d31-482b-a856-94f89814c4df --- .../com/arsdigita/content-types/Contact.pdl | 13 +- .../arsdigita/cms/contenttypes/Contact.java | 154 +++++++++--------- .../cms/contenttypes/ContactInitializer.java | 100 ++++++------ .../cms/contenttypes/ContactPhone.java | 2 +- .../content-types/GenericOrganization.pdl | 36 ++++ .../cms/contenttypes/GenericOrganization.java | 92 ++++++++++- .../GenericOrganizationInitializer.java | 49 +++++- .../arsdigita/cms/ContentSectionConfig.java | 6 +- .../arsdigita/cms/SectionTemplateMapping.java | 14 ++ .../com/arsdigita/cms/dispatcher/CMSPage.java | 6 + .../ItemTemplatePatternGenerator.java | 7 + .../content-section/www/admin/item.jsp | 8 +- 12 files changed, 340 insertions(+), 147 deletions(-) diff --git a/ccm-cms-types-contact/pdl/com/arsdigita/content-types/Contact.pdl b/ccm-cms-types-contact/pdl/com/arsdigita/content-types/Contact.pdl index 4afce4c04..94a0a7615 100755 --- a/ccm-cms-types-contact/pdl/com/arsdigita/content-types/Contact.pdl +++ b/ccm-cms-types-contact/pdl/com/arsdigita/content-types/Contact.pdl @@ -46,13 +46,12 @@ object type Contact extends ContentPage { } association { - - Contact[0..1] associatedContactForItem = - join cms_items.item_id to contact_content_item_map.item_id, - join contact_content_item_map.contact_id to ct_contacts.contact_id; - ContentItem[0..n] associatedContentItemsForContact = - join ct_contacts.contact_id to contact_content_item_map.contact_id, - join contact_content_item_map.item_id to cms_items.item_id; + Contact[0..1] associatedContactForItem = + join cms_items.item_id to contact_content_item_map.item_id, + join contact_content_item_map.contact_id to ct_contacts.contact_id; + ContentItem[0..n] associatedContentItemsForContact = + join ct_contacts.contact_id to contact_content_item_map.contact_id, + join contact_content_item_map.item_id to cms_items.item_id; } diff --git a/ccm-cms-types-contact/src/com/arsdigita/cms/contenttypes/Contact.java b/ccm-cms-types-contact/src/com/arsdigita/cms/contenttypes/Contact.java index 77b3b7254..0d568fe17 100755 --- a/ccm-cms-types-contact/src/com/arsdigita/cms/contenttypes/Contact.java +++ b/ccm-cms-types-contact/src/com/arsdigita/cms/contenttypes/Contact.java @@ -66,9 +66,9 @@ public class Contact extends ContentPage { public static final String CONTACT_ADDRESS = "contactAddress"; public static final String PHONES = "phones"; - public static final String ITEMS = "associatedContentItemsForContact"; - - private static final Logger s_log = Logger.getLogger(Contact.class); + public static final String ITEMS = "associatedContentItemsForContact"; + + private static final Logger s_log = Logger.getLogger(Contact.class); /** data object type for this domain object */ public static final String BASE_DATA_OBJECT_TYPE = "com.arsdigita.cms.contenttypes.Contact"; @@ -79,81 +79,81 @@ public class Contact extends ContentPage { } /** - * Adds an association between this contact and the given content item. - * @param item - */ - public void addContentItem(ContentItem item) { - s_log.debug("item is " + item); - item.addToAssociation(getItemsForContact()); - } - - /** - * Deletes the association between this contact and the given content item. - * @param item - */ - public void removeContentItem(ContentItem item) { - s_log.debug("item is " + item); - DataOperation operation = SessionManager - .getSession() - .retrieveDataOperation( - "com.arsdigita.cms.contenttypes.removeContactFromContentItemAssociation"); - operation.setParameter("itemID", new Integer(item.getID().intValue())); - operation.execute(); - } - - /** - * Removes all mappings between this contact and any other content item. - * - */ - private void removeItemMappings() { - DataOperation operation = SessionManager - .getSession() - .retrieveDataOperation("com.arsdigita.cms.contenttypes.removeContactFromAllAssociations"); - operation.setParameter("contactID", new Integer(this.getID().intValue())); - operation.execute(); - } - - - /** - * Gets the DataAssociation that holds the mapping between this contact and any content items. - * @return - */ - public DataAssociation getItemsForContact() { - return (DataAssociation) get(ITEMS); - } - - - /** - * Returns the Contact for a given content item. - * @param item - * @return - */ - public static Contact getContactForItem(ContentItem item) { - s_log.debug("getting contact for item " + item); - DataQuery query = SessionManager.getSession().retrieveQuery( - "com.arsdigita.cms.contenttypes.getContactForItem"); - query.setParameter("itemID", item.getID()); - BigDecimal contactID; - Contact contact = null; - while (query.next()) { - contactID = (BigDecimal) query.get("contactID"); - contact = new Contact(contactID); - } - s_log.debug("returning contact " + contact); - return contact; - } - - - - - /** - * Constructor. Retrieves an object instance with the given id. - * @param id the id of the object to retrieve + * Adds an association between this contact and the given content item. + * @param item */ - public Contact( BigDecimal id ) throws DataObjectNotFoundException { - this(new OID(BASE_DATA_OBJECT_TYPE, id)); - } - + public void addContentItem(ContentItem item) { + s_log.debug("item is " + item); + item.addToAssociation(getItemsForContact()); + } + + /** + * Deletes the association between this contact and the given content item. + * @param item + */ + public void removeContentItem(ContentItem item) { + s_log.debug("item is " + item); + DataOperation operation = SessionManager + .getSession() + .retrieveDataOperation( + "com.arsdigita.cms.contenttypes.removeContactFromContentItemAssociation"); + operation.setParameter("itemID", new Integer(item.getID().intValue())); + operation.execute(); + } + + /** + * Removes all mappings between this contact and any other content item. + * + */ + private void removeItemMappings() { + DataOperation operation = SessionManager + .getSession() + .retrieveDataOperation("com.arsdigita.cms.contenttypes.removeContactFromAllAssociations"); + operation.setParameter("contactID", new Integer(this.getID().intValue())); + operation.execute(); + } + + + /** + * Gets the DataAssociation that holds the mapping between this contact and any content items. + * @return + */ + public DataAssociation getItemsForContact() { + return (DataAssociation) get(ITEMS); + } + + + /** + * Returns the Contact for a given content item. + * @param item + * @return + */ + public static Contact getContactForItem(ContentItem item) { + s_log.debug("getting contact for item " + item); + DataQuery query = SessionManager.getSession().retrieveQuery( + "com.arsdigita.cms.contenttypes.getContactForItem"); + query.setParameter("itemID", item.getID()); + BigDecimal contactID; + Contact contact = null; + while (query.next()) { + contactID = (BigDecimal) query.get("contactID"); + contact = new Contact(contactID); + } + s_log.debug("returning contact " + contact); + return contact; + } + + + + + /** + * Constructor. Retrieves an object instance with the given id. + * @param id the id of the object to retrieve + */ + public Contact( BigDecimal id ) throws DataObjectNotFoundException { + this(new OID(BASE_DATA_OBJECT_TYPE, id)); + } + /** * Constructor. Retrieves an object instance with the given OID. * diff --git a/ccm-cms-types-contact/src/com/arsdigita/cms/contenttypes/ContactInitializer.java b/ccm-cms-types-contact/src/com/arsdigita/cms/contenttypes/ContactInitializer.java index 773b7a9e4..5b4ce3baa 100755 --- a/ccm-cms-types-contact/src/com/arsdigita/cms/contenttypes/ContactInitializer.java +++ b/ccm-cms-types-contact/src/com/arsdigita/cms/contenttypes/ContactInitializer.java @@ -65,55 +65,55 @@ public class ContactInitializer extends ContentTypeInitializer { /** * Return the statically initialized list of phone types. */ - public static ArrayList getPhoneTypes(){ - return phoneTypesList; - } + public static ArrayList getPhoneTypes(){ + return phoneTypesList; + } + + public void init(LegacyInitEvent evt) { + super.init(evt); + + if (ContentSection.getConfig().getHasContactsAuthoringStep()) { - public void init(LegacyInitEvent evt) { - super.init(evt); - - if (ContentSection.getConfig().getHasContactsAuthoringStep()) { - - // Add the "Contact"authoring step - AuthoringKitWizard.registerAssetStep(getBaseType(), - getAuthoringStep(), getAuthoringStepLabel(), - getAuthoringStepDescription(), getAuthoringStepSortKey()); - - // and sort out the display - at the moment this is just the basic properties, addresses and phones - ContentItemTraversalAdapter associatedContactTraversalAdapter = new ContentItemTraversalAdapter(); - associatedContactTraversalAdapter.addAssociationProperty("/object/phones"); - associatedContactTraversalAdapter.addAssociationProperty("/object/contactAddress"); - - ContentItemTraversalAdapter.registerAssetAdapter( - "associatedContactForItem", - associatedContactTraversalAdapter, - "com.arsdigita.cms.dispatcher.SimpleXMLGenerator"); -} - - } - - private int getAuthoringStepSortKey() { - // TODO - workout what this does and possibly make it configurable - return 1; - } - - private GlobalizedMessage getAuthoringStepDescription() { - return new GlobalizedMessage( - "com.arsdigita.cms.contenttypes.contact_authoring_step_description", - "com.arsdigita.cms.contenttypes.ContactResources"); - } - - private GlobalizedMessage getAuthoringStepLabel() { - return new GlobalizedMessage( - "com.arsdigita.cms.contenttypes.contact_authoring_step_label", - "com.arsdigita.cms.contenttypes.ContactResources"); - } - - private Class getAuthoringStep() { - return AddContactPropertiesStep.class; - } - - private String getBaseType() { - return ContentPage.BASE_DATA_OBJECT_TYPE; - } + // Add the "Contact"authoring step + AuthoringKitWizard.registerAssetStep(getBaseType(), + getAuthoringStep(), getAuthoringStepLabel(), + getAuthoringStepDescription(), getAuthoringStepSortKey()); + + // and sort out the display - at the moment this is just the basic properties, addresses and phones + ContentItemTraversalAdapter associatedContactTraversalAdapter = new ContentItemTraversalAdapter(); + associatedContactTraversalAdapter.addAssociationProperty("/object/phones"); + associatedContactTraversalAdapter.addAssociationProperty("/object/contactAddress"); + + ContentItemTraversalAdapter.registerAssetAdapter( + "associatedContactForItem", + associatedContactTraversalAdapter, + "com.arsdigita.cms.dispatcher.SimpleXMLGenerator"); + } + + } + + private int getAuthoringStepSortKey() { + // TODO - workout what this does and possibly make it configurable + return 1; + } + + private GlobalizedMessage getAuthoringStepDescription() { + return new GlobalizedMessage( + "com.arsdigita.cms.contenttypes.contact_authoring_step_description", + "com.arsdigita.cms.contenttypes.ContactResources"); + } + + private GlobalizedMessage getAuthoringStepLabel() { + return new GlobalizedMessage( + "com.arsdigita.cms.contenttypes.contact_authoring_step_label", + "com.arsdigita.cms.contenttypes.ContactResources"); + } + + private Class getAuthoringStep() { + return AddContactPropertiesStep.class; + } + + private String getBaseType() { + return ContentPage.BASE_DATA_OBJECT_TYPE; + } } diff --git a/ccm-cms-types-contact/src/com/arsdigita/cms/contenttypes/ContactPhone.java b/ccm-cms-types-contact/src/com/arsdigita/cms/contenttypes/ContactPhone.java index c9b14df7b..007c8f0db 100755 --- a/ccm-cms-types-contact/src/com/arsdigita/cms/contenttypes/ContactPhone.java +++ b/ccm-cms-types-contact/src/com/arsdigita/cms/contenttypes/ContactPhone.java @@ -84,7 +84,7 @@ public class ContactPhone extends ContentItem { return BASE_DATA_OBJECT_TYPE; } - + //Accessors public String getPhoneType(){ return (String) get(PHONE_TYPE); } diff --git a/ccm-cms-types-genericorganization/pdl/com/arsdigita/content-types/GenericOrganization.pdl b/ccm-cms-types-genericorganization/pdl/com/arsdigita/content-types/GenericOrganization.pdl index 4bc7a713b..177348225 100644 --- a/ccm-cms-types-genericorganization/pdl/com/arsdigita/content-types/GenericOrganization.pdl +++ b/ccm-cms-types-genericorganization/pdl/com/arsdigita/content-types/GenericOrganization.pdl @@ -40,3 +40,39 @@ object type OrganizationFunction extends ContentItem { reference key ( ct_organizationfunctions.function_id ); } +association { + GenericOrganization[0..1] associatedOrganizationForItem = + join cms_items.item_id to genericorganization_content_item_map.item_id, + join genericorganization_content_item_map.organization_id to ct_genericorganizations.organization_id; + + ContentItem[0..n] associatedContentItemsForOrganization = + join ct_genericorganizations.organization_id to genericorganization_content_item_map.organization_id, + join genericorganization_content_item_map.item_id to cms_items.item_id; +} + +// As mentioned in ccm-cms-types-contact/Contact.pdl (orginal version) an association of the above pattern +// does not work when removing items from the association. Instead of this, an data operation has to be used. + +data operation removeGenericOrganizationFromContentItemAssociation { + do { + delete from genericorganization_content_item_map where item_id = :itemID + } +} + +data operation removeGenericOrganizationFromAllAssociations { + do { + delete from genericorganization_content_item_map where organization_id = :organizationID; + } +} + +query getGenericOrganizationForItem { + BigDecimal genericOrganizationID; + BigDecimal itemID; + + do { + select genericorganization_id, item_id from genericorganization_content_item_map where item_id = :itemID + } map { + genericOrganizationID = genericorganization_id; + itemID = item_id; + } +} diff --git a/ccm-cms-types-genericorganization/src/com/arsdigita/cms/contenttypes/GenericOrganization.java b/ccm-cms-types-genericorganization/src/com/arsdigita/cms/contenttypes/GenericOrganization.java index 96c587bb8..ee83fb4ca 100644 --- a/ccm-cms-types-genericorganization/src/com/arsdigita/cms/contenttypes/GenericOrganization.java +++ b/ccm-cms-types-genericorganization/src/com/arsdigita/cms/contenttypes/GenericOrganization.java @@ -28,6 +28,15 @@ import com.arsdigita.persistence.OID; import com.arsdigita.util.Assert; import java.math.BigDecimal; import com.arsdigita.persistence.DataCollection; +import com.arsdigita.persistence.DataAssociation; +import com.arsdigita.persistence.DataAssociationCursor; +import com.arsdigita.persistence.DataOperation; +import com.arsdigita.persistence.DataQuery; +import com.arsdigita.persistence.SessionManager; + +import org.apache.log4j.Logger; + + /** * An very generic type to represent an organization. * @@ -41,15 +50,20 @@ public class GenericOrganization extends ContentPage { public static final String FUNCTIONS = "functions"; public static final String BASE_DATA_OBJECT_TYPE = "com.arsdigita.cms.contenttypes.GenericOrganization"; + + public static final String ITEMS = "associatedContentItemsForGenericOrganization"; + private static final GenericOrganizationConfig s_config = new GenericOrganizationConfig(); - static { - s_config.load(); - } + private static final Logger s_log = Logger.getLogger(GenericOrganization.class); - public static final GenericOrganizationConfig getConfig () { - return s_config; - } +// static { +// s_config.load(); +// } + +// public static final GenericOrganizationConfig getConfig () { +// return s_config; +// } /** * Default constructor. This creates a new (empty) organization @@ -80,6 +94,66 @@ public class GenericOrganization extends ContentPage { Assert.exists(getContentType(), ContentType.class); } + //Functions for adding and removing associated ContentItems + + /** + * Adds an association. + * + * @param item The item to associated with the organization. + */ + public void addContentItem(ContentItem item) { + s_log.debug("item is " + item); + item.addToAssociation(getItemsForGenericOrganization()); + } + + /** + * Removes an association + * + * @item The item which should longer be associated with this organization. + */ + public void removeContentItem(ContentItem item) { + s_log.debug("item is " + item); + DataOperation operation = SessionManager.getSession().retrieveDataOperation("com.arsdigita.cms.contenttypes.removeGenericOrganizationFromContentItemAssociation"); + operation.setParameter("itemID", new Integer(item.getID().intValue())); + operation.execute(); + } + + /** + * Removes all mappings between this organization and any other content items + */ + private void removeItemMappings() { + DataOperation operation = SessionManager.getSession().retrieveDataOperation("com.arsdigita.cms.contenttypes.removeGenericOrganizationFromAllAssociations"); + operation.setParameter("organizationID", new Integer(this.getID().intValue())); + } + + /** + * Gets the DataAssociation object for this organization + */ + public DataAssociation getItemsForGenericOrganization() { + return (DataAssociation)get(ITEMS); + } + + /** + * Returns the organization for a given content item + * + * @param item + * @return The Organization + */ + public static GenericOrganization getGenericOrganizationForItem(ContentItem item) { + s_log.debug("getting contact for item " + item); + DataQuery query = SessionManager.getSession().retrieveQuery("com.arsdigita.cms.contenttypes.getGenericOrganizationForItem"); + query.setParameter("itemID", item.getID()); + BigDecimal orgaID; + GenericOrganization orga = null; + while(query.next()) { + orgaID = (BigDecimal)query.get("organizationID"); + orga = new GenericOrganization(orgaID); + } + s_log.debug("returning GenericOrganization " + orga); + return orga; + } + + /* accessors *************************************************/ public String getOrganizationName() { return (String)get(ORGANIZATIONNAME); @@ -118,4 +192,10 @@ public class GenericOrganization extends ContentPage { Assert.exists(organizationFunction, OrganizationFunction.class); remove(FUNCTIONS, organizationFunction); } + + private DataObject retrieveDataObject(String attr) { + return (DataObject)get(attr); + } + + } \ No newline at end of file diff --git a/ccm-cms-types-genericorganization/src/com/arsdigita/cms/contenttypes/GenericOrganizationInitializer.java b/ccm-cms-types-genericorganization/src/com/arsdigita/cms/contenttypes/GenericOrganizationInitializer.java index 74771e4a0..6a00bada0 100644 --- a/ccm-cms-types-genericorganization/src/com/arsdigita/cms/contenttypes/GenericOrganizationInitializer.java +++ b/ccm-cms-types-genericorganization/src/com/arsdigita/cms/contenttypes/GenericOrganizationInitializer.java @@ -26,7 +26,14 @@ import com.arsdigita.domain.DomainObjectInstantiator; import com.arsdigita.persistence.DataObject; import com.arsdigita.runtime.DomainInitEvent; import com.arsdigita.domain.SimpleDomainObjectTraversalAdapter; +import com.arsdigita.cms.ContentPage; import org.apache.log4j.Logger; +import com.arsdigita.cms.ui.authoring.AuthoringKitWizard; +import com.arsdigita.domain.SimpleDomainObjectTraversalAdapter; +import com.arsdigita.globalization.GlobalizedMessage; +import com.arsdigita.runtime.LegacyInitEvent; +import com.arsdigita.cms.ContentSection; +import com.arsdigita.cms.contenttypes.ui.genericOrganization.GenericOrganizationPropertiesStep; /** * @@ -47,9 +54,43 @@ public class GenericOrganizationInitializer extends ContentTypeInitializer { GenericOrganization.BASE_DATA_OBJECT_TYPE); } + public void init(DomainInitEvent evt) { super.init(evt); } + /*public void init(LegacyInitEvent evt) { + super.init(evt); + + if(ContentSection.getConfig().getHasGenericOrganizationsAuthoringStep()) { + AuthoringKitWizard.registerAssetStep(getBaseType(), + getAuthoringStep(), + getAuthoringStepLabel(), + getAuthoringStepDescription(), + getAuthoringStepSortKey()); + + ContentItemTraversalAdapter associatedGenericOrganizationTraversalAdapters = new ContentItemTraversalAdapter(); + associatedGenericOrganizationTraversalAdapters.addAssociationProperty("/object/functions"); + } + }*/ + + private int getAuthoringStepSortKey() { + return 1; + } + + private GlobalizedMessage getAuthoringStepDescription() { + return new GlobalizedMessage("com.arsdigita.cms.contenttypes.genericorganization_authoring_step_description", + "com.arsdigita.cms.contenttypes.GenericOrganizationResources"); + } + + private GlobalizedMessage getAuthoringStepLabel() { + return new GlobalizedMessage("com.arsdigita.cms.contenttypes.genericorganization_authoring_step_label", + "com.arsdigita.cms.contenttypes.GenericOrganizationResources"); + } + + private Class getAuthoringStep() { + //return AddGenericOrganizationPropertiesStep.class; + return GenericOrganizationPropertiesStep.class; + } public String[] getStylesheets() { return new String[] { "/static/content-types/com/arsdigita/cms/contenttypes/GenericOrganization.xsl" }; @@ -57,6 +98,10 @@ public class GenericOrganizationInitializer extends ContentTypeInitializer { public String getTraversalXML() { return "/WEB-INF/traversal-adapters/com/arsdigita/cms/contenttypes/GenericOrganization.xml"; - } - + } + + private String getBaseType() { + return ContentPage.BASE_DATA_OBJECT_TYPE; + } + } \ No newline at end of file diff --git a/ccm-cms/src/com/arsdigita/cms/ContentSectionConfig.java b/ccm-cms/src/com/arsdigita/cms/ContentSectionConfig.java index 6e4e09664..4f94667c0 100755 --- a/ccm-cms/src/com/arsdigita/cms/ContentSectionConfig.java +++ b/ccm-cms/src/com/arsdigita/cms/ContentSectionConfig.java @@ -793,8 +793,8 @@ public final class ContentSectionConfig extends AbstractConfig { return (String)get(m_categoryTreeOrdering); } - public boolean getHasContactsAuthoringStep() { - return ((Boolean) get(m_hasContactsAuthoringStep)).booleanValue(); - } + public boolean getHasContactsAuthoringStep() { + return ((Boolean) get(m_hasContactsAuthoringStep)).booleanValue(); + } } diff --git a/ccm-cms/src/com/arsdigita/cms/SectionTemplateMapping.java b/ccm-cms/src/com/arsdigita/cms/SectionTemplateMapping.java index 85f49834b..cfdcddf77 100755 --- a/ccm-cms/src/com/arsdigita/cms/SectionTemplateMapping.java +++ b/ccm-cms/src/com/arsdigita/cms/SectionTemplateMapping.java @@ -30,6 +30,8 @@ import com.arsdigita.mimetypes.MimeType; import java.math.BigDecimal; +import org.apache.log4j.Logger; + /** * Represents a mapping from (content section + content type) to a * template. This class is is package scope since it is part of the @@ -48,6 +50,8 @@ public class SectionTemplateMapping extends TemplateMapping { public static final String SECTION = "section"; public static final String CONTENT_TYPE = "contentType"; + private static final Logger logger = Logger.getLogger(SectionTemplateMapping.class); + // Default constructor public SectionTemplateMapping() { this(BASE_DATA_OBJECT_TYPE); @@ -228,6 +232,16 @@ public class SectionTemplateMapping extends TemplateMapping { DataCollection da = SessionManager.getSession().retrieve (BASE_DATA_OBJECT_TYPE); SectionTemplateCollection c = new SectionTemplateCollection(da); + //Debug code, inserted by jensp 2009-05-26 + if (section == null) { + logger.error("WARNING: section is NULL at this point!"); + } + if (section.ID == null) { + logger.error("WARNING: ACSObject.ID is NULL at this point!"); + } + if (section.getID() == null) { + logger.error("WARNING: section.getID() returns NULL at this point!"); + } c.addEqualsFilter(SECTION + "." + ACSObject.ID, section.getID()); c.addOrder(CONTENT_TYPE + "." + ContentType.LABEL); c.addOrder(USE_CONTEXT); diff --git a/ccm-cms/src/com/arsdigita/cms/dispatcher/CMSPage.java b/ccm-cms/src/com/arsdigita/cms/dispatcher/CMSPage.java index 9756bd2a7..7629c22a1 100755 --- a/ccm-cms/src/com/arsdigita/cms/dispatcher/CMSPage.java +++ b/ccm-cms/src/com/arsdigita/cms/dispatcher/CMSPage.java @@ -246,6 +246,8 @@ public class CMSPage extends Page implements ResourceHandler { RequestContext actx) throws IOException, ServletException { + s_log.error("Starting dispatch()..."); + DeveloperSupport.startStage("CMSPage.dispatch: serve page"); CMSExcursion excursion = new CMSExcursion() { @@ -255,11 +257,14 @@ public class CMSPage extends Page implements ResourceHandler { if (app == null) { // We're at the content center; do nothing. + s_log.info("dispatch: We're at the content center; do nothing."); } else if (app instanceof ContentSection) { + s_log.info("dispatch: Setting section = app"); section = (ContentSection) app; } else { // hack to deal with category browser mounted // under section app. + s_log.info("dispatch: hack for category browser"); app = app.getParentApplication(); if (app instanceof ContentSection) { section = (ContentSection) app; @@ -289,6 +294,7 @@ public class CMSPage extends Page implements ResourceHandler { throw new AccessDeniedException( "You do not have privileges to administer item " + itemID); } + } catch (DataObjectNotFoundException donfe) { s_log.warn("Failed to load content item " + itemID); } diff --git a/ccm-cms/src/com/arsdigita/cms/dispatcher/ItemTemplatePatternGenerator.java b/ccm-cms/src/com/arsdigita/cms/dispatcher/ItemTemplatePatternGenerator.java index 74b99527a..3afd217a6 100755 --- a/ccm-cms/src/com/arsdigita/cms/dispatcher/ItemTemplatePatternGenerator.java +++ b/ccm-cms/src/com/arsdigita/cms/dispatcher/ItemTemplatePatternGenerator.java @@ -36,6 +36,8 @@ import com.arsdigita.cms.TemplateManagerFactory; import javax.servlet.http.HttpServletRequest; +import org.apache.log4j.Logger; + /** * This looks to see if there is a given item and if there is it returns @@ -43,6 +45,8 @@ import javax.servlet.http.HttpServletRequest; */ public class ItemTemplatePatternGenerator implements PatternGenerator { + private static final Logger logger = Logger.getLogger(ItemTemplatePatternGenerator.class); + private static ContentItemDispatcher s_disp = new ContentItemDispatcher(); public String[] generateValues(String key, @@ -60,6 +64,9 @@ public class ItemTemplatePatternGenerator implements PatternGenerator { if (mapping == null) { // there is no mapping so we try to get the default for the // content type + if (item.getContentSection() == null) { + logger.error("WARNING: item.getContentSection() returns NULL here!"); + } template = TemplateManagerFactory.getInstance().getDefaultTemplate (item.getContentSection(), item.getContentType(), diff --git a/ccm-cms/web/packages/content-section/www/admin/item.jsp b/ccm-cms/web/packages/content-section/www/admin/item.jsp index 33348b802..91f864493 100755 --- a/ccm-cms/web/packages/content-section/www/admin/item.jsp +++ b/ccm-cms/web/packages/content-section/www/admin/item.jsp @@ -41,7 +41,7 @@ // in the section change synchronized(this) { if (Utilities.getLastSectionRefresh(section).after(timestamp)) { - s_log.debug("refreshing itemPage"); + s_log.error("refreshing itemPage"); itemPage = new ContentItemPage(); itemPage.init(); timestamp = new Date(); @@ -49,6 +49,12 @@ } RequestContext context = DispatcherHelper.getRequestContext(request); + if(itemPage == null) { + s_log.error("WARNING: itemPage is NULL"); + } + else { + s_log.error("ALL OK: itemPage is not null"); + } itemPage.dispatch(request, response, context); s_log.debug("exited item.jsp's service method");