Author: bpapez
Date: Tue Sep 18 08:14:51 2007
New Revision: 18525

URL: https://svndev.jahia.net/websvn/listing.php?sc=3D1&rev=3D18525&repname=
=3Djahia
Log:
JAHIA-2287 logout with a user causes some exceptions
- when creating the pagepath, consider that not all pages in the hierarchy =
are activated yet (up-port from jahia 4.2)

Modified:
    branches/JAHIA-5-0-SP-BRANCH/core/src/java/org/jahia/services/pages/Jah=
iaPageBaseService.java

Modified: branches/JAHIA-5-0-SP-BRANCH/core/src/java/org/jahia/services/pag=
es/JahiaPageBaseService.java
URL: https://svndev.jahia.net/websvn/diff.php?path=3D/branches/JAHIA-5-0-SP=
-BRANCH/core/src/java/org/jahia/services/pages/JahiaPageBaseService.java&re=
v=3D18525&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-5-0-SP-BRANCH/core/src/java/org/jahia/services/pages/Jah=
iaPageBaseService.java (original)
+++ branches/JAHIA-5-0-SP-BRANCH/core/src/java/org/jahia/services/pages/Jah=
iaPageBaseService.java Tue Sep 18 08:14:51 2007
@@ -1221,31 +1221,40 @@
     public Vector getContentPagePath(int pageID, EntryLoadRequest loadRequ=
est,
                                      String opMode, JahiaUser user)
             throws JahiaException {
-        GroupCacheKey groupCacheKey =3D new GroupCacheKey("PAGE_ID"+pageID=
+ "-"+loadRequest+ "-"+opMode+ "-"+user.getUserKey(), new HashSet());
-        if(mContentPagePathCache.containsKey(groupCacheKey))
+        GroupCacheKey groupCacheKey =3D new GroupCacheKey("PAGE_ID" + page=
ID
+                + "-" + loadRequest + "-" + opMode + "-" + user.getUserKey=
(),
+                new HashSet());
+        if (mContentPagePathCache.containsKey(groupCacheKey))
             return (Vector) mContentPagePathCache.get(groupCacheKey);
         Vector path =3D new Vector();
-        ContentPage contentPage;
-
-        contentPage =3D ContentPage.getPage(pageID);
+        ContentPage contentPage =3D lookupContentPage(pageID, true);
         if (contentPage !=3D null) {
-            path.add(contentPage);
-            groupCacheKey.getGroups().add("PAGE_ID"+contentPage.getID());
-            int parentID =3D contentPage.getParentID(loadRequest);
-            while (parentID > 0) {
-                contentPage =3D ContentPage.getPage(parentID);
-                if (contentPage !=3D null && contentPage.getID() !=3D page=
ID) { // Check to avoid infinite loop when creating cyclic page move
-                    path.insertElementAt(contentPage, 0);
-                    groupCacheKey.getGroups().add("PAGE_ID"+contentPage.ge=
tID());
-                } else {
-                    mContentPagePathCache.put(groupCacheKey,path);
-                    return path;
+            do {
+                path.insertElementAt(contentPage, 0);
+                groupCacheKey.getGroups().add("PAGE_ID" + contentPage.getI=
D());
+                // Coherence check here
+                // if the loadRequest is active, but the page exist only i=
n staging
+                // ( for some reason, it was not actived ), so change the =
loadRequest to
+                // staging ohterwhise calls to getType(), getJahiaID() wil=
l fail !!!!
+                EntryLoadRequest newLoadRequest =3D loadRequest;
+                if (loadRequest !=3D null && loadRequest.isCurrent()
+                        && !contentPage.hasActiveEntries()) {
+                    newLoadRequest =3D new EntryLoadRequest(
+                            EntryLoadRequest.STAGING_WORKFLOW_STATE, 0,
+                            loadRequest.getLocales());
+                    newLoadRequest.setWithDeleted(loadRequest.isWithDelete=
d());
+                    newLoadRequest.setWithMarkedForDeletion(loadRequest
+                            .isWithMarkedForDeletion());
                 }
-                parentID =3D contentPage.getParentID(loadRequest);
-            }
+                int parentId =3D contentPage.getParentID(newLoadRequest);
+                contentPage =3D parentId > 0 ? lookupContentPage(parentId,=
 true)
+                        : null;
+                if (contentPage !=3D null && contentPage.getID() =3D=3D pa=
geID) { // Check to avoid infinite loop when creating cyclic page move
+                    contentPage =3D null;
+                }
+            } while (contentPage !=3D null);
         }
-        contentPage =3D null;
-        mContentPagePathCache.put(groupCacheKey,path);
+        mContentPagePathCache.put(groupCacheKey, path);
         return path;
     }
 =


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

Reply via email to