Author: bpapez
Date: Tue Jul 17 14:17:20 2007
New Revision: 18025

URL: https://svndev.jahia.net/websvn/listing.php?sc=3D1&rev=3D18025&repname=
=3Djahia
Log:
issue UNIL-7: Dysfonctionnement de l'engine de propri=C3=A9t=C3=A9s des con=
tainer listes avec upgrade Jahia 4.2 =

http://www.jahia.net/jira/browse/UNIL-7

* The sorted list in the containerproperties engine was not updated correct=
ly after pressing Apply - this error was already present in Jahia 4.1, so i=
t is not new.
* After changing the sort, the semaphore was not switching to red and you w=
ere not able to publish the change as Jahia did not recognize the sorting a=
s a change. This bug was present only in Jahia 4.2.
* There was a bug in fetching the container IDs for a list in the JahiaCont=
ainerUtilsDB. The select has been changed to look the same as in Jahia 5. T=
he select returns staged and live versions sorted by rank and workflowstate=
, but this caused that in the result the top most staging container was fir=
st and then the top most live container second, although this one could hav=
e been moved further down. This bug is perhaps also present in Jahia 5 as t=
he code was back-ported. I will check it.

Modified:
    branches/JAHIA-4-1-BRANCH/src/java/org/jahia/engines/containerlistprope=
rties/ContainerListProperties_Engine.java
    branches/JAHIA-4-1-BRANCH/src/java/org/jahia/services/containers/JahiaC=
ontainerUtilsDB.java
    branches/JAHIA-4-1-BRANCH/src/java/org/jahia/services/pages/ContentPage=
.java

Modified: branches/JAHIA-4-1-BRANCH/src/java/org/jahia/engines/containerlis=
tproperties/ContainerListProperties_Engine.java
URL: https://svndev.jahia.net/websvn/diff.php?path=3D/branches/JAHIA-4-1-BR=
ANCH/src/java/org/jahia/engines/containerlistproperties/ContainerListProper=
ties_Engine.java&rev=3D18025&repname=3Djahia
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D
--- branches/JAHIA-4-1-BRANCH/src/java/org/jahia/engines/containerlistprope=
rties/ContainerListProperties_Engine.java (original)
+++ branches/JAHIA-4-1-BRANCH/src/java/org/jahia/engines/containerlistprope=
rties/ContainerListProperties_Engine.java Tue Jul 17 14:17:20 2007
@@ -47,6 +47,7 @@
 import org.jahia.services.acl.JahiaBaseACL;
 import org.jahia.services.audit.LoggingEventListener;
 import org.jahia.services.containers.ContentContainerList;
+import org.jahia.services.containers.JahiaContainersService;
 import org.jahia.services.lock.LockKey;
 import org.jahia.services.lock.LockService;
 import org.jahia.services.pages.ContentPage;
@@ -562,107 +563,7 @@
             theScreen =3D "edit";
             // init engine map
             engineMap =3D new HashMap ();
