diff --git a/ccm-cms-types-agenda/pdl/com/arsdigita/content-types/Agenda.pdl b/ccm-cms-types-agenda/pdl/com/arsdigita/content-types/Agenda.pdl index 12893ff28..57814be87 100755 --- a/ccm-cms-types-agenda/pdl/com/arsdigita/content-types/Agenda.pdl +++ b/ccm-cms-types-agenda/pdl/com/arsdigita/content-types/Agenda.pdl @@ -23,7 +23,7 @@ import com.arsdigita.cms.*; // object type to hold extended attributes of agenda content type -object type Agenda extends TextPage { +object type Agenda extends GenericArticle { // The date and time for the agenda Date [0..1] agendaDate = ct_agendas.agenda_date TIMESTAMP; // The location for the agenda diff --git a/ccm-cms-types-agenda/src/WEB-INF/traversal-adapters/com/arsdigita/cms/contenttypes/Agenda.xml b/ccm-cms-types-agenda/src/WEB-INF/traversal-adapters/com/arsdigita/cms/contenttypes/Agenda.xml index 97e8f7a0a..06d4e2b96 100755 --- a/ccm-cms-types-agenda/src/WEB-INF/traversal-adapters/com/arsdigita/cms/contenttypes/Agenda.xml +++ b/ccm-cms-types-agenda/src/WEB-INF/traversal-adapters/com/arsdigita/cms/contenttypes/Agenda.xml @@ -6,7 +6,7 @@ --> - + diff --git a/ccm-cms-types-agenda/src/com/arsdigita/cms/contenttypes/Agenda.java b/ccm-cms-types-agenda/src/com/arsdigita/cms/contenttypes/Agenda.java index cfc9e4cb3..23ece51ff 100755 --- a/ccm-cms-types-agenda/src/com/arsdigita/cms/contenttypes/Agenda.java +++ b/ccm-cms-types-agenda/src/com/arsdigita/cms/contenttypes/Agenda.java @@ -18,10 +18,8 @@ */ package com.arsdigita.cms.contenttypes; - import com.arsdigita.cms.ContentType; import com.arsdigita.cms.TextAsset; -import com.arsdigita.cms.TextPage; import com.arsdigita.domain.DataObjectNotFoundException; import com.arsdigita.persistence.DataObject; import com.arsdigita.persistence.OID; @@ -52,7 +50,7 @@ import java.util.Date; * * @version $Revision: #6 $ $Date: 2004/08/17 $ **/ -public class Agenda extends TextPage { +public class Agenda extends GenericArticle { /** PDL property name for summary */ public static final String SUMMARY = "summary"; @@ -68,12 +66,9 @@ public class Agenda extends TextPage { public static final String CONTACT_INFO = "contactInfo"; /** PDL property name for creation date */ public static final String CREATION_DATE = "creationDate"; - /** Data object type for this domain object */ - public static final String BASE_DATA_OBJECT_TYPE - = "com.arsdigita.cms.contenttypes.Agenda"; + public static final String BASE_DATA_OBJECT_TYPE = "com.arsdigita.cms.contenttypes.Agenda"; /** Data object type for this domain object (for CMS compatibility) */ - private static final Logger s_log = Logger.getLogger(Logger.class); /** @@ -136,7 +131,7 @@ public class Agenda extends TextPage { */ public void beforeSave() { super.beforeSave(); - + Assert.exists(getContentType(), ContentType.class); } @@ -145,11 +140,11 @@ public class Agenda extends TextPage { return (Date) get(AGENDA_DATE); } - public String getDisplayAgendaDate () { + public String getDisplayAgendaDate() { Date d = getAgendaDate(); - return (d != null) ? DateFormat.getDateInstance(DateFormat.LONG) - .format(d) : null; + return (d != null) ? DateFormat.getDateInstance(DateFormat.LONG).format(d) : null; } + public void setAgendaDate(Date agendaDate) { set(AGENDA_DATE, agendaDate); } @@ -163,7 +158,7 @@ public class Agenda extends TextPage { } public String getAttendees() { - return (String) get(ATTENDEES); + return (String) get(ATTENDEES); } public void setAttendees(String attendees) { @@ -171,7 +166,7 @@ public class Agenda extends TextPage { } public String getSubjectItems() { - return (String) get(SUBJECT_ITEMS); + return (String) get(SUBJECT_ITEMS); } public void setSubjectItems(String subjectItems) { @@ -201,7 +196,6 @@ public class Agenda extends TextPage { public void setCreationDate(Date creationDate) { set(CREATION_DATE, creationDate); } - // Search stuff to allow the content type to be searchable public static final int SUMMARY_LENGTH = 200; @@ -209,12 +203,11 @@ public class Agenda extends TextPage { TextAsset ta = getTextAsset(); if (ta != null) { - return com.arsdigita.util.StringUtils.truncateString(ta.getText(), - SUMMARY_LENGTH, - true); + return com.arsdigita.util.StringUtils.truncateString(ta.getText(), + SUMMARY_LENGTH, + true); } else { return ""; } } - } diff --git a/ccm-cms-types-article/src/WEB-INF/content-types/com/arsdigita/cms/contenttypes/Article.xml b/ccm-cms-types-article/src/WEB-INF/content-types/com/arsdigita/cms/contenttypes/Article.xml index ac38585c7..62c7e269c 100755 --- a/ccm-cms-types-article/src/WEB-INF/content-types/com/arsdigita/cms/contenttypes/Article.xml +++ b/ccm-cms-types-article/src/WEB-INF/content-types/com/arsdigita/cms/contenttypes/Article.xml @@ -16,13 +16,6 @@ - - diff --git a/ccm-cms-types-event/pdl/com/arsdigita/content-types/Event.pdl b/ccm-cms-types-event/pdl/com/arsdigita/content-types/Event.pdl index 9c32599f2..cacb8b4c8 100755 --- a/ccm-cms-types-event/pdl/com/arsdigita/content-types/Event.pdl +++ b/ccm-cms-types-event/pdl/com/arsdigita/content-types/Event.pdl @@ -23,7 +23,7 @@ import com.arsdigita.cms.*; // object type to hold extended attributes of event content type -object type Event extends TextPage { +object type Event extends GenericArticle { // The starting date and time of the event, so the events content type // can be used by calendar Date [0..1] startDate = ct_events.start_date DATE; diff --git a/ccm-cms-types-event/src/WEB-INF/traversal-adapters/com/arsdigita/cms/contenttypes/Event.xml b/ccm-cms-types-event/src/WEB-INF/traversal-adapters/com/arsdigita/cms/contenttypes/Event.xml index cd7a4667f..9c5ab03dc 100755 --- a/ccm-cms-types-event/src/WEB-INF/traversal-adapters/com/arsdigita/cms/contenttypes/Event.xml +++ b/ccm-cms-types-event/src/WEB-INF/traversal-adapters/com/arsdigita/cms/contenttypes/Event.xml @@ -7,7 +7,7 @@ - + - *

