svn commit: r569568 - in /ofbiz/trunk/applications/content: entitydef/entitymodel.xml src/org/ofbiz/content/ContentManagementServices.java widget/forum/ForumForms.xml widget/forum/ForumScreens.xml widget/forum/ForumTrees.xml

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
1 message Options
Reply | Threaded
Open this post in threaded view
|

svn commit: r569568 - in /ofbiz/trunk/applications/content: entitydef/entitymodel.xml src/org/ofbiz/content/ContentManagementServices.java widget/forum/ForumForms.xml widget/forum/ForumScreens.xml widget/forum/ForumTrees.xml

adrianc
Author: adrianc
Date: Fri Aug 24 16:16:18 2007
New Revision: 569568

URL: http://svn.apache.org/viewvc?rev=569568&view=rev
Log:
More fixes in the forum feature in the content component. I also added a few comments to indicate what different fields are used for.

The eCommerce component organized forum data one way, and the content component organized it another way. After discussion on the dev ml, I determined that the content component was storing data incorrectly.

This commit is not backwards compatible with existing forum messages. Existing forum messages will have to have the contents of ContentAssoc.contentId and ContentAssoc.contentIdTo swapped before updating to this revision.

Modified:
    ofbiz/trunk/applications/content/entitydef/entitymodel.xml
    ofbiz/trunk/applications/content/src/org/ofbiz/content/ContentManagementServices.java
    ofbiz/trunk/applications/content/widget/forum/ForumForms.xml
    ofbiz/trunk/applications/content/widget/forum/ForumScreens.xml
    ofbiz/trunk/applications/content/widget/forum/ForumTrees.xml

Modified: ofbiz/trunk/applications/content/entitydef/entitymodel.xml
URL: http://svn.apache.org/viewvc/ofbiz/trunk/applications/content/entitydef/entitymodel.xml?rev=569568&r1=569567&r2=569568&view=diff
==============================================================================
--- ofbiz/trunk/applications/content/entitydef/entitymodel.xml (original)
+++ ofbiz/trunk/applications/content/entitydef/entitymodel.xml Fri Aug 24 16:16:18 2007
@@ -187,7 +187,7 @@
             title="Content Entity">
       <field name="contentId" type="id-ne"></field>
       <field name="contentTypeId" type="id"></field>
-      <field name="ownerContentId" type="id"></field>
+      <field name="ownerContentId" type="id"></field> <!-- used for permissions checking -->
       <field name="decoratorContentId" type="id"></field>
       <field name="instanceOfContentId" type="id"></field>
       <field name="dataResourceId" type="id"></field>
@@ -263,7 +263,7 @@
         <key-map field-name="contentId" rel-field-name="contentIdStart" />
       </relation>
     </entity>
-    <view-entity entity-name="ContentAndRole" package-name="org.ofbiz.content.content" title="Content And Role Entity">
+    <view-entity entity-name="ContentAndRole" package-name="org.ofbiz.content.content" title="Content And Role View Entity">
         <member-entity entity-alias="CNT" entity-name="Content"/>
         <member-entity entity-alias="CRLE" entity-name="ContentRole"/>
         <alias-all entity-alias="CNT"/>
@@ -311,8 +311,8 @@
     <entity entity-name="ContentAssoc"
             package-name="org.ofbiz.content.content"
             title="Content Association Entity">
-      <field name="contentId" type="id-ne"></field>
-      <field name="contentIdTo" type="id-ne"></field>
+      <field name="contentId" type="id-ne"></field> <!-- "parent" content -->
+      <field name="contentIdTo" type="id-ne"></field> <!-- "child" or "sub" content -->
       <field name="contentAssocTypeId" type="id"></field>
       <field name="fromDate" type="date-time"></field>
       <field name="thruDate" type="date-time"></field>
@@ -359,7 +359,7 @@
     </entity>
     <view-entity entity-name="ContentAssocDataResourceViewFrom"
                 package-name="org.ofbiz.content.content"
