From: <mb...@re...> - 2005-01-18 14:52:24
|
Author: mbooth Date: 2005-01-18 15:42:28 +0100 (Tue, 18 Jan 2005) New Revision: 183 Modified: ccm-cms-types-mparticle/trunk/src/com/arsdigita/cms/contenttypes/ArticleSection.java ccm-cms-types-mparticle/trunk/src/com/arsdigita/cms/contenttypes/MultiPartArticle.java Log: Ensure that ArticleSection are in the permission context of their article Modified: ccm-cms-types-mparticle/trunk/src/com/arsdigita/cms/contenttypes/ArticleSection.java =================================================================== --- ccm-cms-types-mparticle/trunk/src/com/arsdigita/cms/contenttypes/ArticleSection.java 2005-01-18 13:56:42 UTC (rev 182) +++ ccm-cms-types-mparticle/trunk/src/com/arsdigita/cms/contenttypes/ArticleSection.java 2005-01-18 14:42:28 UTC (rev 183) @@ -25,6 +25,7 @@ import com.arsdigita.cms.TextAsset; import com.arsdigita.domain.DataObjectNotFoundException; import com.arsdigita.domain.DomainObjectFactory; +import com.arsdigita.kernel.permissions.PermissionService; import com.arsdigita.persistence.DataObject; import com.arsdigita.persistence.OID; import com.arsdigita.persistence.metadata.ObjectType; @@ -42,8 +43,7 @@ * @version $Id: //cms/content-types/mparticle/dev/src/com/arsdigita/cms/contenttypes/ArticleSection.java#7 $ */ public class ArticleSection extends ContentPage { - private static final Logger log = - Logger.getLogger(ArticleSection.class.getName()); + private static final Logger s_log = Logger.getLogger(ArticleSection.class); /** attributes names */ public static final String TEXT = "text"; @@ -159,4 +159,20 @@ public void setPageBreak(boolean val) { set(PAGE_BREAK, new Boolean(val)); } + + protected void afterSave() { + super.afterSave(); + + if( s_log.isDebugEnabled() ) { + s_log.debug( "Saved section " + getOID() ); + } + + // Would prefer to do this in beforeSave(), but getMPArticle() returns + // null + if( null == getLanguage() ) { + setLanguage( getMPArticle().getLanguage() ); + } + + PermissionService.setContext( this, getMPArticle() ); + } } Modified: ccm-cms-types-mparticle/trunk/src/com/arsdigita/cms/contenttypes/MultiPartArticle.java =================================================================== --- ccm-cms-types-mparticle/trunk/src/com/arsdigita/cms/contenttypes/MultiPartArticle.java 2005-01-18 13:56:42 UTC (rev 182) +++ ccm-cms-types-mparticle/trunk/src/com/arsdigita/cms/contenttypes/MultiPartArticle.java 2005-01-18 14:42:28 UTC (rev 183) @@ -111,28 +111,10 @@ super(type); } - protected void afterSave() { - DataAssociationCursor dac = ((DataAssociation) get(SECTIONS)).cursor(); - while( dac.next() ) { - ArticleSection section = (ArticleSection) - DomainObjectFactory.newInstance( dac.getDataObject() ); - - if( s_log.isDebugEnabled() ) { - s_log.debug( "Saving section " + section.getOID() ); - } - - section.setLanguage( getLanguage() ); - section.save(); - } - - super.afterSave(); - } - public String getBaseDataObjectType() { return BASE_DATA_OBJECT_TYPE; } - /** Accessor. Get the summary for this MultiPartArticle. */ public String getSummary() { return (String)get(SUMMARY); @@ -143,7 +125,6 @@ set(SUMMARY, summary); } - /** * Add the specified ArticleSection to this object. Sets the rank * of the association to be after all the other ArticleSections. |