From: <fa...@vh...> - 2005-09-12 15:01:48
|
Author: fabrice Date: 2005-09-12 16:52:37 +0200 (Mon, 12 Sep 2005) New Revision: 771 Modified: ccm-cms/trunk/src/com/arsdigita/cms/ContentSectionConfig.java ccm-cms/trunk/src/com/arsdigita/cms/ContentSectionConfig_parameter.properties ccm-cms/trunk/src/com/arsdigita/cms/search/AssetExtractor.java ccm-cms/trunk/src/com/arsdigita/cms/search/TextContentProvider.java Log: Option to disable file asset extraction Modified: ccm-cms/trunk/src/com/arsdigita/cms/ContentSectionConfig.java =================================================================== --- ccm-cms/trunk/src/com/arsdigita/cms/ContentSectionConfig.java 2005-09-12 14:52:01 UTC (rev 770) +++ ccm-cms/trunk/src/com/arsdigita/cms/ContentSectionConfig.java 2005-09-12 14:52:37 UTC (rev 771) @@ -46,6 +46,9 @@ import java.io.IOException; import java.net.MalformedURLException; import java.net.URL; +import java.util.ArrayList; +import java.util.HashMap; +import java.util.List; /** * A record containing server-session scoped configuration properties. @@ -91,6 +94,11 @@ private final Parameter m_publishLifecycleListenerClass; private final Parameter m_notifyAuthorOnLifecycle; private final Parameter m_saveTextCleansWordTags; + private final Parameter m_hideAdditionalResourceFields; + private final Parameter m_disableFileAssetExtraction; + private final Parameter m_deleteWorkflowAfterPublication; + private final Parameter m_soonExpiredTimespanMonths; + private final Parameter m_soonExpiredTimespanDays; private final Parameter m_defaultTaskAlerts; /** @@ -227,6 +235,26 @@ ("com.arsdigita.cms.save_text_cleans_word_tags", Parameter.OPTIONAL, new Boolean(false)); + m_hideAdditionalResourceFields = new BooleanParameter + ("com.arsdigita.cms.contentassets.ui.RelatedLinkPropertyForm.hideAdditionalResourceFields", + Parameter.REQUIRED, new Boolean(false)); + + m_disableFileAssetExtraction = new BooleanParameter + ("com.arsdigita.cms.search.disableFileAssetExtraction", + Parameter.REQUIRED, new Boolean(false)); + + m_deleteWorkflowAfterPublication = new BooleanParameter + ("com.arsdigita.cms.delete_workflow_after_publication", + Parameter.REQUIRED, new Boolean(true)); + + m_soonExpiredTimespanDays = new IntegerParameter + ("com.arsdigita.cms.soon_expired_timespan_days", + Parameter.REQUIRED, new Integer(1)); + + m_soonExpiredTimespanMonths = new IntegerParameter + ("com.arsdigita.cms.soon_expired_timespan_months", + Parameter.REQUIRED, new Integer(0)); + register(m_templateRootPath); register(m_defaultItemTemplatePath); register(m_defaultFolderTemplatePath); @@ -252,6 +280,11 @@ register(m_publishLifecycleListenerClass); register(m_notifyAuthorOnLifecycle); register(m_saveTextCleansWordTags); + register(m_hideAdditionalResourceFields); + register(m_disableFileAssetExtraction); + register(m_deleteWorkflowAfterPublication); + register(m_soonExpiredTimespanMonths); + register(m_soonExpiredTimespanDays); register(m_defaultTaskAlerts); loadInfo(); @@ -361,6 +394,26 @@ return ((Boolean) get(m_saveTextCleansWordTags)).booleanValue(); } + public final boolean isHideAdditionalResourceFields() { + return ((Boolean) get(m_hideAdditionalResourceFields)).booleanValue(); + } + + public final boolean getDisableFileAssetExtraction() { + return ((Boolean) get(m_disableFileAssetExtraction)).booleanValue(); + } + + public final boolean getDeleteWorkflowAfterPublication() { + return ((Boolean) get(m_deleteWorkflowAfterPublication)).booleanValue(); + } + + public final int getSoonExpiredMonths() { + return ((Integer) get(m_soonExpiredTimespanMonths)).intValue(); + } + + public final int getSoonExpiredDays() { + return ((Integer) get(m_soonExpiredTimespanDays)).intValue(); + } + public final String[] getDefaultTaskAlerts() { return (String[]) get(m_defaultTaskAlerts); } Modified: ccm-cms/trunk/src/com/arsdigita/cms/ContentSectionConfig_parameter.properties =================================================================== --- ccm-cms/trunk/src/com/arsdigita/cms/ContentSectionConfig_parameter.properties 2005-09-12 14:52:01 UTC (rev 770) +++ ccm-cms/trunk/src/com/arsdigita/cms/ContentSectionConfig_parameter.properties 2005-09-12 14:52:37 UTC (rev 771) @@ -123,7 +123,31 @@ com.arsdigita.cms.save_text_cleans_word_tags.example=false com.arsdigita.cms.save_text_cleans_word_tags.format=[boolean] +com.arsdigita.cms.contentassets.ui.RelatedLinkPropertyForm.hideAdditionalResourceFields.title=Hide Additional Resource Fields +com.arsdigita.cms.contentassets.ui.RelatedLinkPropertyForm.hideAdditionalResourceFields.purpose=Hide Additional Resource Fields on RelatedLinkPropertyForm +com.arsdigita.cms.contentassets.ui.RelatedLinkPropertyForm.hideAdditionalResourceFields.example=false +com.arsdigita.cms.contentassets.ui.RelatedLinkPropertyForm.hideAdditionalResourceFields.format=[boolean] +com.arsdigita.cms.search.disableFileAssetExtraction.title=Disable FileAsset Extraction +com.arsdigita.cms.search.disableFileAssetExtraction.purpose=Get the search indexing not to process FileAssets, eg to avoid PDF slowdowns +com.arsdigita.cms.search.disableFileAssetExtraction.example=false +com.arsdigita.cms.search.disableFileAssetExtraction.format=[boolean] + +com.arsdigita.cms.delete_workflow_after_publication.title=Delete Workflow After Publication +com.arsdigita.cms.delete_workflow_after_publication.purpose=Whether an item's workflow should be deleted, once the item has been (re)published +com.arsdigita.cms.delete_workflow_after_publication.example=true +com.arsdigita.cms.delete_workflow_after_publication.format=[boolean] + +com.arsdigita.cms.soon_expired_timespan_days.title=Soon Expired Span Days +com.arsdigita.cms.soon_expired_timespan_days.purpose=Defines the number of days ahead that are covered in the 'Soon Expired' tab +com.arsdigita.cms.soon_expired_timespan_days.example=0 +com.arsdigita.cms.soon_expired_timespan_days.format=[integer] + +com.arsdigita.cms.soon_expired_timespan_months.title=Soon Expired Span Months +com.arsdigita.cms.soon_expired_timespan_months.purpose=Defines the number of months ahead that are covered in the 'Soon Expired' tab +com.arsdigita.cms.soon_expired_timespan_months.example=0 +com.arsdigita.cms.soon_expired_timespan_months.format=[integer] + com.arsdigita.cms.default_task_alerts.title=Default task alerts com.arsdigita.cms.default_task_alerts.purpose=Define for each task type on which workflow actions alert notifications are generated com.arsdigita.cms.default_task_alerts.example=Authoring:enable:finish:rollback,Approval:enable:finish:rollback,Deploy:enable:finish:rollback Modified: ccm-cms/trunk/src/com/arsdigita/cms/search/AssetExtractor.java =================================================================== --- ccm-cms/trunk/src/com/arsdigita/cms/search/AssetExtractor.java 2005-09-12 14:52:01 UTC (rev 770) +++ ccm-cms/trunk/src/com/arsdigita/cms/search/AssetExtractor.java 2005-09-12 14:52:37 UTC (rev 771) @@ -18,40 +18,36 @@ */ package com.arsdigita.cms.search; -import com.arsdigita.persistence.metadata.Property; -import com.arsdigita.persistence.DataObject; -import com.arsdigita.persistence.DataAssociation; -import com.arsdigita.persistence.metadata.ObjectType; - +import com.arsdigita.cms.ContentSection; +import com.arsdigita.cms.FileAsset; +import com.arsdigita.cms.TextAsset; import com.arsdigita.domain.DomainObject; import com.arsdigita.domain.DomainObjectTraversal; import com.arsdigita.domain.DomainServiceInterfaceExposer; +import com.arsdigita.persistence.DataAssociation; +import com.arsdigita.persistence.DataObject; +import com.arsdigita.persistence.metadata.ObjectType; +import com.arsdigita.persistence.metadata.Property; -import com.arsdigita.cms.TextAsset; -import com.arsdigita.cms.FileAsset; - import java.util.List; import java.util.ArrayList; import org.apache.log4j.Logger; - /** - * An implementation of DomainObjectTraversal that generates a - * finds all associated binary assets + * An implementation of DomainObjectTraversal that + * finds all associated binary assets. * * @version $Id$ */ public class AssetExtractor extends DomainObjectTraversal { - private static final Logger s_log = - Logger.getLogger( AssetExtractor.class ); + private static final Logger s_log = Logger.getLogger(AssetExtractor.class); + private List m_content; - public static final String TEXT_ASSET_DATA_OBJ = - "com.arsdigita.cms.TextAsset"; - public static final String FILE_ASSET_DATA_OBJ = - "com.arsdigita.cms.FileAsset"; + public static final String TEXT_ASSET_DATA_OBJ = "com.arsdigita.cms.TextAsset"; + public static final String FILE_ASSET_DATA_OBJ = "com.arsdigita.cms.FileAsset"; public AssetExtractor() { m_content = new ArrayList(); @@ -63,13 +59,15 @@ protected void beginObject(DomainObject obj, String path) { - if( obj.getObjectType().isSubtypeOf - ( FileAsset.BASE_DATA_OBJECT_TYPE ) ) { - FileAsset fa = (FileAsset) obj; + + if (!ContentSection.getConfig().getDisableFileAssetExtraction()) { + if (obj.getObjectType().isSubtypeOf(FileAsset.BASE_DATA_OBJECT_TYPE)) { + FileAsset fa = (FileAsset) obj; m_content.add( new RawContentProvider( "file", fa.getContent() ) ); if( s_log.isDebugEnabled() ) { s_log.debug( "Adding file provider for object " + fa.getOID() ); + } } } } @@ -85,44 +83,43 @@ protected void handleAttribute(DomainObject obj, String path, Property property) { + Object value = DomainServiceInterfaceExposer.get(obj, property.getName()); - if (value != null && - property.isRole() && - (value instanceof DataObject)) { + if (value != null && property.isRole() && (value instanceof DataObject)) { ObjectType assetType = ((DataObject)value).getOID().getObjectType(); String assetTypeName = assetType.getQualifiedName(); + if (assetTypeName.equals(TEXT_ASSET_DATA_OBJ)) { // add the value of the text asset to search_content TextAsset ta = new TextAsset((DataObject)value); String text = ta.getText(); if (text != null) { text = com.arsdigita.util.StringUtils.htmlToText( text ); - m_content.add( - new RawContentProvider("text", text.getBytes())); + m_content.add(new RawContentProvider("text", text.getBytes())); } - if( s_log.isDebugEnabled() ) { s_log.debug( "Adding text provider for attribute " + ta.getOID() ); } + } else if (assetTypeName.equals(FILE_ASSET_DATA_OBJ)) { + if (!ContentSection.getConfig().getDisableFileAssetExtraction()) { // add the value of the file asset to search_content FileAsset fa = new FileAsset((DataObject)value); m_content.add(new RawContentProvider("file", fa.getContent())); + if( s_log.isDebugEnabled() ) { + s_log.debug("Adding file provider for attribute "+fa.getOID()); + } + } - if( s_log.isDebugEnabled() ) { - s_log.debug( "Adding file provider for attribute " + - fa.getOID() ); - } } else if( s_log.isDebugEnabled() ) { s_log.debug( "Don't know what to do with property " + property.getName() + " of type " + assetTypeName ); } - } - - else if( s_log.isDebugEnabled() ) { + + } else if( s_log.isDebugEnabled() ) { s_log.debug( "Ignoring property " + property.getName() + " of type " + value.getClass().getName() ); } @@ -142,6 +139,9 @@ protected void beginAssociation(DomainObject obj, String path, Property property) { + + if (!ContentSection.getConfig().getDisableFileAssetExtraction()) { + DataAssociation association = (DataAssociation)DomainServiceInterfaceExposer.get (obj, property.getName()); @@ -161,6 +161,7 @@ } } } + } protected void endAssociation(DomainObject obj, String path, Modified: ccm-cms/trunk/src/com/arsdigita/cms/search/TextContentProvider.java =================================================================== --- ccm-cms/trunk/src/com/arsdigita/cms/search/TextContentProvider.java 2005-09-12 14:52:01 UTC (rev 770) +++ ccm-cms/trunk/src/com/arsdigita/cms/search/TextContentProvider.java 2005-09-12 14:52:37 UTC (rev 771) @@ -18,9 +18,9 @@ */ package com.arsdigita.cms.search; +import com.arsdigita.cms.ContentSection; +import com.arsdigita.cms.FileAsset; import com.arsdigita.cms.TextAsset; -import com.arsdigita.cms.FileAsset; - import com.arsdigita.domain.DomainObject; import com.arsdigita.domain.DomainObjectTraversal; import com.arsdigita.domain.DomainServiceInterfaceExposer; @@ -95,13 +95,15 @@ protected void beginObject(DomainObject obj, String path) { - if( obj.getObjectType().isSubtypeOf - ( FileAsset.BASE_DATA_OBJECT_TYPE ) ) { - FileAsset fa = (FileAsset) obj; + + if (!ContentSection.getConfig().getDisableFileAssetExtraction()) { + if (obj.getObjectType().isSubtypeOf(FileAsset.BASE_DATA_OBJECT_TYPE)) { + FileAsset fa = (FileAsset) obj; appendFileAsset( fa ); if( s_log.isDebugEnabled() ) { s_log.debug( "Adding file asset object " + fa.getOID() ); + } } } } @@ -127,6 +129,7 @@ ObjectType assetType = ((DataObject)value).getOID().getObjectType(); String assetTypeName = assetType.getQualifiedName(); + if (assetTypeName.equals(TextAsset.BASE_DATA_OBJECT_TYPE)) { if( s_log.isDebugEnabled() ) { s_log.debug( "Adding text asset attribute " + @@ -135,7 +138,9 @@ } appendTextAsset(new TextAsset((DataObject)value)); + } else if (assetTypeName.equals(FileAsset.BASE_DATA_OBJECT_TYPE)) { + if (!ContentSection.getConfig().getDisableFileAssetExtraction()) { if( s_log.isDebugEnabled() ) { s_log.debug( "Adding file asset attribute " + property.getName() + " for " + @@ -145,6 +150,8 @@ FileAsset fa = new FileAsset((DataObject)value); appendFileAsset(fa); } + } + } else { if (value != null && !property.isRole()) { m_text.append(" " + value); @@ -173,7 +180,9 @@ if (association != null && association.getObjectType().isSubtypeOf (FileAsset.BASE_DATA_OBJECT_TYPE)) { - while (association.next()) { + + if (!ContentSection.getConfig().getDisableFileAssetExtraction()) { + while (association.next()) { if( s_log.isDebugEnabled() ) { s_log.debug( "Adding file asset association " + property.getName() + " for " + @@ -182,6 +191,8 @@ appendFileAsset(new FileAsset(association.getDataObject())); } + } + } else if (association != null && association.getObjectType().isSubtypeOf (TextAsset.BASE_DATA_OBJECT_TYPE)) { |