shuber 2004/11/04 16:35:32 CET
Modified files:
core/src/java/org/jahia/engines/pages
PageProperties_Engine.java
core/src/java/org/jahia/views/engines/versioning/pages/actions
PagesVersioningAction.java
Log:
Fix for JAHIA-222 :
- Improved locking system so that we only free the page properties lock when we no
longer use then engine.
Revision Changes Path
1.8 +5 -8
jahia/core/src/java/org/jahia/engines/pages/PageProperties_Engine.java
http://jahia.mine.nu:8080/cgi-bin/cvsweb.cgi/jahia/core/src/java/org/jahia/engines/pages/PageProperties_Engine.java.diff?r1=1.7&r2=1.8&f=h
1.6 +21 -5
jahia/core/src/java/org/jahia/views/engines/versioning/pages/actions/PagesVersioningAction.java
http://jahia.mine.nu:8080/cgi-bin/cvsweb.cgi/jahia/core/src/java/org/jahia/views/engines/versioning/pages/actions/PagesVersioningAction.java.diff?r1=1.5&r2=1.6&f=h
Index: PageProperties_Engine.java
===================================================================
RCS file:
/home/cvs/repository/jahia/core/src/java/org/jahia/engines/pages/PageProperties_Engine.java,v
retrieving revision 1.7
retrieving revision 1.8
diff -u -r1.7 -r1.8
--- PageProperties_Engine.java 4 Nov 2004 14:47:06 -0000 1.7
+++ PageProperties_Engine.java 4 Nov 2004 15:35:31 -0000 1.8
@@ -1,4 +1,4 @@
-// $Id: PageProperties_Engine.java,v 1.7 2004/11/04 14:47:06 shuber Exp $
+// $Id: PageProperties_Engine.java,v 1.8 2004/11/04 15:35:31 shuber Exp $
//
//
// ____.
@@ -248,7 +248,7 @@
// reset engine map to default value
engineMap.remove (ENGINE_OUTPUT_FILE_PARAM);
- releaseAllVersioningLocks(jParams);
+ releaseTreeVersioningLocks(jParams);
// now let's reacquire the page lock for this page, as we
// have cleared it as part of the page subtree.
@@ -356,11 +356,8 @@
if (engineMap.get ("writeAccess") != null
|| engineMap.get ("adminAccess") != null) {
- // as we switch to versioning engine, we release the lock first
- if (jParams.settings ().areLocksActivated ()) {
- lockRegistry.release (lockKey, jParams.getUser (),
- jParams.getSessionID ());
- }
+ // we don't need to free the lock when going to the versioning
+ // engine because we can re-acquire a lock we already have.
Properties params = new Properties ();
params.put ("method", "showOperationChoices");
@@ -933,7 +930,7 @@
return thePage;
}
- private void releaseAllVersioningLocks (ParamBean jParams)
+ private void releaseTreeVersioningLocks (ParamBean jParams)
throws JahiaException {
if (jParams.settings ().areLocksActivated ()) {
ArrayList acquiredPageLocks = (ArrayList)
jParams.getSession().getAttribute(PagesVersioningAction.SESSION_VERSIONING_LOCK_LIST);
Index: PagesVersioningAction.java
===================================================================
RCS file:
/home/cvs/repository/jahia/core/src/java/org/jahia/views/engines/versioning/pages/actions/PagesVersioningAction.java,v
retrieving revision 1.5
retrieving revision 1.6
diff -u -r1.5 -r1.6
--- PagesVersioningAction.java 3 Nov 2004 13:22:27 -0000 1.5
+++ PagesVersioningAction.java 4 Nov 2004 15:35:31 -0000 1.6
@@ -243,7 +243,7 @@
// before we go any further, let's try to acquire all the locks
// on the page sub tree.
ActionMessages messages = new ActionMessages();
- boolean lockingSuccessful =
acquireAllLocks(engineCommonData.getParamBean(), messages);
+ boolean lockingSuccessful =
acquireTreeLocks(engineCommonData.getParamBean(), messages);
if (!lockingSuccessful) {
forward = mapping.findForward("pageTreeLocked");
saveMessages(request, messages);
@@ -591,7 +591,7 @@
String method = request.getParameter(mapping.getParameter());
if ( method.equals("restoreSave") ){
- releaseAllLocks(engineCommonData.getParamBean());
+ releaseTreeLocks(engineCommonData.getParamBean());
request.setAttribute("engines.close.refresh-opener","yes");
request.setAttribute("engines.close.opener-url-params","&reloaded=yes");
forward = mapping.findForward("EnginesCloseAnyPopup");
@@ -730,7 +730,10 @@
engineCommonData = (JahiaEngineCommonData)
request.getAttribute(JahiaEngineCommonData.JAHIA_ENGINE_COMMON_DATA);
- releaseAllLocks(engineCommonData.getParamBean());
+ releaseTreeLocks(engineCommonData.getParamBean());
+
+ // this is required in the case that we never locked the tree
+ releaseActionLock(engineCommonData.getParamBean());
} catch ( Throwable t ){
JahiaErrorDisplay.DisplayException(request, response,
@@ -1777,7 +1780,7 @@
* otherwise.
* @throws JahiaException
*/
- private boolean acquireAllLocks (ParamBean jParams, ActionMessages messages)
+ private boolean acquireTreeLocks (ParamBean jParams, ActionMessages messages)
throws JahiaException {
ArrayList acquiredPageLocks = new ArrayList();
if (jParams.settings ().areLocksActivated ()) {
@@ -1850,7 +1853,7 @@
return true;
}
- private void releaseAllLocks (ParamBean jParams)
+ private void releaseTreeLocks (ParamBean jParams)
throws JahiaException {
if (jParams.settings ().areLocksActivated ()) {
ArrayList acquiredPageLocks = (ArrayList)
jParams.getSession().getAttribute(SESSION_VERSIONING_LOCK_LIST);
@@ -1871,6 +1874,19 @@
lockRegistry.release (lockKey, jParams.getUser (),
jParams.getSessionID ());
htmlCache.invalidatePageEntries(Integer.toString(curPageID));
}
+ jParams.getSession().removeAttribute(SESSION_VERSIONING_LOCK_LIST);
+ }
+ }
+
+ private void releaseActionLock(ParamBean jParams)
+ throws JahiaException {
+ if (jParams.settings ().areLocksActivated ()) {
+ HtmlCache htmlCache = CacheFactory.getHtmlCache();
+ LockService lockRegistry = ServicesRegistry.getInstance
().getLockService ();
+ LockKey lockKey = LockKey.composeLockKey (LockKey.UPDATE_PAGE_TYPE,
+ jParams.getPageID(), jParams.getPageID());
+ lockRegistry.release (lockKey, jParams.getUser (), jParams.getSessionID
());
+ htmlCache.invalidatePageEntries(Integer.toString(jParams.getPageID()));
}
}
// #endif