-            theContainerList =3D ServicesRegistry.getInstance ().
-                    getJahiaContainersService ().loadContainerList (
-                            cListID, LoadFlags.NOTHING, jParams);
-            engineMap.put ("theContainerList", theContainerList);
-
-            // print out container list properties
-            Properties props =3D theContainerList.getProperties ();
-            Enumeration enumeration =3D props.propertyNames ();
-            String p =3D EMPTY_STRING;
-            while (enumeration.hasMoreElements ()) {
-                p =3D (String) enumeration.nextElement ();
-                logger.debug ("Properties : " + props.getProperty (p));
-            }
-
-            // the ordered list of containers
-            Vector containers =3D new Vector ();
-            Enumeration containerList =3D theContainerList.getContainers (=
);
-            JahiaContainer theContainer =3D null;
-            // the info displayed to make the difference between containers
-            Vector fieldInfoToDisplay =3D new Vector ();
-            String fieldInfo =3D EMPTY_STRING;
-            // the date in millisecond (the vector is empty if the field i=
s not a date)
-            Vector sortInfo4Date =3D new Vector ();
-            String sortInfo =3D EMPTY_STRING;
-            int cnt =3D 0;
-
-            while (containerList.hasMoreElements ()) {
-                cnt++;
-                theContainer =3D (JahiaContainer) containerList.nextElemen=
t ();
-                // let's order the container fields in the exact order in =
which they are decrared in the template
-                // ( not as in the order in which they are stored in db )
-                theContainer.setLanguageCode (jParams.getEntryLoadRequest =
().
-                        getFirstLocale (true).toString ());
-                theContainer.fieldsStructureCheck (jParams);
-                containers.add (theContainer);
-                fieldInfo =3D getFieldInfoToDisplay (0, theContainer, jPar=
ams);
-                if (fieldInfo !=3D null) {
-                    if (fieldInfo.equals (EMPTY_STRING)) {
-                        fieldInfo =3D "-- Item " + cnt + " --";
-                    }
-                } else {
-                    fieldInfo =3D "-- Item " + cnt + " --";
-                }
-                fieldInfoToDisplay.add (fieldInfo);
-
-                sortInfo =3D getSortInfo4Date (0, theContainer, jParams);
-                if (sortInfo !=3D null) {
-                    sortInfo4Date.add (sortInfo);
-                }
-            }
-
-            JahiaField theField =3D null;
-            Enumeration fieldsList =3D null;
-            Vector fields =3D null;
-
-            if (theContainer =3D=3D null) {
-                // no containers in the container list
-                // create an empty container facade
-                ContentPage contentPage =3D
-                        ContentPage.getPage (theContainerList.getPageID ()=
, false);
-                JahiaContentContainerFacade contentContainerFacade =3D
-                        new JahiaContentContainerFacade (0,
-                                contentPage.getJahiaID (),
-                                theContainerList.getPageID (),
-                                theContainerList.getID (),
-                                theContainerList.getctndefid (),
-                                //contentPage.getAclID(),
-                                0,
-                                jParams,
-                                jParams.getSite ().getLanguageSettingsAsLo=
cales (false));
-                if (contentContainerFacade.getContainers ().hasMoreElement=
s ()) {
-                    theContainer =3D (JahiaContainer)
-                            contentContainerFacade.getContainers ().
-                            nextElement ();
-                    if (theContainer !=3D null) {
-                        theContainerList.addContainer (theContainer);
-                    }
-                }
-            }
-
-            if (theContainer !=3D null) {
-                fieldsList =3D theContainer.getFields ();
-
-                fields =3D new Vector ();
-
-                while (fieldsList.hasMoreElements ()) {
-                    theField =3D (JahiaField) fieldsList.nextElement ();
-                    fields.add (theField);
-                }
-            }
-
-            engineMap.put ("containers", containers);
-            engineMap.put ("fields", fields);
-            engineMap.put ("cursorField", new Integer (0));
-            engineMap.put ("fieldInfoToDisplay", fieldInfoToDisplay);
-            engineMap.put ("containerSelected", new Integer (0));
-
-            // build container list field acl
-            HashMap fieldAcls =3D buildFieldDefAcls (theContainerList, jPa=
rams,
-                    engineMap);
-            engineMap.put ("fieldAcls", fieldAcls);
+            theContainerList =3D fillEngineMap(cListID, jParams, engineMap=
, "");
         }
 =

         if (theContainerList =3D=3D null) {
@@ -898,31 +799,32 @@
      */
     private void saveContainersRank (ParamBean jParams, HashMap engineMap)
             throws JahiaException {
+       String curFieldStr =3D jParams.getParameter("cursorField");
         Vector containers_beforeSort =3D (Vector) engineMap.get ("containe=
rs");
         Vector containers =3D new Vector ();
 =

         String[] manRank =3D jParams.getRequest ().getParameterValues ("ma=
nRank");
         if (manRank !=3D null) {
-            int num =3D 0;
             for (int j =3D 0; j < manRank.length; j++) {
-                num =3D Integer.parseInt (manRank[j]);
+                final int num =3D Integer.parseInt (manRank[j]);
                 //System.out.println("####### Debug save CList: "+num);
                 containers.add (containers_beforeSort.get (num));
             }
         }
         int counter =3D containers.size ();
         JahiaContainer c;
-
+        JahiaContainersService jahiaContainersService =3D ServicesRegistry=
.getInstance().getJahiaContainersService();
         // rank are save with negative number, because new containers have=
 a rank equal to 0.
         // then new containers will appear at the end of the container lis=
t.
         for (int i =3D 0; i < containers.size (); i++) {
             c =3D (JahiaContainer) containers.get (i);
             c.setRank (counter * (-1));
-            ServicesRegistry.getInstance ().getJahiaContainersService ().
-                    saveContainerInfo (c, 0, 0, jParams);
+            jahiaContainersService.saveContainerInfo (c, 0, 0, jParams);
             counter--;
         }
-
+        JahiaContainerList theContainerList =3D (JahiaContainerList) engin=
eMap.get("theContainerList");
+        theContainerList.setProperty("automatic_sort_handler", "");
+        fillEngineMap(theContainerList.getID(), jParams, engineMap, curFie=
ldStr);
     }
 =

     /**
@@ -1273,4 +1175,105 @@
         theContainer =3D null;
         return hash;
     }
+ =

+    private JahiaContainerList fillEngineMap(int cListID, ParamBean jParam=
s,
+                       HashMap engineMap, String cursorField) throws 
JahiaException {
+               JahiaContainerList theContainerList =3D 
ServicesRegistry.getInstance()
+                               
.getJahiaContainersService().loadContainerList(cListID,
+                                               LoadFlags.NOTHING, jParams);
+               engineMap.put("theContainerList", theContainerList);
+
+               // print out container list properties
+               Properties props =3D theContainerList.getProperties();
+               Enumeration enumeration =3D props.propertyNames();
+               String p =3D EMPTY_STRING;
+               while (enumeration.hasMoreElements()) {
+                       p =3D (String) enumeration.nextElement();
+                       logger.debug("Properties : " + props.getProperty(p));
+               }
+
+               // the ordered list of containers
+               Vector containers =3D new Vector();
+               Enumeration containerList =3D theContainerList.getContainers();
+               JahiaContainer theContainer =3D null;
+               // the info displayed to make the difference between containers
+               Vector fieldInfoToDisplay =3D new Vector();
+               String fieldInfo =3D EMPTY_STRING;
+               // the date in millisecond (the vector is empty if the field is 
not a da=
te)
+               Vector sortInfo4Date =3D new Vector();
+               String sortInfo =3D EMPTY_STRING;
+               int cnt =3D 0;
+
+               while (containerList.hasMoreElements()) {
+                       cnt++;
+                       theContainer =3D (JahiaContainer) 
containerList.nextElement();
+                       // let's order the container fields in the exact order 
in which they ar=
e decrared in the template
+                       // ( not as in the order in which they are stored in db 
)
+                       
theContainer.setLanguageCode(jParams.getEntryLoadRequest()
+                                       .getFirstLocale(true).toString());
+                       theContainer.fieldsStructureCheck(jParams);
+                       containers.add(theContainer);
+                       fieldInfo =3D getFieldInfoToDisplay(0, theContainer, 
jParams);
+                       if (fieldInfo !=3D null) {
+                               if (fieldInfo.equals(EMPTY_STRING)) {
+                                       fieldInfo =3D "-- Item " + cnt + " --";
+                               }
+                       } else {
+                               fieldInfo =3D "-- Item " + cnt + " --";
+                       }
+                       fieldInfoToDisplay.add(fieldInfo);
+
+                       sortInfo =3D getSortInfo4Date(0, theContainer, jParams);
+                       if (sortInfo !=3D null) {
+                               sortInfo4Date.add(sortInfo);
+                       }
+               }
+
+               JahiaField theField =3D null;
+               Enumeration fieldsList =3D null;
+               Vector fields =3D null;
+
+               if (theContainer =3D=3D null) {
+                       // no containers in the container list
+                       // create an empty container facade
+                       ContentPage contentPage =3D 
ContentPage.getPage(theContainerList
+                                       .getPageID(), false);
+                       JahiaContentContainerFacade contentContainerFacade =3D 
new JahiaContent=
ContainerFacade(
+                                       0, contentPage.getJahiaID(), 
theContainerList.getPageID(),
+                                       theContainerList.getID(), 
theContainerList.getctndefid(),
+                                       //contentPage.getAclID(),
+                                       0, jParams, 
jParams.getSite().getLanguageSettingsAsLocales(
+                                                       false));
+                       if 
(contentContainerFacade.getContainers().hasMoreElements()) {
+                               theContainer =3D (JahiaContainer) 
contentContainerFacade
+                                               .getContainers().nextElement();
+                               if (theContainer !=3D null) {
+                                       
theContainerList.addContainer(theContainer);
+                               }
+                       }
+               }
+
+               if (theContainer !=3D null) {
+                       fieldsList =3D theContainer.getFields();
+
+                       fields =3D new Vector();
+
+                       while (fieldsList.hasMoreElements()) {
+                               theField =3D (JahiaField) 
fieldsList.nextElement();
+                               fields.add(theField);
+                       }
+               }
+
+               engineMap.put("containers", containers);
+               engineMap.put("fields", fields);
+               engineMap.put("cursorField", new Integer(0));
+               engineMap.put("fieldInfoToDisplay", fieldInfoToDisplay);
+               engineMap.put("containerSelected", new Integer(0));
+
+               // build container list field acl
+               HashMap fieldAcls =3D buildFieldDefAcls(theContainerList, 
jParams,
+                               engineMap);
+               engineMap.put("fieldAcls", fieldAcls);
+               return theContainerList;
+       }    =

 }

Modified: branches/JAHIA-4-1-BRANCH/src/java/org/jahia/services/containers/=
JahiaContainerUtilsDB.java
URL: https://svndev.jahia.net/websvn/diff.php?path=3D/branches/JAHIA-4-1-BR=
ANCH/src/java/org/jahia/services/containers/JahiaContainerUtilsDB.java&rev=
=3D18025&repname=3Djahia
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D
--- branches/JAHIA-4-1-BRANCH/src/java/org/jahia/services/containers/JahiaC=
ontainerUtilsDB.java (original)
+++ branches/JAHIA-4-1-BRANCH/src/java/org/jahia/services/containers/JahiaC=
ontainerUtilsDB.java Tue Jul 17 14:17:20 2007
@@ -1008,24 +1008,30 @@
                 rs =3D stmt.executeQuery();
                 Set deletedInStaging =3D null;
                 Set addedCtnIds =3D null;
-                if (loadVersion !=3D null && loadVersion.isStaging() && !l=
oadVersion.isWithMarkedForDeletion()) {
-                    deletedInStaging =3D new HashSet();
-                    addedCtnIds =3D new HashSet();                    =

+                if (loadVersion !=3D null && loadVersion.isStaging()) {
+                    addedCtnIds =3D new HashSet();                     =

+                       if (!loadVersion.isWithMarkedForDeletion()) {
+                        deletedInStaging =3D new HashSet();
+                       }
                 }
+                int rank =3D 0;
+                int prevRank =3D 0;                =

                 while (rs.next()) {
                     Integer ctnID =3D new Integer(rs.getInt(1));
-
-                    if (loadVersion !=3D null && loadVersion.isStaging() &=
& !loadVersion.isWithMarkedForDeletion()) {
+                    =

+                    if (loadVersion !=3D null && loadVersion.isStaging()) {
                         long version =3D rs.getLong(2);
-                        if (!deletedInStaging.contains(ctnID) && !addedCtn=
Ids.contains(ctnID) && version > -1) {
+                        rank =3D rs.getInt (3);                        =

+                        if (!addedCtnIds.contains(ctnID) && (rank =3D=3D 0=
 || rank !=3D prevRank) && !loadVersion.isWithMarkedForDeletion() && !delet=
edInStaging.contains(ctnID) && version > -1) {
                             result.add(ctnID);
                             addedCtnIds.add(ctnID);
-                        } else if (!compareMode && version =3D=3D -1) {
+                        } else if (!loadVersion.isWithMarkedForDeletion() =
&& !compareMode && version =3D=3D -1) {
                             deletedInStaging.add(ctnID);
                         }
                     } else {
                         result.add(ctnID);
                     }
+                    prevRank =3D rank;
                 }
                 theList =3D new Vector(result);
                 rs.close();

Modified: branches/JAHIA-4-1-BRANCH/src/java/org/jahia/services/pages/Conte=
ntPage.java
URL: https://svndev.jahia.net/websvn/diff.php?path=3D/branches/JAHIA-4-1-BR=
ANCH/src/java/org/jahia/services/pages/ContentPage.java&rev=3D18025&repname=
=3Djahia
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D
--- branches/JAHIA-4-1-BRANCH/src/java/org/jahia/services/pages/ContentPage=
.java (original)
+++ branches/JAHIA-4-1-BRANCH/src/java/org/jahia/services/pages/ContentPage=
.java Tue Jul 17 14:17:20 2007
@@ -4189,16 +4189,21 @@
 =

                 result =3D mergeLanguageStates (result, fieldsLanguagesSta=
tes);
 =

-//                long beforeContainersState =3D new Date().getTime();
-//
-//                Map containersLanguagesStates =3D ServicesRegistry.getIn=
stance ()
-//                        .getJahiaContainersService ()
-//                        .getContainersLanguagesState (getID ());
-//
-//                long afterContainersState =3D new Date().getTime();
-//                logger.debug("Time to retrieve container state=3D" + Lon=
g.toString(afterContainersState - beforeContainersState) + "ms");
-//
-//                result =3D mergeLanguageStates (result, containersLangua=
gesStates);
+                long beforeContainersState =3D logger.isDebugEnabled() ? S=
ystem
+                                               .currentTimeMillis() : 0;
+
+                Map containersLanguagesStates =3D ServicesRegistry.getInst=
ance ()
+                        .getJahiaContainersService ()
+                        .getContainersLanguagesState (getID ());
+                =

+                if (logger.isDebugEnabled()) {
+                                       long afterContainersState =3D 
System.currentTimeMillis();
+                                       logger.debug("Time to retrieve 
container state=3D"
+                                                       + 
Long.toString(afterContainersState
+                                                                       - 
beforeContainersState) + "ms");
+                               }  =

+
+                result =3D mergeLanguageStates (result, containersLanguage=
sStates);
             } catch (JahiaException je) {
                 logger.debug ("Error while retrieving language workflow st=
ates", je);
             }

_______________________________________________
cvs_list mailing list
[email protected]
http://lists.jahia.org/cgi-bin/mailman/listinfo/cvs_list

Reply via email to