-                title="Main Assoc To and DataResource">
+                title="Main Assoc From and DataResource View Entity">
       <member-entity entity-alias="CO" entity-name="Content"/>
       <member-entity entity-alias="CA" entity-name="ContentAssoc"/>
       <member-entity entity-alias="DR" entity-name="DataResource"/>
@@ -402,7 +402,7 @@
     </view-entity>
     <view-entity entity-name="ContentAssocDataResourceViewTo"
                 package-name="org.ofbiz.content.content"
-                title="Main Assoc To and DataResource">
+                title="Main Assoc To and DataResource View Entity">
       <member-entity entity-alias="CO" entity-name="Content"/>
       <member-entity entity-alias="CA" entity-name="ContentAssoc"/>
       <member-entity entity-alias="DR" entity-name="DataResource"/>
@@ -461,7 +461,7 @@
     </entity>
    <view-entity entity-name="ContentAssocViewFrom"
                 package-name="org.ofbiz.content.content"
-                title="Main Assoc To">
+                title="Main Assoc From View Entity">
       <member-entity entity-alias="CO" entity-name="Content"/>
       <member-entity entity-alias="CA" entity-name="ContentAssoc"/>
       <alias-all entity-alias="CO"/>
@@ -475,7 +475,7 @@
     </view-entity>
     <view-entity entity-name="ContentAssocViewTo"
                 package-name="org.ofbiz.content.content"
-                title="Main Assoc To">
+                title="Main Assoc To View Entity">
       <member-entity entity-alias="CO" entity-name="Content"/>
       <member-entity entity-alias="CA" entity-name="ContentAssoc"/>
       <alias-all entity-alias="CO"/>
@@ -504,7 +504,7 @@
     </entity>
     <view-entity entity-name="ContentDataResourceView"
                 package-name="org.ofbiz.content.content"
-                title="Content and DataResource">
+                title="Content and DataResource View Entity">
       <member-entity entity-alias="CO" entity-name="Content"/>
       <member-entity entity-alias="DR" entity-name="DataResource"/>
       <alias-all entity-alias="CO" />
@@ -542,7 +542,7 @@
     </view-entity>
     <view-entity entity-name="CommEventContentDataResource"
                 package-name="org.ofbiz.content.content"
-                title="CommEvent and Content and DataResource">
+                title="CommEvent and Content and DataResource View Entity">
       <member-entity entity-alias="CECA" entity-name="CommEventContentAssoc"/>
       <member-entity entity-alias="CO" entity-name="Content"/>
       <member-entity entity-alias="DR" entity-name="DataResource"/>
@@ -758,7 +758,7 @@
     </entity>
     <view-entity entity-name="SubContentDataResourceView"
                 package-name="org.ofbiz.content.content"
-                title="Content and DataResource for SubContent">
+                title="Content and DataResource for SubContent View Entity">
       <member-entity entity-alias="CO" entity-name="Content"/>
       <member-entity entity-alias="DR" entity-name="DataResource"/>
       <alias-all entity-alias="CO" />

