Author: xlawrence
Date: Fri Jun 29 11:02:57 2007
New Revision: 17828

URL: https://svndev.jahia.net/websvn/listing.php?sc=3D1&rev=3D17828&repname=
=3Djahia
Log:
Correctly release the locks when exiting the versionning sub-engine

Modified:
    trunk/core/src/java/org/jahia/views/engines/versioning/actions/ContentV=
ersioningAction.java

Modified: trunk/core/src/java/org/jahia/views/engines/versioning/actions/Co=
ntentVersioningAction.java
URL: https://svndev.jahia.net/websvn/diff.php?path=3D/trunk/core/src/java/o=
rg/jahia/views/engines/versioning/actions/ContentVersioningAction.java&rev=
=3D17828&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
--- trunk/core/src/java/org/jahia/views/engines/versioning/actions/ContentV=
ersioningAction.java (original)
+++ trunk/core/src/java/org/jahia/views/engines/versioning/actions/ContentV=
ersioningAction.java Fri Jun 29 11:02:57 2007
@@ -114,11 +114,12 @@
             request.setAttribute(JahiaEngineButtonsHelper.JAHIA_ENGINE_BUT=
TONS_HELPER,
                     jahiaEngineButtonsHelper);
 =

-            ContentObject contentObject =3D null;
+            final ContentObject contentObject;
 =

             if (engineViewHelper =3D=3D null) {
                 // Prepage a new engine view helper
                 String objectKey;
+                EntryLoadRequest loadRequest =3D EntryLoadRequest.VERSIONE=
D;
                 objectKey =3D request.getParameter("objectKey");
                 contentObject =3D ContentObject.getContentObjectInstance(O=
bjectKey.getInstance(objectKey));
                 CalendarHandler cal =3D this.getCalHandler("restoreDateCal=
endar",0,
@@ -1747,9 +1748,13 @@
      * @return boolean true if all the sub pages could be locked, false
      *         otherwise.
      * @throws org.jahia.exceptions.JahiaException
+     *
      */
-    protected boolean acquireTreeLocks(ProcessingContext jParams, ActionMe=
ssages actionMessages)
+    protected boolean acquireTreeLocks(ProcessingContext jParams, ActionMe=
ssages messages)
             throws JahiaException {
+        //@todo: have locks optimized or remove them.
+        return true;
+        /*
         ArrayList acquiredPageLocks =3D new ArrayList();
         if (jParams.settings().areLocksActivated()) {
             JahiaUser user =3D jParams.getUser();
@@ -1763,7 +1768,7 @@
             int pageInfosFlag =3D ContentPage.ACTIVE_PAGE_INFOS | ContentP=
age.STAGING_PAGE_INFOS;
             siteMapService.invokeTreeSiteMapViewHelperMethod(jParams.getUs=
er(),
                     contentPage, jParams.getSessionID(), pageInfosFlag,
-                    null, "expandall|0", true, null, null);
+                    null, "expandall|0");
 =

             // here below we set the page level to maximum because we want
             // to free all the sub pages locks.
@@ -1787,7 +1792,7 @@
                     if (!lockRegistry.isAcquireable(lockKey, user, user.ge=
tUserKey())) {
                         // acquiring of all locks was not successfull, we
                         // exit immediately.
-                        actionMessages.add(ActionMessages.GLOBAL_MESSAGE,
+                        messages.add(ActionMessages.GLOBAL_MESSAGE,
                                 new ActionMessage("message.org.jahia.views=
.engines.versioning.pages.cannotLockPage", new Integer(siteMapContentPage.g=
etID())));
                         return false;
                     }
@@ -1819,10 +1824,29 @@
         }
         jParams.getSessionState().setAttribute(ContentVersioningAction.SES=
SION_VERSIONING_LOCK_LIST, acquiredPageLocks);
         return true;
+        */
     }
 =

     protected void releaseTreeLocks(ProcessingContext jParams)
             throws JahiaException {
+        //@todo: have locks optimized or remove it
+        if (jParams.settings().areLocksActivated()) {
+            final Set locks =3D (Set) jParams.getSessionState().getAttribu=
te("VersionningLocks");
+            if (locks !=3D null) {
+                final LockService lockRegistry =3D ServicesRegistry.getIns=
tance().getLockService();
+                final JahiaUser user =3D jParams.getUser();
+                final HtmlCache htmlCache =3D ServicesRegistry.getInstance=
().getCacheService().getHtmlCacheInstance();
+                synchronized (locks) {
+                    final Iterator iterator =3D locks.iterator();
+                    while (iterator.hasNext()) {
+                        final LockKey lockKey =3D (LockKey) iterator.next(=
);
+                        lockRegistry.release(lockKey, user, user.getUserKe=
y());
+                        htmlCache.invalidatePageEntries(Integer.toString(l=
ockKey.getPageID()));
+                    }
+                }
+            }
+        }
+        /*
         if (jParams.settings().areLocksActivated()) {
             ArrayList acquiredPageLocks =3D (ArrayList) jParams.getSession=
State().getAttribute(ContentVersioningAction.SESSION_VERSIONING_LOCK_LIST);
             if (acquiredPageLocks =3D=3D null) {
@@ -1842,7 +1866,7 @@
                 htmlCache.invalidatePageEntries(Integer.toString(curPageID=
));
             }
             jParams.getSessionState().removeAttribute(ContentVersioningAct=
ion.SESSION_VERSIONING_LOCK_LIST);
-        }
+        }*/
     }
 =

     protected void releaseActionLock(ProcessingContext jParams)

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

Reply via email to