From 8138d560a31bda4cc6bf5d00dbb2ce03fc44bc42 Mon Sep 17 00:00:00 2001 From: pb Date: Fri, 15 Feb 2008 21:06:03 +0000 Subject: [PATCH] incporporating APLAWS patches 1686 & 1687: r1686 | chrisg23 | 2007-10-23 16:11:16 +0200 (Di, 23 Okt 2007) Change sql to a version that both Oracle and Postgres understand ------------------------------------------------------------------------ r1687 | chrisg23 | 2007-10-23 16:16:50 +0200 (Di, 23 Okt 2007) sourceforge patch [1803373] - don't stream out blob data until it's actually needed. Note this is configurable so that by default there is no behaviour change, but really it would be unusual to actively want the overhead of the additional streamout. Credit to matt at magpie for this one git-svn-id: https://svn.libreccm.org/ccm/trunk@35 8810af33-2d31-482b-a856-94f89814c4df --- ...rt-application-container-group-columns.sql | 4 +-- ccm-core/src/ccm-core.config | 2 ++ ccm-core/src/com/arsdigita/domain/Domain.java | 21 ++++++++++++ .../com/arsdigita/domain/DomainConfig.java | 25 ++++++++++++++ .../domain/DomainConfig_parameter.properties | 4 +++ .../domain/DomainObjectTraversal.java | 34 ++++++++++++++++--- 6 files changed, 84 insertions(+), 6 deletions(-) create mode 100644 ccm-core/src/com/arsdigita/domain/Domain.java create mode 100644 ccm-core/src/com/arsdigita/domain/DomainConfig.java create mode 100644 ccm-core/src/com/arsdigita/domain/DomainConfig_parameter.properties diff --git a/ccm-core/sql/ccm-core/default/upgrade/6.5.3-6.5.4/insert-application-container-group-columns.sql b/ccm-core/sql/ccm-core/default/upgrade/6.5.3-6.5.4/insert-application-container-group-columns.sql index fbac1b88f..aecb98de5 100755 --- a/ccm-core/sql/ccm-core/default/upgrade/6.5.3-6.5.4/insert-application-container-group-columns.sql +++ b/ccm-core/sql/ccm-core/default/upgrade/6.5.3-6.5.4/insert-application-container-group-columns.sql @@ -14,10 +14,10 @@ -- Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA -- alter table application_types -add (container_group_id NUMBER); +add container_group_id integer; alter table applications -add (container_group_id NUMBER); +add container_group_id integer; alter table application_types add constraint applic_typ_cont_gro_id_f_lszuh foreign key (container_group_id) diff --git a/ccm-core/src/ccm-core.config b/ccm-core/src/ccm-core.config index f50485673..45961ee4d 100755 --- a/ccm-core/src/ccm-core.config +++ b/ccm-core/src/ccm-core.config @@ -34,4 +34,6 @@ storage="ccm-core/core-xml.properties"/> + diff --git a/ccm-core/src/com/arsdigita/domain/Domain.java b/ccm-core/src/com/arsdigita/domain/Domain.java new file mode 100644 index 000000000..75f43a7e2 --- /dev/null +++ b/ccm-core/src/com/arsdigita/domain/Domain.java @@ -0,0 +1,21 @@ +package com.arsdigita.domain; + + +public class Domain { + + + private static DomainConfig s_config; + + /** + * Gets the DomainConfig object. + */ + public static final DomainConfig getConfig() { + if (s_config == null) { + s_config = new DomainConfig(); + s_config.load("ccm-core/domain.properties"); + } + return s_config; + + } + +} diff --git a/ccm-core/src/com/arsdigita/domain/DomainConfig.java b/ccm-core/src/com/arsdigita/domain/DomainConfig.java new file mode 100644 index 000000000..051983e7f --- /dev/null +++ b/ccm-core/src/com/arsdigita/domain/DomainConfig.java @@ -0,0 +1,25 @@ +package com.arsdigita.domain; + +import com.arsdigita.runtime.AbstractConfig; +import com.arsdigita.util.parameter.BooleanParameter; +import com.arsdigita.util.parameter.Parameter; + +public final class DomainConfig extends AbstractConfig { + + private final BooleanParameter m_queryBlobContent; + + public DomainConfig() { + + m_queryBlobContent = new BooleanParameter( + "waf.domain.query_file_attachment_blob", Parameter.OPTIONAL, + Boolean.TRUE); + + register(m_queryBlobContent); + loadInfo(); + } + + public boolean queryBlobContentForFileAttachments() { + return ((Boolean) get(m_queryBlobContent)).booleanValue(); + } + +} diff --git a/ccm-core/src/com/arsdigita/domain/DomainConfig_parameter.properties b/ccm-core/src/com/arsdigita/domain/DomainConfig_parameter.properties new file mode 100644 index 000000000..64bcb2c83 --- /dev/null +++ b/ccm-core/src/com/arsdigita/domain/DomainConfig_parameter.properties @@ -0,0 +1,4 @@ +waf.domain.query_file_attachment_blob.title=Unnecessarily Query Blobs? +waf.domain.query_file_attachment_blob.purpose=Allows you to prevent an unnecessary and expensive query on cms_files.content. For legacy reasons the defualt is true - go on set it to false.. (assuming that you have ccm-cms-assets-fileattachment loaded) +waf.domain.query_file_attachment_blob.example=true|false +waf.domain.query_file_attachment_blob.format=[boolean] \ No newline at end of file diff --git a/ccm-core/src/com/arsdigita/domain/DomainObjectTraversal.java b/ccm-core/src/com/arsdigita/domain/DomainObjectTraversal.java index 1926739ec..d840b9dc7 100755 --- a/ccm-core/src/com/arsdigita/domain/DomainObjectTraversal.java +++ b/ccm-core/src/com/arsdigita/domain/DomainObjectTraversal.java @@ -22,9 +22,12 @@ import com.arsdigita.util.Assert; import com.arsdigita.persistence.metadata.ObjectType; import com.arsdigita.persistence.metadata.Property; +import com.arsdigita.persistence.DataCollection; import com.arsdigita.persistence.DataObject; import com.arsdigita.persistence.DataAssociation; import com.arsdigita.persistence.DataAssociationCursor; +import com.arsdigita.persistence.DataQuery; +import com.arsdigita.persistence.DataQueryDataCollectionAdapter; import com.arsdigita.persistence.OID; import com.arsdigita.persistence.SessionManager; @@ -323,15 +326,38 @@ public abstract class DomainObjectTraversal { endRole(obj, path, prop); } else if (propValue instanceof DataAssociation) { + + + // see #25808 - this hack prevents the content field of cms_files + // (which is a blob) from being queried when all we need is a list + // of the files on an item.. + if (prop.getName().equals("fileAttachments") && !Domain.getConfig().queryBlobContentForFileAttachments()) { // make true a config + DataQuery fileAttachmentsQuery = SessionManager.getSession().retrieveQuery("com.arsdigita.cms.contentassets.fileAttachmentsQuery"); + + fileAttachmentsQuery.setParameter("item_id", obj.getOID().get("id")); + + DataCollection files = new DataQueryDataCollectionAdapter(fileAttachmentsQuery, "file"); + + while(files.next()) { + DataObject file = files.getDataObject(); + walk(adapter, + DomainObjectFactory.newInstance + (file), + appendToPath(path, propName), + context, + null); + } + + } else { + if( s_log.isDebugEnabled() ) { s_log.debug( prop.getName() + " is a DataAssociation" ); } - beginAssociation(obj, path, prop); - + DataAssociationCursor daCursor = ((DataAssociation)propValue).getDataAssociationCursor(); - + while (daCursor.next()) { DataObject link = daCursor.getLink(); DomainObject linkObj = null; @@ -345,8 +371,8 @@ public abstract class DomainObjectTraversal { context, linkObj); } - endAssociation(obj, path, prop); + } } else { // Unknown property value type - do nothing }