This class extends {@link com.arsdigita.cms.TextPage content page} and + *

This class extends {@link com.arsdigita.cms.contenttypes.GenericArticle content page} and * inherits title, name (filename), body (TextAsset), and metadata. It adds * extended attributes specific for an event:

*
@@ -70,21 +67,17 @@ import java.util.Date; * * @version $Revision: #6 $ $Date: 2004/08/17 $ **/ -public class Event extends TextPage { +public class Event extends GenericArticle { private final static org.apache.log4j.Logger s_log = - org.apache.log4j.Logger.getLogger(Event.class); - + org.apache.log4j.Logger.getLogger(Event.class); /** PDL property name for lead (summary) */ public static final String LEAD = "lead"; - /** PDL property name for event date */ public static final String START_DATE = "startDate"; public static final String END_DATE = "endDate"; - public static final String START_TIME = "startTime"; public static final String END_TIME = "endTime"; - public static final String EVENT_DATE = "eventDate"; /** PDL property name for location */ public static final String LOCATION = "location"; @@ -96,20 +89,17 @@ public class Event extends TextPage { public static final String MAP_LINK = "mapLink"; /** PDL property name for cost */ public static final String COST = "cost"; - public static final String RECENT_EVENT = "com.arsdigita.cms.contenttypes.RecentEvent"; - /** Data object type for this domain object */ - public static final String BASE_DATA_OBJECT_TYPE - = "com.arsdigita.cms.contenttypes.Event"; - + public static final String BASE_DATA_OBJECT_TYPE = "com.arsdigita.cms.contenttypes.Event"; private static final EventConfig s_config = new EventConfig(); + static { - s_config.load(); + s_config.load(); } - public static final EventConfig getConfig() - { - return s_config; + + public static final EventConfig getConfig() { + return s_config; } /** @@ -172,48 +162,45 @@ public class Event extends TextPage { */ public void beforeSave() { super.beforeSave(); - + Assert.exists(getContentType(), ContentType.class); } - public String formatDate (Date date) { - return (date != null) ? DateFormat.getDateInstance(DateFormat.LONG) - .format(date) : null; + public String formatDate(Date date) { + return (date != null) ? DateFormat.getDateInstance(DateFormat.LONG).format(date) : null; } - - public String formatTime (Date time) { - return (time != null) ? DateFormat.getTimeInstance(DateFormat.SHORT) - .format(time) : null; + public String formatTime(Date time) { + return (time != null) ? DateFormat.getTimeInstance(DateFormat.SHORT).format(time) : null; } /* accessors *****************************************************/ - public Date getStartTime () { - return (Date)get(START_TIME); + public Date getStartTime() { + return (Date) get(START_TIME); } - public void setStartTime (Date startTime) { + public void setStartTime(Date startTime) { set(START_TIME, startTime); } - public String getDisplayStartTime () { + public String getDisplayStartTime() { return formatTime(getStartTime()); } - public Date getEndTime () { - return (Date)get(END_TIME); + public Date getEndTime() { + return (Date) get(END_TIME); } - public void setEndTime (Date endTime) { + public void setEndTime(Date endTime) { set(END_TIME, endTime); } - public String getDisplayEndTime () { + public String getDisplayEndTime() { return formatTime(getEndTime()); } public Date getStartDate() { - Date startDate = (Date) get (START_DATE); + Date startDate = (Date) get(START_DATE); return startDate; } @@ -226,7 +213,7 @@ public class Event extends TextPage { } public Date getEndDate() { - Date endDate = (Date) get (END_DATE); + Date endDate = (Date) get(END_DATE); return endDate; } @@ -242,7 +229,6 @@ public class Event extends TextPage { return (String) get(EVENT_DATE); } - public void setEventDate(String eventDate) { set(EVENT_DATE, eventDate); } @@ -294,13 +280,13 @@ public class Event extends TextPage { public void setCost(String cost) { set(COST, cost); } - // Search stuff to allow the content type to be searchable public static final int SUMMARY_LENGTH = 200; + public String getSearchSummary() { return com.arsdigita.util.StringUtils.truncateString(getLead(), - SUMMARY_LENGTH, - true); + SUMMARY_LENGTH, + true); } diff --git a/ccm-cms-types-legalnotice/pdl/com/arsdigita/content-types/LegalNotice.pdl b/ccm-cms-types-legalnotice/pdl/com/arsdigita/content-types/LegalNotice.pdl index ea0c86a57..bfff2e811 100755 --- a/ccm-cms-types-legalnotice/pdl/com/arsdigita/content-types/LegalNotice.pdl +++ b/ccm-cms-types-legalnotice/pdl/com/arsdigita/content-types/LegalNotice.pdl @@ -22,7 +22,7 @@ model com.arsdigita.cms.contenttypes; import com.arsdigita.cms.*; // object type to hold extended attributes of legal notice content type -object type LegalNotice extends TextPage { +object type LegalNotice extends GenericArticle { // The government issued UID for the legal notice String [0..1] governmentUID = ct_legal_notices.government_uid VARCHAR(100); diff --git a/ccm-cms-types-legalnotice/src/com/arsdigita/cms/contenttypes/LegalNotice.java b/ccm-cms-types-legalnotice/src/com/arsdigita/cms/contenttypes/LegalNotice.java index cbbb26a2f..c1662b50a 100755 --- a/ccm-cms-types-legalnotice/src/com/arsdigita/cms/contenttypes/LegalNotice.java +++ b/ccm-cms-types-legalnotice/src/com/arsdigita/cms/contenttypes/LegalNotice.java @@ -18,10 +18,8 @@ */ package com.arsdigita.cms.contenttypes; - import com.arsdigita.cms.ContentType; import com.arsdigita.cms.TextAsset; -import com.arsdigita.cms.TextPage; import com.arsdigita.domain.DataObjectNotFoundException; import com.arsdigita.persistence.DataObject; import com.arsdigita.persistence.OID; @@ -35,16 +33,14 @@ import java.math.BigDecimal; * * @version $Revision: #6 $ $Date: 2004/08/17 $ **/ -public class LegalNotice extends TextPage { +public class LegalNotice extends GenericArticle { /** PDL property name for government UID */ public static final String GOVERNMENT_UID = "governmentUID"; - /** Data object type for this domain object */ - public static final String BASE_DATA_OBJECT_TYPE - = "com.arsdigita.cms.contenttypes.LegalNotice"; - + public static final String BASE_DATA_OBJECT_TYPE = "com.arsdigita.cms.contenttypes.LegalNotice"; private static final Logger s_log = Logger.getLogger(LegalNotice.class); + public LegalNotice() { this(BASE_DATA_OBJECT_TYPE); } @@ -67,7 +63,7 @@ public class LegalNotice extends TextPage { public void beforeSave() { super.beforeSave(); - + Assert.exists(getContentType(), ContentType.class); } @@ -79,7 +75,6 @@ public class LegalNotice extends TextPage { public void setGovernmentUID(String governmentUID) { set(GOVERNMENT_UID, governmentUID); } - // Search stuff to allow the content type to be searchable public static final int SUMMARY_LENGTH = 200; @@ -88,11 +83,10 @@ public class LegalNotice extends TextPage { if (ta != null) { return com.arsdigita.util.StringUtils.truncateString(ta.getText(), - SUMMARY_LENGTH, - true); + SUMMARY_LENGTH, + true); } else { return ""; } } - } diff --git a/ccm-cms-types-minutes/pdl/com/arsdigita/content-types/Minutes.pdl b/ccm-cms-types-minutes/pdl/com/arsdigita/content-types/Minutes.pdl index 84934950e..b46dd6ab5 100755 --- a/ccm-cms-types-minutes/pdl/com/arsdigita/content-types/Minutes.pdl +++ b/ccm-cms-types-minutes/pdl/com/arsdigita/content-types/Minutes.pdl @@ -23,7 +23,7 @@ import com.arsdigita.cms.*; // object type to hold extended attributes of minutes content type -object type Minutes extends TextPage { +object type Minutes extends GenericArticle { // The minute number for the minutes String [0..1] minuteNumber = ct_minutes.minute_number VARCHAR(100); // The description of the minutes diff --git a/ccm-cms-types-minutes/src/com/arsdigita/cms/contenttypes/Minutes.java b/ccm-cms-types-minutes/src/com/arsdigita/cms/contenttypes/Minutes.java index 75f493acc..eaf5a1356 100755 --- a/ccm-cms-types-minutes/src/com/arsdigita/cms/contenttypes/Minutes.java +++ b/ccm-cms-types-minutes/src/com/arsdigita/cms/contenttypes/Minutes.java @@ -18,9 +18,7 @@ */ package com.arsdigita.cms.contenttypes; - import com.arsdigita.cms.ContentType; -import com.arsdigita.cms.TextPage; import com.arsdigita.domain.DataObjectNotFoundException; import com.arsdigita.persistence.DataObject; import com.arsdigita.persistence.OID; @@ -34,11 +32,10 @@ import java.math.BigDecimal; * * @version $Revision: #6 $ $Date: 2004/08/17 $ **/ -public class Minutes extends TextPage { +public class Minutes extends GenericArticle { private static Logger s_log = - Logger.getLogger(Minutes.class); - + Logger.getLogger(Minutes.class); /** PDL property name for attendees */ public static final String ATTENDEES = "attendees"; /** PDL property name for description */ @@ -49,10 +46,8 @@ public class Minutes extends TextPage { public static final String MINUTE_NUMBER = "minuteNumber"; /** PDL property name for description */ public static final String DESCRIPTION_OF_MINUTES = "descriptionOfMinutes"; - /** Data object type for this domain object */ - public static final String BASE_DATA_OBJECT_TYPE - = "com.arsdigita.cms.contenttypes.Minutes"; + public static final String BASE_DATA_OBJECT_TYPE = "com.arsdigita.cms.contenttypes.Minutes"; public Minutes() { this(BASE_DATA_OBJECT_TYPE); @@ -74,10 +69,9 @@ public class Minutes extends TextPage { super(type); } - public void beforeSave() { super.beforeSave(); - + Assert.exists(getContentType(), ContentType.class); } @@ -121,12 +115,11 @@ public class Minutes extends TextPage { public void setMinuteNumber(String minuteNumber) { set(MINUTE_NUMBER, minuteNumber); } - public static final int SUMMARY_LENGTH = 200; + public String getSearchSummary() { return com.arsdigita.util.StringUtils.truncateString(getDescription(), - SUMMARY_LENGTH, - true); + SUMMARY_LENGTH, + true); } - } diff --git a/ccm-cms-types-pressrelease/pdl/com/arsdigita/content-types/PressRelease.pdl b/ccm-cms-types-pressrelease/pdl/com/arsdigita/content-types/PressRelease.pdl index 3bbfed8f6..286fcfcf5 100755 --- a/ccm-cms-types-pressrelease/pdl/com/arsdigita/content-types/PressRelease.pdl +++ b/ccm-cms-types-pressrelease/pdl/com/arsdigita/content-types/PressRelease.pdl @@ -25,7 +25,7 @@ import com.arsdigita.cms.*; -object type PressRelease extends TextPage { +object type PressRelease extends GenericArticle { // contact information text for the press release String [0..1] contactInfo = ct_press_releases.contact_info VARCHAR(1000); // the text summary for the press release diff --git a/ccm-cms-types-pressrelease/src/com/arsdigita/cms/contenttypes/PressRelease.java b/ccm-cms-types-pressrelease/src/com/arsdigita/cms/contenttypes/PressRelease.java index f88b31915..99d6a81fa 100755 --- a/ccm-cms-types-pressrelease/src/com/arsdigita/cms/contenttypes/PressRelease.java +++ b/ccm-cms-types-pressrelease/src/com/arsdigita/cms/contenttypes/PressRelease.java @@ -18,9 +18,7 @@ */ package com.arsdigita.cms.contenttypes; - import com.arsdigita.cms.ContentType; -import com.arsdigita.cms.TextPage; import com.arsdigita.domain.DataObjectNotFoundException; import com.arsdigita.persistence.DataObject; import com.arsdigita.persistence.OID; @@ -34,26 +32,23 @@ import java.math.BigDecimal; * reference purposes. Reference code is an arbitrary string that is used for * out-of-system reference. The type inherits name (filename), title, body * (TextAsset), and metadata from - * com.arsdigita.aplaws.cms.TextPage, and also provides the + * com.arsdigita.cms.contenttypes.Genericrticle, and also provides the * capability to associate contact information with this press release. * * @version $Revision: #6 $ $Date: 2004/08/17 $ **/ -public class PressRelease extends TextPage { +public class PressRelease extends GenericArticle { // is the CardBin sort of contact support needed here? // implements ContactSupport { - /** PDL property name for contact info */ public static final String CONTACT_INFO = "contactInfo"; /** PDL property name for summary */ public static final String SUMMARY = "summary"; /** PDL property name for reference code */ public static final String REFERENCE_CODE = "referenceCode"; - /** Data object type for this domain object */ - public static final String BASE_DATA_OBJECT_TYPE - = "com.arsdigita.cms.contenttypes.PressRelease"; + public static final String BASE_DATA_OBJECT_TYPE = "com.arsdigita.cms.contenttypes.PressRelease"; public PressRelease() { this(BASE_DATA_OBJECT_TYPE); @@ -77,7 +72,7 @@ public class PressRelease extends TextPage { public void beforeSave() { super.beforeSave(); - + Assert.exists(getContentType(), ContentType.class); } @@ -105,12 +100,11 @@ public class PressRelease extends TextPage { public void setReferenceCode(String refCode) { set(REFERENCE_CODE, refCode); } - public static final int SUMMARY_LENGTH = 200; + public String getSearchSummary() { return com.arsdigita.util.StringUtils.truncateString(getSummary(), - SUMMARY_LENGTH, - true); + SUMMARY_LENGTH, + true); } - } diff --git a/ccm-cms/pdl/com/arsdigita/content-section/TextPage.pdl b/ccm-cms/pdl/com/arsdigita/content-section/TextPage.pdl.noLongerInUse similarity index 100% rename from ccm-cms/pdl/com/arsdigita/content-section/TextPage.pdl rename to ccm-cms/pdl/com/arsdigita/content-section/TextPage.pdl.noLongerInUse diff --git a/ccm-cms/pdl/com/arsdigita/content-types/GenericArticle.pdl b/ccm-cms/pdl/com/arsdigita/content-types/GenericArticle.pdl index 9ae6831dc..5a270e4d5 100644 --- a/ccm-cms/pdl/com/arsdigita/content-types/GenericArticle.pdl +++ b/ccm-cms/pdl/com/arsdigita/content-types/GenericArticle.pdl @@ -22,10 +22,11 @@ model com.arsdigita.cms.contenttypes; import com.arsdigita.cms.*; import com.arsdigita.kernel.*; -object type GenericArticle extends TextPage { +object type GenericArticle extends ContentPage { + + component TextAsset[0..1] textAsset = join cms_text_pages.text_id to cms_text.text_id; reference key (cms_articles.article_id); - } //association { @@ -33,12 +34,12 @@ object type GenericArticle extends TextPage { // component GenericArticleImageAssociation[0..n] imageCaptions = join cms_articles.article_id // to cms_article_image_map.article_id; // -// GenericArticle[1..1] captionArticle = join cms_article_image_map.article_id to cms_articles.article_id; +// GenericArticle[1..1] captionArticle = join cms_article_image_map.article_id to cms_articles.article_id; // //} // //object type GenericArticleImageAssociation extends ContentItem { -// String[0..1] caption = cms_article_image_map.caption VARCHAR(4000); +// String[0..1] caption = cms_article_image_map.caption VARCHAR(4000); // // // Only including these ID attributes for legacy purposes // BigDecimal[0..1] articleId = cms_article_image_map.article_id INTEGER; diff --git a/ccm-cms/src/com/arsdigita/cms/TextPage.java b/ccm-cms/src/com/arsdigita/cms/TextPage.java.noLongerInUse similarity index 100% rename from ccm-cms/src/com/arsdigita/cms/TextPage.java rename to ccm-cms/src/com/arsdigita/cms/TextPage.java.noLongerInUse diff --git a/ccm-cms/src/com/arsdigita/cms/contenttypes/GenericArticle.java b/ccm-cms/src/com/arsdigita/cms/contenttypes/GenericArticle.java index 238dc5b9c..decb512db 100644 --- a/ccm-cms/src/com/arsdigita/cms/contenttypes/GenericArticle.java +++ b/ccm-cms/src/com/arsdigita/cms/contenttypes/GenericArticle.java @@ -18,7 +18,8 @@ */ package com.arsdigita.cms.contenttypes; -import com.arsdigita.cms.TextPage; +import com.arsdigita.cms.ContentPage; +import com.arsdigita.cms.TextAsset; import com.arsdigita.domain.DataObjectNotFoundException; import com.arsdigita.persistence.DataObject; import com.arsdigita.persistence.OID; @@ -32,13 +33,14 @@ import java.math.BigDecimal; * @version $Revision: #28 $ $Date: 2004/08/17 $ * @version $Id: Article.java 2070 2010-01-28 08:47:41Z pboy $ */ -public class GenericArticle extends TextPage { +public class GenericArticle extends ContentPage { public static final String BASE_DATA_OBJECT_TYPE = - "com.arsdigita.cms.contenttypes.GenericArticle"; - + "com.arsdigita.cms.contenttypes.GenericArticle"; + public static final String TEXT_ASSET = "textAsset"; + protected static final int SUMMARY_SIZE = 1024; private static org.apache.log4j.Logger s_log = - org.apache.log4j.Logger.getLogger(GenericArticle.class); + org.apache.log4j.Logger.getLogger(GenericArticle.class); /** * Default constructor. This creates a new article. @@ -60,7 +62,7 @@ public class GenericArticle extends TextPage { } public GenericArticle(String type) { - super(type); + super(type); } /** @@ -88,4 +90,41 @@ public class GenericArticle extends TextPage { public String getBaseDataObjectType() { return BASE_DATA_OBJECT_TYPE; } + + /** + * Return the text asset for this TextPage. Could return + * null if there is no text body actually associated with the page + */ + public TextAsset getTextAsset() { + DataObject text = (DataObject) get(TEXT_ASSET); + if (text == null) { + return null; + } else { + return new TextAsset(text); + } + } + + /** + * Pass in a null value to remove the text of this item. + * Explicitly call text.delete() to remove the text from the database + */ + public void setTextAsset(TextAsset text) { + setAssociation(TEXT_ASSET, text); + } + + /** + * Return a short summary of the text body for search. + * This method is WRONG, because the text body could actually + * be extremely large, and doing substring on it is NOT safe + */ + public String getSearchSummary() { + TextAsset a = getTextAsset(); + + if (a == null) { + return ""; + } + return com.arsdigita.util.StringUtils.truncateString(a.getText(), + SUMMARY_SIZE, + true); + } } diff --git a/ccm-cms/src/com/arsdigita/cms/installer/xml/TextPageHelper.java b/ccm-cms/src/com/arsdigita/cms/installer/xml/GenericArticleHelper.java similarity index 81% rename from ccm-cms/src/com/arsdigita/cms/installer/xml/TextPageHelper.java rename to ccm-cms/src/com/arsdigita/cms/installer/xml/GenericArticleHelper.java index f44821fa6..21d1fb65b 100755 --- a/ccm-cms/src/com/arsdigita/cms/installer/xml/TextPageHelper.java +++ b/ccm-cms/src/com/arsdigita/cms/installer/xml/GenericArticleHelper.java @@ -20,19 +20,20 @@ package com.arsdigita.cms.installer.xml; import com.arsdigita.cms.ContentSection; import com.arsdigita.cms.TextAsset; -import com.arsdigita.cms.TextPage; +import com.arsdigita.cms.contenttypes.GenericArticle; import org.apache.log4j.Logger; /** - * TextPageHelper + * GenericArticleHelper * * @author Jon Orris * */ -public class TextPageHelper extends ContentPageHelper { +public class GenericArticleHelper extends ContentPageHelper { - private static final Logger s_log = Logger.getLogger(TextPageHelper.class); - public TextPageHelper(ContentSection section) { + private static final Logger s_log = Logger.getLogger(GenericArticleHelper.class); + + public GenericArticleHelper(ContentSection section) { super(section); } @@ -41,7 +42,7 @@ public class TextPageHelper extends ContentPageHelper { TextAsset asset = new TextAsset(); asset.setText(body); - TextPage page = (TextPage) m_item; + GenericArticle page = (GenericArticle) m_item; page.setTextAsset(asset); asset.setParent(page); asset.setName(page.getName() + "_text_" + page.getID()); diff --git a/ccm-cms/src/com/arsdigita/cms/ui/authoring/TextPageBody.java b/ccm-cms/src/com/arsdigita/cms/ui/authoring/GenericArticleBody.java similarity index 87% rename from ccm-cms/src/com/arsdigita/cms/ui/authoring/TextPageBody.java rename to ccm-cms/src/com/arsdigita/cms/ui/authoring/GenericArticleBody.java index ff75d3f8b..8ac5bef9e 100755 --- a/ccm-cms/src/com/arsdigita/cms/ui/authoring/TextPageBody.java +++ b/ccm-cms/src/com/arsdigita/cms/ui/authoring/GenericArticleBody.java @@ -28,7 +28,7 @@ import com.arsdigita.bebop.form.Option; import com.arsdigita.bebop.form.SingleSelect; import com.arsdigita.cms.ItemSelectionModel; import com.arsdigita.cms.TextAsset; -import com.arsdigita.cms.TextPage; +import com.arsdigita.cms.contenttypes.GenericArticle; import com.arsdigita.cms.ui.workflow.WorkflowLockedComponentAccess; import com.arsdigita.cms.util.GlobalizationUtil; import com.arsdigita.domain.DomainObject; @@ -44,15 +44,15 @@ import com.arsdigita.util.Assert; * this class. * * @author Stanislav Freidin (sfreidin@arsdigita.com) - * @version $Id: TextPageBody.java 1949 2009-06-25 08:30:50Z terry $ + * @version $Id: GenericArticleBody.java 1949 2009-06-25 08:30:50Z terry $ */ -public class TextPageBody extends TextAssetBody { +public class GenericArticleBody extends TextAssetBody { private AuthoringKitWizard m_parent; private ItemSelectionModel m_itemModel; /** - * Construct a new TextPageBody component + * Construct a new GenericArticleBody component * * @param itemModel The {@link ItemSelectionModel} which will * be responsible for loading the current item @@ -61,7 +61,7 @@ public class TextPageBody extends TextAssetBody { * may use the wizard's methods, such as stepForward and stepBack, * in its process listener. */ - public TextPageBody(ItemSelectionModel itemModel, AuthoringKitWizard parent) { + public GenericArticleBody(ItemSelectionModel itemModel, AuthoringKitWizard parent) { super(new ItemAssetModel(itemModel)); m_itemModel = itemModel; m_parent = parent; @@ -87,8 +87,9 @@ public class TextPageBody extends TextAssetBody { /** * Adds the options for the mime type select widget of - * TextPageForm and sets the default mime type. + * GenericArticleForm and sets the default mime type. **/ + @Override protected void setMimeTypeOptions(SingleSelect mimeSelect) { mimeSelect.addOption(new Option("text/html", "HTML Text")); mimeSelect.setOptionSelected("text/html"); @@ -101,7 +102,7 @@ public class TextPageBody extends TextAssetBody { * @return a valid TextAsset */ protected TextAsset createTextAsset(PageState s) { - TextPage item = getTextPage(s); + GenericArticle item = getGenericArticle(s); TextAsset t = new TextAsset(); t.setName(item.getName() + "_text_" + item.getID()); // no need - cg. Text doesn't need a security context, @@ -118,7 +119,7 @@ public class TextPageBody extends TextAssetBody { * @param a the new TextAsset */ protected void updateTextAsset(PageState s, TextAsset a) { - TextPage t = getTextPage(s); + GenericArticle t = getGenericArticle(s); Assert.exists(t); // no need - cg. Text doesn't need a security context, // and ownership of text is recorded in text_pages @@ -130,10 +131,10 @@ public class TextPageBody extends TextAssetBody { } /** - * Get the current TextPage + * Get the current GenericArticle */ - protected TextPage getTextPage(PageState s) { - return (TextPage)m_itemModel.getSelectedObject(s); + protected GenericArticle getGenericArticle(PageState s) { + return (GenericArticle)m_itemModel.getSelectedObject(s); } /** @@ -148,8 +149,9 @@ public class TextPageBody extends TextAssetBody { super(m); m_asset = new RequestLocal() { + @Override protected Object initialValue(PageState s) { - TextPage t = (TextPage) + GenericArticle t = (GenericArticle) ((ItemSelectionModel)getSingleSelectionModel()) .getSelectedObject(s); Assert.exists(t); @@ -158,23 +160,28 @@ public class TextPageBody extends TextAssetBody { }; } + @Override public Object getSelectedKey(PageState s) { TextAsset a = (TextAsset)getSelectedObject(s); return (a == null) ? null : a.getID(); } + @Override public DomainObject getSelectedObject(PageState s) { return (DomainObject)m_asset.get(s); } + @Override public void setSelectedObject(PageState s, DomainObject o) { m_asset.set(s, o); } + @Override public void setSelectedKey(PageState s, Object key) { throw new UnsupportedOperationException( (String) GlobalizationUtil.globalize("cms.ui.authoring.not_implemented").localize()); } + @Override public boolean isSelected(PageState s) { return (getSelectedObject(s) != null); } diff --git a/ccm-ldn-terms/src/com/arsdigita/london/terms/indexing/kea/IndexerService.java b/ccm-ldn-terms/src/com/arsdigita/london/terms/indexing/kea/IndexerService.java index 2f2d100d0..4775a7fe9 100644 --- a/ccm-ldn-terms/src/com/arsdigita/london/terms/indexing/kea/IndexerService.java +++ b/ccm-ldn-terms/src/com/arsdigita/london/terms/indexing/kea/IndexerService.java @@ -33,7 +33,7 @@ import weka.core.Instance; import weka.core.Instances; import com.arsdigita.cms.ContentItem; -import com.arsdigita.cms.TextPage; +import com.arsdigita.cms.contenttypes.GenericArticle; import com.arsdigita.london.terms.Domain; import com.arsdigita.london.terms.Term; import com.arsdigita.london.terms.indexing.Indexer; @@ -63,7 +63,7 @@ public class IndexerService { // Extract keyphrases StringBuffer txtStr = new StringBuffer(); - txtStr.append(((TextPage) item).getTextAsset().getText()); + txtStr.append(((GenericArticle) item).getTextAsset().getText()); double[] newInst = new double[2]; newInst[0] = (double) data.attribute(0).addStringValue(txtStr.toString());