|
From: <fg...@us...> - 2011-11-06 17:21:27
|
Revision: 3690
http://openutils.svn.sourceforge.net/openutils/?rev=3690&view=rev
Author: fgiust
Date: 2011-11-06 17:21:20 +0000 (Sun, 06 Nov 2011)
Log Message:
-----------
avoid excessive synchronization on activation/delete
Modified Paths:
--------------
trunk/openutils-mgnlmedia/src/main/java/net/sourceforge/openutils/mgnlmedia/media/commands/MediaActivationCommand.java
trunk/openutils-mgnlmedia/src/main/java/net/sourceforge/openutils/mgnlmedia/media/pages/MediaFolderViewPage.java
Modified: trunk/openutils-mgnlmedia/src/main/java/net/sourceforge/openutils/mgnlmedia/media/commands/MediaActivationCommand.java
===================================================================
--- trunk/openutils-mgnlmedia/src/main/java/net/sourceforge/openutils/mgnlmedia/media/commands/MediaActivationCommand.java 2011-11-06 17:16:05 UTC (rev 3689)
+++ trunk/openutils-mgnlmedia/src/main/java/net/sourceforge/openutils/mgnlmedia/media/commands/MediaActivationCommand.java 2011-11-06 17:21:20 UTC (rev 3690)
@@ -24,10 +24,8 @@
import info.magnolia.cms.exchange.ExchangeException;
import info.magnolia.cms.i18n.MessagesManager;
import info.magnolia.cms.util.AlertUtil;
-import info.magnolia.cms.util.ExclusiveWrite;
import info.magnolia.cms.util.Rule;
import info.magnolia.context.Context;
-import info.magnolia.context.MgnlContext;
import info.magnolia.module.admininterface.commands.ActivationCommand;
import java.util.ArrayList;
@@ -63,54 +61,52 @@
@Override
public boolean execute(Context ctx)
{
- synchronized (ExclusiveWrite.getInstance())
+ try
{
- try
+ Content thisState = getNode(ctx);
+ String parentPath = StringUtils.substringBeforeLast(thisState.getHandle(), "/");
+ if (StringUtils.isEmpty(parentPath))
{
- Content thisState = getNode(ctx);
- String parentPath = StringUtils.substringBeforeLast(thisState.getHandle(), "/");
- if (StringUtils.isEmpty(parentPath))
+ parentPath = "/";
+ }
+ // make multiple activations instead of a big bulp
+ if (super.isRecursive())
+ {
+ List versionMap = getVersionMap();
+ if (versionMap == null)
{
- parentPath = "/";
+ activateRecursive(parentPath, thisState, ctx);
}
- // make multiple activations instead of a big bulp
- if (super.isRecursive())
+ else
{
- List versionMap = getVersionMap();
- if (versionMap == null)
+ activateRecursive(ctx, versionMap);
+ }
+ }
+ else
+ {
+ if (StringUtils.isNotEmpty(getVersion()))
+ {
+ try
{
- activateRecursive(parentPath, thisState, ctx);
+ thisState = thisState.getVersionedContent(getVersion());
}
- else
+ catch (RepositoryException re)
{
- activateRecursive(ctx, versionMap);
+ log.error("Failed to get version " + getVersion() + " for " + thisState.getHandle(), re);
}
}
- else
- {
- if (StringUtils.isNotEmpty(getVersion()))
- {
- try
- {
- thisState = thisState.getVersionedContent(getVersion());
- }
- catch (RepositoryException re)
- {
- log.error("Failed to get version " + getVersion() + " for " + thisState.getHandle(), re);
- }
- }
- activateRecursiveOneLevel(parentPath, thisState);
- }
+ activateRecursiveOneLevel(parentPath, thisState);
}
- catch (Exception e)
- {
- log.error("can't activate", e);
- AlertUtil.setException(MessagesManager.get("tree.error.activate"), e, ctx);
- return false;
- }
- log.info("exec successfully.");
- return true;
}
+ catch (Exception e)
+ {
+ log.error("can't activate", e);
+ AlertUtil.setException(MessagesManager.get("tree.error.activate"), e, ctx);
+ return false;
+ }
+ log.info("exec successfully.");
+ return true;
+
}
/**
Modified: trunk/openutils-mgnlmedia/src/main/java/net/sourceforge/openutils/mgnlmedia/media/pages/MediaFolderViewPage.java
===================================================================
--- trunk/openutils-mgnlmedia/src/main/java/net/sourceforge/openutils/mgnlmedia/media/pages/MediaFolderViewPage.java 2011-11-06 17:16:05 UTC (rev 3689)
+++ trunk/openutils-mgnlmedia/src/main/java/net/sourceforge/openutils/mgnlmedia/media/pages/MediaFolderViewPage.java 2011-11-06 17:21:20 UTC (rev 3690)
@@ -29,7 +29,6 @@
import info.magnolia.cms.security.Permission;
import info.magnolia.cms.util.AlertUtil;
import info.magnolia.cms.util.ContentUtil;
-import info.magnolia.cms.util.ExclusiveWrite;
import info.magnolia.commands.CommandsManager;
import info.magnolia.context.Context;
import info.magnolia.context.MgnlContext;
@@ -295,11 +294,8 @@
try
{
- synchronized (ExclusiveWrite.getInstance())
- {
- hm.delete(this.node);
- hm.save();
- }
+ hm.delete(this.node);
+ hm.save();
}
catch (RepositoryException ex)
{
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|