Modified: ofbiz/trunk/applications/content/src/org/ofbiz/content/ContentManagementServices.java
URL: http://svn.apache.org/viewvc/ofbiz/trunk/applications/content/src/org/ofbiz/content/ContentManagementServices.java?rev=569568&r1=569567&r2=569568&view=diff
==============================================================================
--- ofbiz/trunk/applications/content/src/org/ofbiz/content/ContentManagementServices.java (original)
+++ ofbiz/trunk/applications/content/src/org/ofbiz/content/ContentManagementServices.java Fri Aug 24 16:16:18 2007
@@ -148,13 +148,13 @@
 
     /**
      * persistContentAndAssoc
-     * A combination method that will create or update all or one of the following
-     * a Content entity, a ContentAssoc related to the Content and
+     * A combination method that will create or update all or one of the following:
+     * a Content entity, a ContentAssoc related to the Content, and
      * the ElectronicText that may be associated with the Content.
      * The keys for determining if each entity is created is the presence
      * of the contentTypeId, contentAssocTypeId and dataResourceTypeId.
-     * This service tries to handle DataResource and ContentAssoc fields with and
-     * without "dr" and "ca" prefixes.
+     * This service tries to handle DataResource fields with and
+     * without "dr" prefixes.
      * Assumes binary data is always in field, "imageData".
      *
      * This service does not accept straight ContentAssoc parameters. They must be prefaced with "ca" + cap first letter
@@ -213,7 +213,13 @@
         if (Debug.infoOn()) Debug.logInfo("in persist... dataResourceId(0):" + dataResourceId, null);
 
         GenericValue contentAssoc = delegator.makeValue("ContentAssoc", null);
+        String contentAssocTypeId = (String)context.get("contentAssocTypeId");
+        if (UtilValidate.isNotEmpty(contentAssocTypeId)) {
+            context.put("caContentAssocTypeId", contentAssocTypeId);
+        }
+        contentAssocTypeId = (String)context.get("caContentAssocTypeId");
         contentAssoc.setAllFields(context, false, "ca", null);
+        contentAssoc.put("contentId", context.get("caContentId"));
         context.putAll(contentAssoc);
 
         GenericValue electronicText = delegator.makeValue("ElectronicText", null);
@@ -296,7 +302,7 @@
                 //targetOperations.add("CONTENT_UPDATE");
                 Map contentContext = new HashMap();
                 ModelService contentModel = dispatcher.getDispatchContext().getModelService("updateContent");
-                contentContext.putAll(contentModel.makeValid(context, "IN"));
+                contentContext.putAll(contentModel.makeValid(content, "IN"));
                 contentContext.put("userLogin", userLogin);
                 contentContext.put("displayFailCond", bDisplayFailCond);
                 contentContext.put("skipPermissionCheck", context.get("skipPermissionCheck"));
@@ -309,7 +315,7 @@
                 //targetOperations.add("CONTENT_CREATE");
                 Map contentContext = new HashMap();
                 ModelService contentModel = dispatcher.getDispatchContext().getModelService("createContent");
-                contentContext.putAll(contentModel.makeValid(context, "IN"));
+                contentContext.putAll(contentModel.makeValid(content, "IN"));
                 contentContext.put("userLogin", userLogin);
                 contentContext.put("displayFailCond", bDisplayFailCond);
                 contentContext.put("skipPermissionCheck", context.get("skipPermissionCheck"));
@@ -362,14 +368,14 @@
         }
 
         // If parentContentIdTo or parentContentIdFrom exists, create association with newly created content
-        String contentAssocTypeId = (String)context.get("contentAssocTypeId");
-        if (UtilValidate.isEmpty(contentAssocTypeId))
-            contentAssocTypeId = (String)context.get("caContentAssocTypeId");
-
-        if (Debug.infoOn()) Debug.logInfo("CREATING contentASSOC contentAssocTypeId:" +  contentAssocTypeId, null);
+        if (Debug.infoOn()) {
+            Debug.logInfo("CREATING contentASSOC contentAssocTypeId:" + contentAssocTypeId, null);
+        }
         // create content assoc if the key values are present....
-        if (contentAssocTypeId != null && contentAssocTypeId.length() > 0 && contentAssoc.get("contentId") != null && contentAssoc.get("contentIdTo") != null ) {
-            if (Debug.infoOn()) Debug.logInfo("in persistContentAndAssoc, deactivateExisting:" +  deactivateExisting, null);
+        Debug.logInfo("contentAssoc: " + contentAssoc.toString(), null);
+        if (UtilValidate.isNotEmpty(contentAssocTypeId) && contentAssoc.get("contentId") != null && contentAssoc.get("contentIdTo") != null) {
+            if (Debug.infoOn())
+                Debug.logInfo("in persistContentAndAssoc, deactivateExisting:" + deactivateExisting, null);
             Map contentAssocContext = new HashMap();
             contentAssocContext.put("userLogin", userLogin);
             contentAssocContext.put("displayFailCond", bDisplayFailCond);
@@ -386,13 +392,18 @@
                     if (ServiceUtil.isError(thisResult) || ServiceUtil.isFailure(thisResult) || UtilValidate.isNotEmpty(errMsg)) {
                         return ServiceUtil.returnError(errMsg);
                     }
-//                    results.put("contentIdTo", thisResult.get("contentIdTo"));
-//                    results.put("contentIdFrom", thisResult.get("contentIdFrom"));
-//                    //results.put("contentId", thisResult.get("contentIdFrom"));
-//                    results.put("contentAssocTypeId", thisResult.get("contentAssocTypeId"));
-//                    results.put("fromDate", thisResult.get("fromDate"));
-//                    results.put("sequenceNum", thisResult.get("sequenceNum"));
-                    
+                    // results.put("contentIdTo",
+                    // thisResult.get("contentIdTo"));
+                    // results.put("contentIdFrom",
+                    // thisResult.get("contentIdFrom"));
+                    // results.put("contentId",
+                    // thisResult.get("contentIdFrom"));
+                    // results.put("contentAssocTypeId",
+                    // thisResult.get("contentAssocTypeId"));
+                    // results.put("fromDate", thisResult.get("fromDate"));
+                    // results.put("sequenceNum",
+                    // thisResult.get("sequenceNum"));
+
                     results.put("caContentIdTo", thisResult.get("contentIdTo"));
                     results.put("caContentId", thisResult.get("contentIdFrom"));
                     results.put("caContentAssocTypeId", thisResult.get("contentAssocTypeId"));
@@ -400,7 +411,7 @@
                     results.put("caSequenceNum", thisResult.get("sequenceNum"));
                 } else {
                     if (deactivateExisting) {
-                        contentAssoc.put("thruDate",UtilDateTime.nowTimestamp());
+                        contentAssoc.put("thruDate", UtilDateTime.nowTimestamp());
                     }
                     ModelService contentAssocModel = dispatcher.getDispatchContext().getModelService("updateContentAssoc");
                     Map ctx = contentAssocModel.makeValid(contentAssoc, "IN");
@@ -417,16 +428,16 @@
                 throw new GenericServiceException(e2.getMessage());
             }
             String errMsg = ServiceUtil.getErrorMessage(thisResult);
-           if (UtilValidate.isNotEmpty(errMsg)) {
-               return ServiceUtil.returnError(errMsg);
-           }
-       }
-       context.remove("skipPermissionCheck");
-       context.put("contentId", origContentId);
-       context.put("dataResourceId", origDataResourceId);
-       context.remove("dataResource");
-       Debug.logInfo("results:" + results, module);
-       return results;
+            if (UtilValidate.isNotEmpty(errMsg)) {
+                return ServiceUtil.returnError(errMsg);
+            }
+        }
+        context.remove("skipPermissionCheck");
+        context.put("contentId", origContentId);
+        context.put("dataResourceId", origDataResourceId);
+        context.remove("dataResource");
+        Debug.logInfo("results:" + results, module);
+        return results;
     }
 
     /**

Modified: ofbiz/trunk/applications/content/widget/forum/ForumForms.xml
URL: http://svn.apache.org/viewvc/ofbiz/trunk/applications/content/widget/forum/ForumForms.xml?rev=569568&r1=569567&r2=569568&view=diff
==============================================================================
--- ofbiz/trunk/applications/content/widget/forum/ForumForms.xml (original)
+++ ofbiz/trunk/applications/content/widget/forum/ForumForms.xml Fri Aug 24 16:16:18 2007
@@ -166,7 +166,7 @@
         <field name="forumMessageTitle" parameter-name="description"><text default-value="${forumMessage.description}"/></field>
         <field name="contentTypeId"><hidden value="DOCUMENT"/></field>
         <field name="ownerContentId"><hidden value="${parameters.forumId}"/></field>
-        <field name="caContentIdTo"><hidden value="${parameters.forumMessageIdTo}"/></field>
+        <field name="caContentId"><hidden value="${parameters.forumMessageIdTo}"/></field>
         <field name="caContentAssocTypeId"><hidden value="RESPONSE"/></field>
         <field name="forumMessageText" parameter-name="textData"><textarea rows="10" visual-editor-enable="true" visual-editor-buttons="undo redo bold italic underline bullet indent outdent link"/></field>
         <field name="addButton" title="${uiLabelMap.CommonAdd}" widget-style="smallSubmit"><submit button-type="button"/></field>
@@ -176,7 +176,7 @@
     <form name="EditForumThreadMessage" type="single" target="updateForumThreadMessage">
         <field name="forumGroupId"><hidden value="${parameters.forumGroupId}"/></field>
         <field name="forumId"><hidden value="${parameters.forumId}"/></field>
-        <field name="rsp.contentId" parameter-name="contenId"><hidden/></field>
+        <field name="rsp.contentId" parameter-name="contentId"><hidden/></field>
         <field name="rsp.contentName" parameter-name="contentName"><hidden/></field>
         <field name="rsp.description" parameter-name="description"><text/></field>
         <field name="rsp.contentTypeId" parameter-name="contentTypeId"><hidden/></field>

Modified: ofbiz/trunk/applications/content/widget/forum/ForumScreens.xml
URL: http://svn.apache.org/viewvc/ofbiz/trunk/applications/content/widget/forum/ForumScreens.xml?rev=569568&r1=569567&r2=569568&view=diff
==============================================================================
--- ofbiz/trunk/applications/content/widget/forum/ForumScreens.xml (original)
+++ ofbiz/trunk/applications/content/widget/forum/ForumScreens.xml Fri Aug 24 16:16:18 2007
@@ -64,7 +64,7 @@
                 </entity-one>
                 <set field="objectName" from-field="forumGroup.contentName"/>
                 <set field="objectId"  from-field="forumGroup.contentId"/>
-                <entity-and entity-name="ContentAssocDataResourceViewFrom" list-name="forums">
+                <entity-and entity-name="ContentAssocDataResourceViewTo" list-name="forums">
                     <field-map field-name="contentIdStart" env-name="forumGroupId"/>
                 </entity-and>
             </actions>

Modified: ofbiz/trunk/applications/content/widget/forum/ForumTrees.xml
URL: http://svn.apache.org/viewvc/ofbiz/trunk/applications/content/widget/forum/ForumTrees.xml?rev=569568&r1=569567&r2=569568&view=diff
==============================================================================
--- ofbiz/trunk/applications/content/widget/forum/ForumTrees.xml (original)
+++ ofbiz/trunk/applications/content/widget/forum/ForumTrees.xml Fri Aug 24 16:16:18 2007
@@ -29,9 +29,9 @@
             </entity-one>
             <!--include-screen name="responseTreeLine" location="component://content/widget/forum/ForumScreens.xml" /-->
             <sub-node node-name="node-body">
-                <entity-condition entity-name="ContentAssocViewFrom" use-cache="false" >
+                <entity-condition entity-name="ContentAssocViewTo" use-cache="false" >
                     <condition-list combine="and">
-                        <condition-expr field-name="caContentIdTo" operator="equals" env-name="rsp.contentId" />
+                        <condition-expr field-name="contentIdStart" operator="equals" env-name="rsp.contentId" />
                         <condition-list combine="or">
                             <condition-expr field-name="caContentAssocTypeId" operator="equals" value="RESPONSE" />
                             <condition-expr field-name="caContentAssocTypeId" operator="equals" value="PUBLISH_LINK" />
@@ -45,9 +45,9 @@
         <node name="node-body" entry-name="rsp">
             <include-screen name="responseTreeLine"  location="${parameters.mainDecoratorLocation}" />
             <sub-node node-name="node-body">
-                <entity-condition entity-name="ContentAssocViewFrom" use-cache="true" >
+                <entity-condition entity-name="ContentAssocViewTo" use-cache="true" >
                     <condition-list combine="and">
-                        <condition-expr field-name="caContentIdTo" operator="equals" env-name="rsp.contentId" />
+                        <condition-expr field-name="contentIdStart" operator="equals" env-name="rsp.contentId" />
                         <condition-expr field-name="caContentAssocTypeId" operator="equals" value="RESPONSE" />
                         <condition-expr field-name="caThruDate" operator="equals" value=""/>
                     </condition-list>