Author: mbooth Date: 2005-01-20 10:48:10 +0100 (Thu, 20 Jan 2005) New Revision: 184 Added: ccm-cms/trunk/src/com/arsdigita/cms/search/AssetExtractor.java ccm-cms/trunk/src/com/arsdigita/cms/search/AssetMetadataProvider.java ccm-cms/trunk/src/com/arsdigita/cms/search/ContentItemMetadataProvider.java ccm-cms/trunk/src/com/arsdigita/cms/search/RawContentProvider.java ccm-cms/trunk/src/com/arsdigita/cms/search/TextContentProvider.java ccm-cms/trunk/src/com/arsdigita/cms/search/XMLContentProvider.java Removed: ccm-cms/trunk/src/com/arsdigita/cms/search/ContentPageAssetExtractor.java ccm-cms/trunk/src/com/arsdigita/cms/search/ContentPageRawContentProvider.java ccm-cms/trunk/src/com/arsdigita/cms/search/ContentPageTextContentProvider.java ccm-cms/trunk/src/com/arsdigita/cms/search/ContentPageXMLContentProvider.java Modified: ccm-cms-assets-fileattachment/trunk/src/WEB-INF/traversal-adapters/com/arsdigita/cms/contentassets/FileAttachment.xml ccm-cms-assets-fileattachment/trunk/src/com/arsdigita/cms/contentassets/FileAttachment.java ccm-cms-assets-fileattachment/trunk/src/com/arsdigita/cms/contentassets/FileAttachmentInitializer.java ccm-cms-types-filestorageitem/trunk/src/WEB-INF/traversal-adapters/com/arsdigita/cms/contenttypes/FileStorageItem.xml ccm-cms-types-mparticle/trunk/src/WEB-INF/traversal-adapters/com/arsdigita/cms/contenttypes/MultiPartArticle.xml ccm-cms/trunk/src/WEB-INF/resources/cms-item-adapters.xml ccm-cms/trunk/src/com/arsdigita/cms/FileAsset.java ccm-cms/trunk/src/com/arsdigita/cms/Initializer.java ccm-cms/trunk/src/com/arsdigita/cms/contenttypes/ContentItemTraversalAdapter.java ccm-cms/trunk/src/com/arsdigita/cms/search/ContentPageMetadataProvider.java ccm-cms/trunk/src/com/arsdigita/cms/search/IntermediaQueryEngine.java ccm-ldn-search/trunk/doc/indexing-and-querying.html Log: Initial commit of file searching in both intermedia and lucene. This change indexes FileAttachments with their associated items, and also the files individually. There is an outstanding issue on Lucene where deleted FileAssets are not being removed from the search results. Also there is not yet a URLFinder registered for FileAssets. Applying this change involves reindexing search content. Modified: ccm-cms/trunk/src/WEB-INF/resources/cms-item-adapters.xml =================================================================== --- ccm-cms/trunk/src/WEB-INF/resources/cms-item-adapters.xml 2005-01-18 14:42:28 UTC (rev 183) +++ ccm-cms/trunk/src/WEB-INF/resources/cms-item-adapters.xml 2005-01-20 09:48:10 UTC (rev 184) @@ -112,7 +112,6 @@ <xrd:associations rule="include"> <xrd:property name="/object/locale"/> <xrd:property name="/object/type"/> - <xrd:property name="/object/fileAttachments"/> </xrd:associations> </xrd:adapter> @@ -172,13 +171,26 @@ <!-- Article in several sections --> </xrd:context> + <!-- Search metadata for file assets --> + <xrd:context name="com.arsdigita.cms.search.AssetMetadataProvider"> + <xrd:adapter objectType="com.arsdigita.cms.FileAsset" traversalClass="com.arsdigita.cms.contenttypes.ContentItemTraversalAdapter"> + <xrd:attributes rule="exclude"> + <xrd:property name="/object/id"/> + <xrd:property name="/object/content"/> + <xrd:property name="/object/defaultDomainClass"/> + <xrd:property name="/object/displayName"/> + <xrd:property name="/object/ancestors"/> + <xrd:property name="/object/version"/> + <xrd:property name="/object/isDeleted"/> + </xrd:attributes> + </xrd:adapter> + </xrd:context> <!-- For assets, we want to pull out all HTML, or binary files --> - <xrd:context name="com.arsdigita.cms.search.ContentPageAssetExtractor"> + <xrd:context name="com.arsdigita.cms.search.AssetExtractor"> <!-- Content item is the simplest type --> <xrd:adapter objectType="com.arsdigita.cms.ContentItem" traversalClass="com.arsdigita.cms.contenttypes.ContentItemTraversalAdapter"> - <xrd:associations rule="include"> - </xrd:associations> + <xrd:associations rule="include"/> </xrd:adapter> <!-- Adds a text asset --> Modified: ccm-cms/trunk/src/com/arsdigita/cms/FileAsset.java =================================================================== --- ccm-cms/trunk/src/com/arsdigita/cms/FileAsset.java 2005-01-18 14:42:28 UTC (rev 183) +++ ccm-cms/trunk/src/com/arsdigita/cms/FileAsset.java 2005-01-20 09:48:10 UTC (rev 184) @@ -25,14 +25,15 @@ import com.arsdigita.persistence.Filter; import com.arsdigita.persistence.OID; import com.arsdigita.persistence.SessionManager; + import java.io.File; import java.io.FileInputStream; import java.io.FileOutputStream; import java.io.IOException; import java.math.BigDecimal; +import java.util.Locale; - /** * An {@link com.arsdigita.cms.Asset asset} describing a concrete * file, such as an image. @@ -233,4 +234,12 @@ return getFilesByKeyword(keyword, ContentItem.DRAFT); } + + protected void beforeSave() { + if( null == getLanguage() ) { + setLanguage( Locale.getDefault().getLanguage() ); + } + + super.beforeSave(); + } } Modified: ccm-cms/trunk/src/com/arsdigita/cms/Initializer.java =================================================================== --- ccm-cms/trunk/src/com/arsdigita/cms/Initializer.java 2005-01-18 14:42:28 UTC (rev 183) +++ ccm-cms/trunk/src/com/arsdigita/cms/Initializer.java 2005-01-20 09:48:10 UTC (rev 184) @@ -24,15 +24,16 @@ import com.arsdigita.cms.dispatcher.ItemDelegatedURLPatternGenerator; import com.arsdigita.cms.publishToFile.PublishToFileListener; import com.arsdigita.cms.publishToFile.QueueManager; +import com.arsdigita.cms.search.AssetMetadataProvider; import com.arsdigita.cms.search.ContentTypeFilterType; -import com.arsdigita.cms.search.VersionFilterType; -import com.arsdigita.cms.search.LaunchDateFilterType; -import com.arsdigita.cms.search.LastModifiedUserFilterType; -import com.arsdigita.cms.search.LastModifiedDateFilterType; import com.arsdigita.cms.search.CreationDateFilterType; import com.arsdigita.cms.search.CreationUserFilterType; import com.arsdigita.cms.search.IntermediaQueryEngine; +import com.arsdigita.cms.search.LastModifiedDateFilterType; +import com.arsdigita.cms.search.LastModifiedUserFilterType; +import com.arsdigita.cms.search.LaunchDateFilterType; import com.arsdigita.cms.search.LuceneQueryEngine; +import com.arsdigita.cms.search.VersionFilterType; import com.arsdigita.cms.workflow.CMSTask; import com.arsdigita.domain.xml.TraversalHandler; import com.arsdigita.db.DbHelper; @@ -55,10 +56,11 @@ import com.arsdigita.runtime.LegacyInitializer; import com.arsdigita.runtime.PDLInitializer; import com.arsdigita.runtime.RuntimeConfig; -import com.arsdigita.search.Search; +import com.arsdigita.search.FilterType; import com.arsdigita.search.IndexerType; -import com.arsdigita.search.FilterType; +import com.arsdigita.search.MetadataProviderRegistry; import com.arsdigita.search.QueryEngineRegistry; +import com.arsdigita.search.Search; import com.arsdigita.search.filters.PermissionFilterType; import com.arsdigita.search.filters.CategoryFilterType; import com.arsdigita.util.UncheckedWrapperException; @@ -169,6 +171,9 @@ ("Couldn't access the listener class", ex); } + MetadataProviderRegistry.registerAdapter( + FileAsset.BASE_DATA_OBJECT_TYPE, + new AssetMetadataProvider()); } /** Modified: ccm-cms/trunk/src/com/arsdigita/cms/contenttypes/ContentItemTraversalAdapter.java =================================================================== --- ccm-cms/trunk/src/com/arsdigita/cms/contenttypes/ContentItemTraversalAdapter.java 2005-01-18 14:42:28 UTC (rev 183) +++ ccm-cms/trunk/src/com/arsdigita/cms/contenttypes/ContentItemTraversalAdapter.java 2005-01-20 09:48:10 UTC (rev 184) @@ -74,7 +74,7 @@ Property prop, String context) { if (s_log.isDebugEnabled()) { - s_log.debug("Process property " + path); + s_log.debug("Process property " + path + " in context " + context ); } String prefix = "/object/"; int offset = path.indexOf("/", prefix.length()); Copied: ccm-cms/trunk/src/com/arsdigita/cms/search/AssetExtractor.java (from rev 170, ccm-cms/trunk/src/com/arsdigita/cms/search/ContentPageAssetExtractor.java) =================================================================== --- ccm-cms/trunk/src/com/arsdigita/cms/search/ContentPageAssetExtractor.java 2005-01-05 16:32:08 UTC (rev 170) +++ ccm-cms/trunk/src/com/arsdigita/cms/search/AssetExtractor.java 2005-01-20 09:48:10 UTC (rev 184) @@ -0,0 +1,170 @@ +/* + * Copyright (C) 2003-2004 Red Hat Inc. All Rights Reserved. + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public License + * as published by the Free Software Foundation; either version 2.1 of + * the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + * + */ +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.domain.DomainObject; +import com.arsdigita.domain.DomainObjectTraversal; +import com.arsdigita.domain.DomainServiceInterfaceExposer; + +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 + * + * @version $Id: //cms/dev/src/com/arsdigita/cms/search/AssetExtractor.java#6 $ + */ +public class AssetExtractor extends DomainObjectTraversal { + 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 AssetExtractor() { + m_content = new ArrayList(); + } + + public List getContent() { + return m_content; + } + + protected void beginObject(DomainObject obj, + String path) { + 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() ); + } + } + } + + protected void endObject(DomainObject obj, + String path) { + } + + protected void revisitObject(DomainObject obj, + String path) { + } + + protected void handleAttribute(DomainObject obj, + String path, + Property property) { + Object value = DomainServiceInterfaceExposer.get(obj, property.getName()); + + 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())); + } + + if( s_log.isDebugEnabled() ) { + s_log.debug( "Adding text provider for attribute " + + ta.getOID() ); + } + } else if (assetTypeName.equals(FILE_ASSET_DATA_OBJ)) { + // 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() ); + } + } 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() ) { + s_log.debug( "Ignoring property " + property.getName() + + " of type " + value.getClass().getName() ); + } + } + + protected void beginRole(DomainObject obj, + String path, + Property property) { + } + + protected void endRole(DomainObject obj, + String path, + Property property) { + } + + + protected void beginAssociation(DomainObject obj, + String path, + Property property) { + DataAssociation association = + (DataAssociation)DomainServiceInterfaceExposer.get + (obj, property.getName()); + + if (association != null && + association.getObjectType().isSubtypeOf + (FileAsset.BASE_DATA_OBJECT_TYPE)) { + while (association.next()) { + // add the value of the file asset to search_content + FileAsset fa = new FileAsset(association.getDataObject()); + m_content.add(new RawContentProvider("file", fa.getContent())); + + if( s_log.isDebugEnabled() ) { + s_log.debug( "Adding file provider for association " + + fa.getOID() ); + } + } + } + } + + protected void endAssociation(DomainObject obj, + String path, + Property property) { + } + +} Added: ccm-cms/trunk/src/com/arsdigita/cms/search/AssetMetadataProvider.java =================================================================== --- ccm-cms/trunk/src/com/arsdigita/cms/search/AssetMetadataProvider.java 2005-01-18 14:42:28 UTC (rev 183) +++ ccm-cms/trunk/src/com/arsdigita/cms/search/AssetMetadataProvider.java 2005-01-20 09:48:10 UTC (rev 184) @@ -0,0 +1,61 @@ +/* + * Copyright (C) 2003-2004 Red Hat Inc. All Rights Reserved. + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public License + * as published by the Free Software Foundation; either version 2.1 of + * the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + * + */ +package com.arsdigita.cms.search; + +import com.arsdigita.cms.Asset; +import com.arsdigita.domain.DomainObject; +import com.arsdigita.util.StringUtils; + +import org.apache.log4j.Logger; + +/** + * This class is an implementation of the Search metadata provider for any + * subclass of {@link com.arsdigita.cms.Asset}. + * + * @author <a href="mailto:ber...@re...">Daniel Berrange</a> + * @version $Revision: #5 $ $Date: 2004/08/17 $ + */ +public class AssetMetadataProvider extends ContentItemMetadataProvider { + + public static final String ADAPTER_CONTEXT = + AssetMetadataProvider.class.getName(); + + private static final Logger s_log = + Logger.getLogger(AssetMetadataProvider.class); + + public final static String versionId = + "$Id: //cms/dev/src/com/arsdigita/cms/search/AssetMetadataProvider.java#5 $" + + " by $Author: dennis $, $DateTime: 2004/08/17 23:15:09 $"; + + public String getTitle(DomainObject dobj) { + Asset item = (Asset)dobj; + String title = item.getName(); + if (StringUtils.emptyString(title)) { + throw new IllegalArgumentException( + "Asset must have non-blank name!" + ); + } + return title; + } + + public String getSummary(DomainObject dobj) { + Asset item = (Asset)dobj; + return item.getDescription(); + } +} Added: ccm-cms/trunk/src/com/arsdigita/cms/search/ContentItemMetadataProvider.java =================================================================== --- ccm-cms/trunk/src/com/arsdigita/cms/search/ContentItemMetadataProvider.java 2005-01-18 14:42:28 UTC (rev 183) +++ ccm-cms/trunk/src/com/arsdigita/cms/search/ContentItemMetadataProvider.java 2005-01-20 09:48:10 UTC (rev 184) @@ -0,0 +1,113 @@ +/* + * Copyright (C) 2003-2004 Red Hat Inc. All Rights Reserved. + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public License + * as published by the Free Software Foundation; either version 2.1 of + * the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + * + */ +package com.arsdigita.cms.search; + +import com.arsdigita.cms.ContentItem; +import com.arsdigita.domain.DomainObject; +import com.arsdigita.kernel.Party; +import com.arsdigita.search.ContentType; +import com.arsdigita.search.ContentProvider; +import com.arsdigita.search.MetadataProvider; + +import java.util.List; +import java.util.ArrayList; + +import java.util.Date; + +import org.apache.log4j.Logger; + +/** + * This class is an implementation of the Search metadata provider that uses the + * <code>DomainObjectTextRenderer</code> to extract search content for any + * subclass of {@link com.arsdigita.cms.ContentItem}. + * + * @author <a href="mailto:ber...@re...">Daniel Berrange</a> + * @version $Revision: #5 $ $Date: 2004/08/17 $ + */ +public abstract class ContentItemMetadataProvider implements MetadataProvider { + private static final Logger s_log = + Logger.getLogger(ContentItemMetadataProvider.class); + + public final static String versionId = + "$Id: //cms/dev/src/com/arsdigita/cms/search/ContentItemMetadataProvider.java#5 $" + + " by $Author: dennis $, $DateTime: 2004/08/17 23:15:09 $"; + + public String getTypeSpecificInfo(DomainObject dobj) { + ContentItem item = (ContentItem) dobj; + return ContentItem.LIVE.equals(item.getVersion()) ? + ContentItem.LIVE : ContentItem.DRAFT; + } + + public java.util.Locale getLocale(DomainObject dobj) { + ContentItem item = (ContentItem)dobj; + String lang = item.getLanguage(); + return lang == null ? null : new java.util.Locale(lang,""); + } + + public Date getCreationDate(DomainObject dobj) { + ContentItem item = (ContentItem)dobj; + return item.getCreationDate(); + } + + public Party getCreationParty(DomainObject dobj) { + ContentItem item = (ContentItem)dobj; + return item.getCreationUser(); + } + + public Date getLastModifiedDate(DomainObject dobj) { + ContentItem item = (ContentItem)dobj; + return item.getLastModifiedDate(); + } + + public Party getLastModifiedParty(DomainObject dobj) { + ContentItem item = (ContentItem)dobj; + return item.getLastModifiedUser(); + } + + public ContentProvider[] getContent(DomainObject dobj, + ContentType type) { + List content = new ArrayList(); + + if (type == ContentType.XML) { + if (s_log.isDebugEnabled()) { + s_log.debug("Adding XML Content for " + dobj.getOID()); + } + content.add(new XMLContentProvider("xml", dobj, + getClass().getName())); + } else if (type == ContentType.TEXT) { + if (s_log.isDebugEnabled()) { + s_log.debug("Adding Text Content for " + dobj.getOID()); + } + content.add(new TextContentProvider("text", dobj, + getClass().getName())); + content.add(new TextContentProvider("text", dobj, + AssetExtractor.class.getName())); + } else if (type == ContentType.RAW) { + if (s_log.isDebugEnabled()) { + s_log.debug("Adding Raw Content for " + dobj.getOID()); + } + AssetExtractor ex = new AssetExtractor(); + ex.walk(dobj, AssetExtractor.class.getName()); + content.addAll(ex.getContent()); + } + + return (ContentProvider[])content.toArray( + new ContentProvider[content.size()]); + } +} Deleted: ccm-cms/trunk/src/com/arsdigita/cms/search/ContentPageAssetExtractor.java =================================================================== --- ccm-cms/trunk/src/com/arsdigita/cms/search/ContentPageAssetExtractor.java 2005-01-18 14:42:28 UTC (rev 183) +++ ccm-cms/trunk/src/com/arsdigita/cms/search/ContentPageAssetExtractor.java 2005-01-20 09:48:10 UTC (rev 184) @@ -1,138 +0,0 @@ -/* - * Copyright (C) 2003-2004 Red Hat Inc. All Rights Reserved. - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public License - * as published by the Free Software Foundation; either version 2.1 of - * the License, or (at your option) any later version. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with this library; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - * - */ -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.domain.DomainObject; -import com.arsdigita.domain.DomainObjectTraversal; -import com.arsdigita.domain.DomainServiceInterfaceExposer; - -import com.arsdigita.cms.TextAsset; -import com.arsdigita.cms.FileAsset; -import com.arsdigita.cms.ContentPage; - -import java.util.List; -import java.util.ArrayList; - - -/** - * An implementation of DomainObjectTraversal that generates a - * finds all associated binary assets - * - * @version $Id: //cms/dev/src/com/arsdigita/cms/search/ContentPageAssetExtractor.java#6 $ - */ -public class ContentPageAssetExtractor extends DomainObjectTraversal { - - 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 ContentPageAssetExtractor() { - m_content = new ArrayList(); - } - - public List getContent() { - return m_content; - } - - protected void beginObject(DomainObject obj, - String path) { - } - - protected void endObject(DomainObject obj, - String path) { - } - - protected void revisitObject(DomainObject obj, - String path) { - } - - protected void handleAttribute(DomainObject obj, - String path, - Property property) { - Object value = DomainServiceInterfaceExposer.get(obj, property.getName()); - - 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 ContentPageRawContentProvider("text", - text.getBytes())); - } - } else if (assetTypeName.equals(FILE_ASSET_DATA_OBJ)) { - // add the value of the file asset to search_content - FileAsset fa = new FileAsset((DataObject)value); - m_content.add(new ContentPageRawContentProvider("file", - fa.getContent())); - } - } - } - - protected void beginRole(DomainObject obj, - String path, - Property property) { - } - - protected void endRole(DomainObject obj, - String path, - Property property) { - } - - - protected void beginAssociation(DomainObject obj, - String path, - Property property) { - DataAssociation association = - (DataAssociation)DomainServiceInterfaceExposer.get - (obj, property.getName()); - - if (association != null && - association.getObjectType().isSubtypeOf - (FileAsset.BASE_DATA_OBJECT_TYPE)) { - while (association.next()) { - // add the value of the file asset to search_content - FileAsset fa = new FileAsset(association.getDataObject()); - m_content.add(new ContentPageRawContentProvider("file", - fa.getContent())); - } - } - } - - protected void endAssociation(DomainObject obj, - String path, - Property property) { - } - -} Modified: ccm-cms/trunk/src/com/arsdigita/cms/search/ContentPageMetadataProvider.java =================================================================== --- ccm-cms/trunk/src/com/arsdigita/cms/search/ContentPageMetadataProvider.java 2005-01-18 14:42:28 UTC (rev 183) +++ ccm-cms/trunk/src/com/arsdigita/cms/search/ContentPageMetadataProvider.java 2005-01-20 09:48:10 UTC (rev 184) @@ -18,27 +18,12 @@ */ package com.arsdigita.cms.search; -import com.arsdigita.cms.ContentItem; import com.arsdigita.cms.ContentPage; - import com.arsdigita.domain.DomainObject; -import com.arsdigita.domain.DomainObjectTextRenderer; -import com.arsdigita.domain.DomainObjectXMLRenderer; - -import com.arsdigita.kernel.Party; - -import com.arsdigita.search.MetadataProvider; import com.arsdigita.search.ContentProvider; import com.arsdigita.search.ContentType; - -import com.arsdigita.persistence.metadata.ObjectType; import com.arsdigita.util.StringUtils; -import java.math.BigDecimal; -import java.util.Date; -import java.util.List; -import java.util.ArrayList; - import org.apache.log4j.Logger; /** @@ -49,7 +34,7 @@ * @author <a href="mailto:ber...@re...">Daniel Berrange</a> * @version $Revision: #5 $ $Date: 2004/08/17 $ */ -public class ContentPageMetadataProvider implements MetadataProvider { +public class ContentPageMetadataProvider extends ContentItemMetadataProvider { public static final String ADAPTER_CONTEXT = ContentPageMetadataProvider.class.getName(); @@ -61,18 +46,6 @@ "$Id: //cms/dev/src/com/arsdigita/cms/search/ContentPageMetadataProvider.java#5 $" + " by $Author: dennis $, $DateTime: 2004/08/17 23:15:09 $"; - public String getTypeSpecificInfo(DomainObject dobj) { - ContentPage item = (ContentPage) dobj; - return ContentItem.LIVE.equals(item.getVersion()) ? - ContentItem.LIVE : ContentItem.DRAFT; - } - - public java.util.Locale getLocale(DomainObject dobj) { - ContentPage item = (ContentPage)dobj; - String lang = item.getLanguage(); - return lang == null ? null : new java.util.Locale(lang,""); - } - public String getTitle(DomainObject dobj) { ContentPage item = (ContentPage)dobj; String title = item.getTitle(); @@ -88,53 +61,4 @@ ContentPage item = (ContentPage)dobj; return item.getSearchSummary(); } - - public ContentProvider[] getContent(DomainObject dobj, - ContentType type) { - List content = new ArrayList(); - - if (type == ContentType.XML) { - if (s_log.isDebugEnabled()) { - s_log.debug("Adding XML Content"); - } - content.add(new ContentPageXMLContentProvider("xml", - (ContentPage)dobj)); - } else if (type == ContentType.TEXT) { - if (s_log.isDebugEnabled()) { - s_log.debug("Adding Text Content"); - } - content.add(new ContentPageTextContentProvider("text", - (ContentPage)dobj)); - } else if (type == ContentType.RAW) { - if (s_log.isDebugEnabled()) { - s_log.debug("Adding Raw Content"); - } - ContentPageAssetExtractor ex = new ContentPageAssetExtractor(); - ex.walk(dobj, ContentPageAssetExtractor.class.getName()); - content.addAll(ex.getContent()); - } - - return (ContentProvider[])content.toArray( - new ContentProvider[content.size()]); - } - - public Date getCreationDate(DomainObject dobj) { - ContentPage item = (ContentPage)dobj; - return item.getCreationDate(); - } - - public Party getCreationParty(DomainObject dobj) { - ContentPage item = (ContentPage)dobj; - return item.getCreationUser(); - } - - public Date getLastModifiedDate(DomainObject dobj) { - ContentPage item = (ContentPage)dobj; - return item.getLastModifiedDate(); - } - - public Party getLastModifiedParty(DomainObject dobj) { - ContentPage item = (ContentPage)dobj; - return item.getLastModifiedUser(); - } } Deleted: ccm-cms/trunk/src/com/arsdigita/cms/search/ContentPageRawContentProvider.java =================================================================== --- ccm-cms/trunk/src/com/arsdigita/cms/search/ContentPageRawContentProvider.java 2005-01-18 14:42:28 UTC (rev 183) +++ ccm-cms/trunk/src/com/arsdigita/cms/search/ContentPageRawContentProvider.java 2005-01-20 09:48:10 UTC (rev 184) @@ -1,49 +0,0 @@ -/* - * Copyright (C) 2003-2004 Red Hat Inc. All Rights Reserved. - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public License - * as published by the Free Software Foundation; either version 2.1 of - * the License, or (at your option) any later version. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with this library; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - * - */ -package com.arsdigita.cms.search; - - -import com.arsdigita.search.ContentType; -import com.arsdigita.search.ContentProvider; - - -public class ContentPageRawContentProvider implements ContentProvider { - - private byte[] m_content; - private String m_context; - - public ContentPageRawContentProvider(String context, - byte[] content) { - m_context = context; - m_content = content; - } - - public String getContext() { - return m_context; - } - - public ContentType getType() { - return ContentType.RAW; - } - - public byte[] getBytes() { - return m_content; - } - -} Deleted: ccm-cms/trunk/src/com/arsdigita/cms/search/ContentPageTextContentProvider.java =================================================================== --- ccm-cms/trunk/src/com/arsdigita/cms/search/ContentPageTextContentProvider.java 2005-01-18 14:42:28 UTC (rev 183) +++ ccm-cms/trunk/src/com/arsdigita/cms/search/ContentPageTextContentProvider.java 2005-01-20 09:48:10 UTC (rev 184) @@ -1,202 +0,0 @@ -/* - * Copyright (C) 2003-2004 Red Hat Inc. All Rights Reserved. - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public License - * as published by the Free Software Foundation; either version 2.1 of - * the License, or (at your option) any later version. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with this library; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - * - */ -package com.arsdigita.cms.search; - - -import com.arsdigita.cms.CMS; -import com.arsdigita.cms.ContentPage; -import com.arsdigita.search.ContentType; -import com.arsdigita.search.ContentProvider; - -import com.arsdigita.domain.DomainObjectTextRenderer; -import com.arsdigita.domain.DomainObjectTraversal; -import com.arsdigita.domain.DomainObject; -import com.arsdigita.persistence.DataObject; -import com.arsdigita.persistence.DataAssociation; -import com.arsdigita.cms.TextAsset; -import com.arsdigita.persistence.metadata.ObjectType; -import com.arsdigita.persistence.metadata.Property; -import com.arsdigita.domain.DomainServiceInterfaceExposer; -import com.arsdigita.cms.FileAsset; -import com.arsdigita.util.StringUtils; -import com.arsdigita.search.converter.ConverterRegistry; -import com.arsdigita.search.converter.ConversionException; -import com.arsdigita.search.converter.Converter; -import org.apache.log4j.Logger; - -public class ContentPageTextContentProvider implements ContentProvider { - - private ContentPage m_page; - private String m_context; - - public ContentPageTextContentProvider(String context, - ContentPage page) { - m_context = context; - m_page = page; - } - - public String getContext() { - return m_context; - } - - public ContentType getType() { - return ContentType.TEXT; - } - - public byte[] getBytes() { - - // Long term, this should be uncommented and the conversion - // should be moved in to the com.arsdigita.search package. - // But, for now, this is faster/easier - //DomainObjectTextRenderer renderer = - // new DomainObjectTextRenderer(); - TextRenderer renderer = new TextRenderer(); - - renderer.walk(m_page, ContentPageMetadataProvider.class.getName()); - - String text = renderer.getText(); - return text.getBytes(); - } - - /** - * An implementation of the traversal code that converts FileAssets in - * to the appropriate text - */ - public class TextRenderer extends DomainObjectTraversal { - - private Logger s_log = Logger.getLogger(TextRenderer.class); - private StringBuffer m_text; - - /** - */ - public TextRenderer() { - m_text = new StringBuffer(""); - } - - public String getText() { - return m_text.toString(); - } - - protected void beginObject(DomainObject obj, - String path) { - } - - protected void endObject(DomainObject obj, - String path) { - } - - protected void revisitObject(DomainObject obj, - String path) { - } - - protected void handleAttribute(DomainObject obj, - String path, - Property property) { - - Object value = - DomainServiceInterfaceExposer.get(obj, property.getName()); - - if (value != null && - property.isRole() && - (value instanceof DataObject)) { - - ObjectType assetType = ((DataObject)value).getOID().getObjectType(); - String assetTypeName = assetType.getQualifiedName(); - if (assetTypeName.equals(TextAsset.BASE_DATA_OBJECT_TYPE)) { - // add the value of the text asset to search_content - appendTextAsset(new TextAsset((DataObject)value)); - - } else if (assetTypeName.equals(FileAsset.BASE_DATA_OBJECT_TYPE)) { - // add the value of the file asset to search_content - FileAsset fa = new FileAsset((DataObject)value); - appendFileAsset(fa); - } - } else { - if (value != null && !property.isRole()) { - m_text.append(" " + value); - } - } - } - - protected void beginRole(DomainObject obj, - String path, - Property property) { - } - - protected void endRole(DomainObject obj, - String path, - Property property) { - } - - - protected void beginAssociation(DomainObject obj, - String path, - Property property) { - DataAssociation association = - (DataAssociation)DomainServiceInterfaceExposer.get - (obj, property.getName()); - - if (association != null && - association.getObjectType().isSubtypeOf - (FileAsset.BASE_DATA_OBJECT_TYPE)) { - while (association.next()) { - // add the value of the file asset to search_content - appendFileAsset(new FileAsset(association.getDataObject())); - } - } else if (association != null && - association.getObjectType().isSubtypeOf - (TextAsset.BASE_DATA_OBJECT_TYPE)) { - while (association.next()) { - // add the value of the file asset to search_content - appendTextAsset(new TextAsset(association.getDataObject())); - } - } - } - - protected void endAssociation(DomainObject obj, - String path, - Property property) { - } - - private void appendTextAsset(TextAsset asset) { - String content = asset.getText(); - if (content != null) { - m_text.append(" " + StringUtils.htmlToText(content)); - } - } - - private void appendFileAsset(FileAsset asset) { - Converter converter = - ConverterRegistry.getConverter(asset.getMimeType()); - if (converter != null) { - try { - m_text.append - (" " + - converter.convertDocument(asset.getContent())); - } catch (ConversionException e) { - s_log.error("Error converting FileAsset " + asset.getOID()+ - " with MimeType " + asset.getMimeType(), e); - } - } else { - s_log.debug("Skipping FileAsset " + asset.getOID() + - " with MimeType " + asset.getMimeType()); - } - } - } -} Deleted: ccm-cms/trunk/src/com/arsdigita/cms/search/ContentPageXMLContentProvider.java =================================================================== --- ccm-cms/trunk/src/com/arsdigita/cms/search/ContentPageXMLContentProvider.java 2005-01-18 14:42:28 UTC (rev 183) +++ ccm-cms/trunk/src/com/arsdigita/cms/search/ContentPageXMLContentProvider.java 2005-01-20 09:48:10 UTC (rev 184) @@ -1,85 +0,0 @@ -/* - * Copyright (C) 2003-2004 Red Hat Inc. All Rights Reserved. - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public License - * as published by the Free Software Foundation; either version 2.1 of - * the License, or (at your option) any later version. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with this library; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - * - */ -package com.arsdigita.cms.search; - - -import com.arsdigita.cms.CMS; -import com.arsdigita.cms.ContentPage; -import com.arsdigita.cms.util.GlobalizationUtil; -import com.arsdigita.search.ContentType; -import com.arsdigita.search.ContentProvider; - -import com.arsdigita.domain.DomainObjectXMLRenderer; -import com.arsdigita.xml.Document; -import com.arsdigita.xml.Element; -import com.arsdigita.util.UncheckedWrapperException; - -import org.apache.log4j.Logger; - -public class ContentPageXMLContentProvider implements ContentProvider { - - private static final Logger s_log = Logger - .getLogger(ContentPageXMLContentProvider.class); - - private ContentPage m_page; - private String m_context; - - public ContentPageXMLContentProvider(String context, - ContentPage page) { - m_context = context; - m_page = page; - } - - public String getContext() { - return m_context; - } - - public ContentType getType() { - return ContentType.XML; - } - - public byte[] getBytes() { - - Element root = new Element("cms:item", CMS.CMS_XML_NS); - DomainObjectXMLRenderer renderer = - new DomainObjectXMLRenderer(root); - - renderer.setWrapAttributes(true); - renderer.walk(m_page, ContentPageMetadataProvider.class.getName()); - - Document doc = null; - try { - doc = new Document(root); - } catch (javax.xml.parsers.ParserConfigurationException ex) { - final String message = - (String) GlobalizationUtil.globalize - ("cms.cannot_create_xml_document").localize(); - throw new UncheckedWrapperException(message, ex); - } - if (s_log.isDebugEnabled()) { - s_log.debug("XML is " + doc.toString(true)); - } - - // Hmm, why on earth doesn't this method return - // Element directly ?!?! - String xml = doc.toString(true); - return xml.getBytes(); - } - -} Modified: ccm-cms/trunk/src/com/arsdigita/cms/search/IntermediaQueryEngine.java =================================================================== --- ccm-cms/trunk/src/com/arsdigita/cms/search/IntermediaQueryEngine.java 2005-01-18 14:42:28 UTC (rev 183) +++ ccm-cms/trunk/src/com/arsdigita/cms/search/IntermediaQueryEngine.java 2005-01-20 09:48:10 UTC (rev 184) @@ -47,16 +47,16 @@ public IntermediaQueryEngine() { addColumn("i.version", "version"); - addColumn("p.launch_date", "launch_date"); + //addColumn("p.launch_date", "launch_date"); addColumn("audited.last_modified", "last_modified"); addColumn("audited.modifying_user", "modifying_user"); addColumn("audited.creation_date", "creation_date"); addColumn("audited.creation_user", "creation_user"); addTable("cms_items", "i"); - addTable("cms_pages", "p"); + //addTable("cms_pages", "p"); addTable("acs_auditing", "audited"); addCondition("c.object_id = i.item_id"); - addCondition("c.object_id = p.item_id"); + //addCondition("c.object_id = p.item_id"); addCondition("c.object_id = audited.object_id"); } @@ -71,6 +71,9 @@ } else if (VersionFilterType.KEY.equals(type.getKey())) { addVersionFilter(query, (VersionFilterSpecification)filter); } else if (LaunchDateFilterType.KEY.equals(type.getKey())) { + addColumn("p.launch_date", "launch_date"); + addTable("cms_pages", "p"); + addCondition("c.object_id = p.item_id"); addLaunchDateFilter(query, (DateRangeFilterSpecification)filter); } else if (LastModifiedDateFilterType.KEY.equals(type.getKey())) { addLastModifiedDateFilter(query, (DateRangeFilterSpecification)filter); @@ -96,7 +99,6 @@ addDateRangeFilter(query, filter, "launch_date"); } - protected void addLastModifiedDateFilter(DataQuery query, DateRangeFilterSpecification filter) { // TODO: https://bugzilla.redhat.com/bugzilla/show_bug.cgi?id=113394 Copied: ccm-cms/trunk/src/com/arsdigita/cms/search/RawContentProvider.java (from rev 170, ccm-cms/trunk/src/com/arsdigita/cms/search/ContentPageRawContentProvider.java) =================================================================== --- ccm-cms/trunk/src/com/arsdigita/cms/search/ContentPageRawContentProvider.java 2005-01-05 16:32:08 UTC (rev 170) +++ ccm-cms/trunk/src/com/arsdigita/cms/search/RawContentProvider.java 2005-01-20 09:48:10 UTC (rev 184) @@ -0,0 +1,59 @@ +/* + * Copyright (C) 2003-2004 Red Hat Inc. All Rights Reserved. + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public License + * as published by the Free Software Foundation; either version 2.1 of + * the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + * + */ +package com.arsdigita.cms.search; + + +import com.arsdigita.search.ContentType; +import com.arsdigita.search.ContentProvider; + +import org.apache.log4j.Logger; + +public class RawContentProvider implements ContentProvider { + private static final Logger s_log = + Logger.getLogger( RawContentProvider.class ); + + private byte[] m_content; + private String m_context; + + public RawContentProvider(String context, + byte[] content) { + m_context = context; + m_content = content; + } + + public String getContext() { + return m_context; + } + + public ContentType getType() { + return ContentType.RAW; + } + + public byte[] getBytes() { + if( s_log.isDebugEnabled() ) { + int length = m_content.length > 512 ? 512 : m_content.length; + + s_log.debug( "RAW Content is: " + + new String( m_content, 0, length ) ); + } + + return m_content; + } + +} Copied: ccm-cms/trunk/src/com/arsdigita/cms/search/TextContentProvider.java (from rev 170, ccm-cms/trunk/src/com/arsdigita/cms/search/ContentPageTextContentProvider.java) =================================================================== --- ccm-cms/trunk/src/com/arsdigita/cms/search/ContentPageTextContentProvider.java 2005-01-05 16:32:08 UTC (rev 170) +++ ccm-cms/trunk/src/com/arsdigita/cms/search/TextContentProvider.java 2005-01-20 09:48:10 UTC (rev 184) @@ -0,0 +1,240 @@ +/* + * Copyright (C) 2003-2004 Red Hat Inc. All Rights Reserved. + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public License + * as published by the Free Software Foundation; either version 2.1 of + * the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + * + */ +package com.arsdigita.cms.search; + +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; +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.search.ContentProvider; +import com.arsdigita.search.ContentType; +import com.arsdigita.search.converter.ConversionException; +import com.arsdigita.search.converter.Converter; +import com.arsdigita.search.converter.ConverterRegistry; +import com.arsdigita.util.StringUtils; + +import org.apache.log4j.Logger; + +public class TextContentProvider implements ContentProvider { + + private DomainObject m_obj; + private String m_context; + private String m_adapterContext; + + public TextContentProvider(String context, + DomainObject obj, + String adapterContext) { + m_context = context; + m_obj = obj; + m_adapterContext = adapterContext; + } + + public String getContext() { + return m_context; + } + + public ContentType getType() { + return ContentType.TEXT; + } + + public byte[] getBytes() { + + // Long term, this should be uncommented and the conversion + // should be moved in to the com.arsdigita.search package. + // But, for now, this is faster/easier + //DomainObjectTextRenderer renderer = + // new DomainObjectTextRenderer(); + TextRenderer renderer = new TextRenderer(); + + renderer.walk(m_obj, m_adapterContext); + + String text = renderer.getText(); + return text.getBytes(); + } + + /** + * An implementation of the traversal code that converts FileAssets in + * to the appropriate text + */ + public class TextRenderer extends DomainObjectTraversal { + + private Logger s_log = Logger.getLogger(TextRenderer.class); + private StringBuffer m_text; + + /** + */ + public TextRenderer() { + m_text = new StringBuffer(""); + } + + public String getText() { + return m_text.toString(); + } + + protected void beginObject(DomainObject obj, + String path) { + 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() ); + } + } + } + + protected void endObject(DomainObject obj, + String path) { + } + + protected void revisitObject(DomainObject obj, + String path) { + } + + protected void handleAttribute(DomainObject obj, + String path, + Property property) { + + Object value = + DomainServiceInterfaceExposer.get(obj, property.getName()); + + if (value != null && + property.isRole() && + (value instanceof DataObject)) { + + 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 " + + property.getName() + " for " + + obj.getOID() ); + } + + appendTextAsset(new TextAsset((DataObject)value)); + } else if (assetTypeName.equals(FileAsset.BASE_DATA_OBJECT_TYPE)) { + if( s_log.isDebugEnabled() ) { + s_log.debug( "Adding file asset attribute " + + property.getName() + " for " + + obj.getOID() ); + } + + FileAsset fa = new FileAsset((DataObject)value); + appendFileAsset(fa); + } + } else { + if (value != null && !property.isRole()) { + m_text.append(" " + value); + } + } + } + + protected void beginRole(DomainObject obj, + String path, + Property property) { + } + + protected void endRole(DomainObject obj, + String path, + Property property) { + } + + + protected void beginAssociation(DomainObject obj, + String path, + Property property) { + DataAssociation association = + (DataAssociation)DomainServiceInterfaceExposer.get + (obj, property.getName()); + + if (association != null && + association.getObjectType().isSubtypeOf + (FileAsset.BASE_DATA_OBJECT_TYPE)) { + while (association.next()) { + if( s_log.isDebugEnabled() ) { + s_log.debug( "Adding file asset association " + + property.getName() + " for " + + obj.getOID() ); + } + + appendFileAsset(new FileAsset(association.getDataObject())); + } + } else if (association != null && + association.getObjectType().isSubtypeOf + (TextAsset.BASE_DATA_OBJECT_TYPE)) { + while (association.next()) { + if( s_log.isDebugEnabled() ) { + s_log.debug( "Adding text asset association " + + property.getName() + " for " + + obj.getOID() ); + } + + appendTextAsset(new TextAsset(association.getDataObject())); + } + } + } + + protected void endAssociation(DomainObject obj, + String path, + Property property) { + } + + private void appendTextAsset(TextAsset asset) { + String content = asset.getText(); + if (content != null) { + m_text.append(" " + StringUtils.htmlToText(content)); + } + } + + private void appendFileAsset(FileAsset asset) { + Converter converter = + ConverterRegistry.getConverter(asset.getMimeType()); + if (converter != null) { + if( s_log.isDebugEnabled() ) { + s_log.debug( "Converting " + asset.getOID() + " using " + + converter.getClass().getName() ); + } + + try { + String converted = converter.convertDocument + ( asset.getContent() ); + + if( s_log.isDebugEnabled() ) { + s_log.debug( "Converted file is: " + converted ); + } + + m_text.append( " " ).append( converted ); + } catch (ConversionException e) { + s_log.error("Error converting FileAsset " + asset.getOID()+ + " with MimeType " + asset.getMimeType(), e); + } + } else { + s_log.debug("Skipping FileAsset " + asset.getOID() + + " with MimeType " + asset.getMimeType()); + } + } + } +} Copied: ccm-cms/trunk/src/com/arsdigita/cms/search/XMLContentProvider.java (from rev 170, ccm-cms/trunk/src/com/arsdigita/cms/search/ContentPageXMLContentProvider.java) =================================================================== --- ccm-cms/trunk/src/com/arsdigita/cms/search/ContentPageXMLContentProvider.java 2005-01-05 16:32:08 UTC (rev 170) +++ ccm-cms/trunk/src/com/arsdigita/cms/search/XMLContentProvider.java 2005-01-20 09:48:10 UTC (rev 184) @@ -0,0 +1,88 @@ +/* + * Copyright (C) 2003-2004 Red Hat Inc. All Rights Reserved. + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public License + * as published by the Free Software Foundation; either version 2.1 of + * the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Les... [truncated message content] |