From: <fg...@us...> - 2011-11-06 17:48:17
|
Revision: 3691 http://openutils.svn.sourceforge.net/openutils/?rev=3691&view=rev Author: fgiust Date: 2011-11-06 17:48:11 +0000 (Sun, 06 Nov 2011) Log Message: ----------- MEDIA-266 Avoid usage of ExclusiveWrite and use node-scoped locks when saving resolutions - to be tested carefully Modified Paths: -------------- trunk/openutils-mgnlmedia/src/main/java/net/sourceforge/openutils/mgnlmedia/media/utils/ImageUtils.java Modified: trunk/openutils-mgnlmedia/src/main/java/net/sourceforge/openutils/mgnlmedia/media/utils/ImageUtils.java =================================================================== --- trunk/openutils-mgnlmedia/src/main/java/net/sourceforge/openutils/mgnlmedia/media/utils/ImageUtils.java 2011-11-06 17:21:20 UTC (rev 3690) +++ trunk/openutils-mgnlmedia/src/main/java/net/sourceforge/openutils/mgnlmedia/media/utils/ImageUtils.java 2011-11-06 17:48:11 UTC (rev 3691) @@ -23,7 +23,6 @@ import info.magnolia.cms.core.Content; import info.magnolia.cms.core.HierarchyManager; import info.magnolia.cms.core.NodeData; -import info.magnolia.cms.util.ExclusiveWrite; import info.magnolia.context.Context; import info.magnolia.context.MgnlContext; import info.magnolia.context.MgnlContext.SystemContextOperation; @@ -60,6 +59,7 @@ import javax.imageio.stream.ImageOutputStream; import javax.jcr.PropertyType; import javax.jcr.RepositoryException; +import javax.jcr.lock.Lock; import net.sourceforge.openutils.mgnlmedia.media.configuration.ImageProcessorsManager; import net.sourceforge.openutils.mgnlmedia.media.configuration.MediaConfigurationManager; @@ -481,6 +481,7 @@ { resolutions = saveTo.createContent("resolutions", MediaConfigurationManager.RESOLUTIONS); resolutions.getMetaData().setModificationDate(); + saveTo.save(); } String resolution = name; @@ -492,13 +493,17 @@ String originalRes = resolution; resolution = getResolutionPath(resolution); - synchronized (ExclusiveWrite.getInstance()) + // max wait 5 secs + Lock lock = resolutions.lock(false, true, 5000); + + try { if (resolutions.hasNodeData(resolution)) { NodeData nd = resolutions.getNodeData(resolution); nd.delete(); + resolutions.save(); } // don't remove deprecated method call, needed for magnolia 4.0 compatibility @@ -514,7 +519,6 @@ /** * {@inheritDoc} */ - @Override public void run() { try @@ -558,7 +562,13 @@ nd.setAttribute(FileProperties.PROPERTY_HEIGHT, "" + image.getHeight()); nd.setAttribute(FileProperties.PROPERTY_SIZE, "" + count); + + resolutions.save(); } + finally + { + resolutions.unlock(); + } } @@ -883,7 +893,13 @@ forceProgressive = true; } - ImageUtils.saveResolution(img, node, resolutioNodeName, outputextension, quality, forceProgressive); + ImageUtils.saveResolution( + img, + node, + resolutioNodeName, + outputextension, + quality, + forceProgressive); } catch (RepositoryException e) { This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |