You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@ofbiz.apache.org by jl...@apache.org on 2013/06/15 15:40:42 UTC

svn commit: r1493352 - in /ofbiz/trunk: framework/common/script/org/ofbiz/common/PortalPageServices.xml framework/widget/src/org/ofbiz/widget/PortalPageWorker.java themes/tomahawk/includes/appbarClose.ftl

Author: jleroux
Date: Sat Jun 15 13:40:42 2013
New Revision: 1493352

URL: http://svn.apache.org/r1493352
Log:
A patch from Olivier Heintz for "Portal page personalization is not working" https://issues.apache.org/jira/browse/OFBIZ-5189

Two simples errors after last change from FastList to standard java List :
1) go to example component / Dasboard 
1.1) click on edit for one page
Screen is blocked
reason : 
{code}
                    for (GenericValue portalPage : portalPages) {
                        cond = EntityCondition.makeCondition(UtilMisc.toList(
                                EntityCondition.makeCondition("ownerUserLoginId", EntityOperator.EQUALS, userLoginId),
                                EntityCondition.makeCondition("originalPortalPageId", EntityOperator.EQUALS, portalPage.getString("portalPageId"))),
                                EntityOperator.AND);
                        List <GenericValue> privatePortalPages = delegator.findList("PortalPage", cond, null, null, null, false);
                        if (UtilValidate.isNotEmpty(privatePortalPages)) {
                            portalPages.remove(portalPage);
                            portalPages.add(privatePortalPages.get(0));
                        }
                    }
{code}
code iterate on a list and modify it, I don't know how it could work before ;-)
I propose to use an other list on iterate 

2) on appbarclose.ftl for tomawak theme there is
{code}
    <#assign portalPage = delegator.findOne("PortalPage", findMap, true)>
{code}
when you click to "revert to original" in dasboard screen
{code}
Error on line 45, column 5 in component://tomahawk/includes/appbarClose.ftl delegator.findOne("PortalPage", findMap, true) is undefined. It cannot be assigned to portalPage The problematic instruction: ---------- ==> assignment: portalPage=delegator.findOne("PortalPage", findMap, true) [on line 45, column 5 in component://tomahawk/includes/appbarClose.ftl] -
{code}
2.1) to see the error, modify ExampleMenus.xml and change menu-item name from "Dasboard" to "Dasboard1" 
2.2) go to example / dashboard and edit one page
2.3) click to "revert to original"
I propose to add ?if_exists 

One other bug in portal page personalization.
When trying to delete portlet or column in portal page, there is an error because in delete service, cache is used to read data before remove.

Correction proposed is to remove use-cache="true"

Modified:
    ofbiz/trunk/framework/common/script/org/ofbiz/common/PortalPageServices.xml
    ofbiz/trunk/framework/widget/src/org/ofbiz/widget/PortalPageWorker.java
    ofbiz/trunk/themes/tomahawk/includes/appbarClose.ftl

Modified: ofbiz/trunk/framework/common/script/org/ofbiz/common/PortalPageServices.xml
URL: http://svn.apache.org/viewvc/ofbiz/trunk/framework/common/script/org/ofbiz/common/PortalPageServices.xml?rev=1493352&r1=1493351&r2=1493352&view=diff
==============================================================================
--- ofbiz/trunk/framework/common/script/org/ofbiz/common/PortalPageServices.xml (original)
+++ ofbiz/trunk/framework/common/script/org/ofbiz/common/PortalPageServices.xml Sat Jun 15 13:40:42 2013
@@ -50,7 +50,7 @@ under the License.
 
     <simple-method method-name="deletePortalPageColumn" short-description="Delete a Column from a PortalPage">
         <call-simple-method method-name="checkOwnerShip"/>
-        <entity-one entity-name="PortalPageColumn" value-field="column" auto-field-map="true" use-cache="true"/>
+        <entity-one entity-name="PortalPageColumn" value-field="column" auto-field-map="true"/>
         <if-not-empty field="column">
             <entity-and entity-name="PortalPagePortlet" list="portalPortletList">
                 <field-map field-name="portalPageId" from-field="column.portalPageId"/>
@@ -97,7 +97,7 @@ under the License.
 
     <simple-method method-name="deletePortalPagePortlet" short-description="Delete a PortalPortlet from a PortalPageColumn">
         <call-simple-method method-name="checkOwnerShip"/>
-        <entity-one entity-name="PortalPagePortlet" value-field="portlet" auto-field-map="true" use-cache="true"/>
+        <entity-one entity-name="PortalPagePortlet" value-field="portlet" auto-field-map="true"/>
         <if-not-empty field="portlet">
             <make-value value-field="newEntity" entity-name="PortletAttribute"/>
             <set field="newEntity.portalPageId" from-field="portlet.portalPageId"/>

Modified: ofbiz/trunk/framework/widget/src/org/ofbiz/widget/PortalPageWorker.java
URL: http://svn.apache.org/viewvc/ofbiz/trunk/framework/widget/src/org/ofbiz/widget/PortalPageWorker.java?rev=1493352&r1=1493351&r2=1493352&view=diff
==============================================================================
--- ofbiz/trunk/framework/widget/src/org/ofbiz/widget/PortalPageWorker.java (original)
+++ ofbiz/trunk/framework/widget/src/org/ofbiz/widget/PortalPageWorker.java Sat Jun 15 13:40:42 2013
@@ -19,6 +19,7 @@
 package org.ofbiz.widget;
 
 import java.io.IOException;
+import java.util.ArrayList;
 import java.util.List;
 import java.util.Map;
 import org.ofbiz.base.util.Debug;
@@ -66,6 +67,7 @@ public class PortalPageWorker {
                                 EntityOperator.OR)),
                         EntityOperator.AND);
                 portalPages = delegator.findList("PortalPage", cond, null, null, null, false);
+                List<GenericValue> userPortalPages = new ArrayList<GenericValue>();
                 if (UtilValidate.isNotEmpty(context.get("userLogin"))) { // check if a user is logged in
                     String userLoginId = ((GenericValue)context.get("userLogin")).getString("userLoginId");
                     // replace with private pages
@@ -76,8 +78,10 @@ public class PortalPageWorker {
                                 EntityOperator.AND);
                         List <GenericValue> privatePortalPages = delegator.findList("PortalPage", cond, null, null, null, false);
                         if (UtilValidate.isNotEmpty(privatePortalPages)) {
-                            portalPages.remove(portalPage);
-                            portalPages.add(privatePortalPages.get(0));
+                            //portalPages.remove(portalPage);
+                            userPortalPages.add(privatePortalPages.get(0));
+                        } else {
+                            userPortalPages.add(portalPage);
                         }
                     }
                     // add any other created private pages
@@ -86,9 +90,9 @@ public class PortalPageWorker {
                             EntityCondition.makeCondition("originalPortalPageId", EntityOperator.EQUALS, null),
                             EntityCondition.makeCondition("parentPortalPageId", EntityOperator.EQUALS, parentPortalPageId)),
                             EntityOperator.AND);
-                    portalPages.addAll(delegator.findList("PortalPage", cond, null, null, null, false));
+                    userPortalPages.addAll(delegator.findList("PortalPage", cond, null, null, null, false));
                 }
-                portalPages = EntityUtil.orderBy(portalPages, UtilMisc.toList("sequenceNum"));
+                portalPages = EntityUtil.orderBy(userPortalPages, UtilMisc.toList("sequenceNum"));
             } catch (GenericEntityException e) {
                 Debug.logError("Could not retrieve portalpages:" + e.getMessage(), module);
             }

Modified: ofbiz/trunk/themes/tomahawk/includes/appbarClose.ftl
URL: http://svn.apache.org/viewvc/ofbiz/trunk/themes/tomahawk/includes/appbarClose.ftl?rev=1493352&r1=1493351&r2=1493352&view=diff
==============================================================================
--- ofbiz/trunk/themes/tomahawk/includes/appbarClose.ftl (original)
+++ ofbiz/trunk/themes/tomahawk/includes/appbarClose.ftl Sat Jun 15 13:40:42 2013
@@ -42,7 +42,7 @@ under the License.
 
 <#if parameters.portalPageId?has_content && !appModelMenu.getModelMenuItemByName(headerItem)?exists && userLogin?exists>
     <#assign findMap = Static["org.ofbiz.base.util.UtilMisc"].toMap("portalPageId", parameters.portalPageId)>
-    <#assign portalPage = delegator.findOne("PortalPage", findMap, true)>
+    <#assign portalPage = delegator.findOne("PortalPage", findMap, true)?if_exists>
     <#if portalPage?has_content>
       <div id="app-nav-selected-item">
         ${portalPage.get("portalPageName", locale)?if_exists}