From: <fg...@us...> - 2008-12-04 11:42:10
|
Revision: 940 http://openutils.svn.sourceforge.net/openutils/?rev=940&view=rev Author: fgiust Date: 2008-12-04 11:35:26 +0000 (Thu, 04 Dec 2008) Log Message: ----------- basic docs Added Paths: ----------- trunk/openutils-mgnlmedia/src/site/ trunk/openutils-mgnlmedia/src/site/apt/ trunk/openutils-mgnlmedia/src/site/apt/index.apt trunk/openutils-mgnlmedia/src/site/changes/ trunk/openutils-mgnlmedia/src/site/changes/changes.xml trunk/openutils-mgnlmedia/src/site/site.xml Added: trunk/openutils-mgnlmedia/src/site/apt/index.apt =================================================================== --- trunk/openutils-mgnlmedia/src/site/apt/index.apt (rev 0) +++ trunk/openutils-mgnlmedia/src/site/apt/index.apt 2008-12-04 11:35:26 UTC (rev 940) @@ -0,0 +1,28 @@ + -------------------------- + openutils-mgnlmedia + -------------------------- + Fabrizio Giustina + -------------------------- + +About openutils-mgnlmedia + + openutils-mgnlmedia is a custom {{{http://www.magnolia.info}magnolia}} module for the management of multimedia assets + like images and videos. + + <<This module requires magnolia 3.6.x, and will not work on any earlier version!>> + + + +Configuration + + First of all drop the openutils-mgnlstripes jar and the stripes jar into WEB-INF/lib, or (better) if you are using maven + just declare the following dependency: + ++----------------------------------------------+ + <dependency> + <groupId>net.sourceforge.openutils</groupId> + <artifactId>openutils-mgnlmedia</artifactId> + <version>0.1</version> + </dependency> ++----------------------------------------------+ + Property changes on: trunk/openutils-mgnlmedia/src/site/apt/index.apt ___________________________________________________________________ Added: svn:mime-type + text/plain Added: svn:keywords + Author Date Id Revision Added: svn:eol-style + native Added: trunk/openutils-mgnlmedia/src/site/changes/changes.xml =================================================================== --- trunk/openutils-mgnlmedia/src/site/changes/changes.xml (rev 0) +++ trunk/openutils-mgnlmedia/src/site/changes/changes.xml 2008-12-04 11:35:26 UTC (rev 940) @@ -0,0 +1,15 @@ +<?xml version="1.0"?> + <!-- + "type" attribute can be: add, remove, update or fix. +--> +<document> + <properties> + <title>Changes</title> + <author email="fgiust(at)users.sourceforge.net">Fabrizio Giustina</author> + </properties> + <body> + <release version="0.1" date="2008-12-04" description=""> + <action type="add" dev="fgiust">first alpha release</action> + </release> + </body> +</document> \ No newline at end of file Property changes on: trunk/openutils-mgnlmedia/src/site/changes/changes.xml ___________________________________________________________________ Added: svn:mime-type + text/plain Added: svn:keywords + Author Date Id Revision Added: svn:eol-style + native Added: trunk/openutils-mgnlmedia/src/site/site.xml =================================================================== --- trunk/openutils-mgnlmedia/src/site/site.xml (rev 0) +++ trunk/openutils-mgnlmedia/src/site/site.xml 2008-12-04 11:35:26 UTC (rev 940) @@ -0,0 +1,35 @@ +<?xml version="1.0" encoding="UTF-8"?> +<project name="Openutils mgnlmedia"> + <publishDate position="navigation-bottom" format="yyyy-MM-dd" /> + <version position="navigation-bottom" /> + <bannerRight> + <name>Openutils</name> + <src>http://openutils.sourceforge.net/images/openutils-logo.png + </src> + <href>http://openutils.sourceforge.net</href> + </bannerRight> + <bannerLeft> + <name>Sourceforge</name> + <src>http://sourceforge.net/sflogo.php?group_id=150467&amp;type=2</src> + <href>http://www.sourceforge.net/projects/openutils</href> + </bannerLeft> + <body> + <head> + <link rel="icon" href="images/favicon.ico" /> + </head> + <breadcrumbs> + <item name="openutils" href="http://openutils.sourceforge.net/" /> + <item name="openutils-mgnlstripes" href="http://openutils.sourceforge.net/openutils-mgnlmedia" /> + </breadcrumbs> + <menu name="openutils mgnlmedia"> + <item name="About" href="index.html"></item> + </menu> + <menu ref="modules" inherit="bottom" /> + <menu ref="reports" inherit="bottom" /> + </body> + <skin> + <groupId>net.sourceforge.openutils</groupId> + <artifactId>openutils-maven-skin</artifactId> + <version>1.1</version> + </skin> +</project> Property changes on: trunk/openutils-mgnlmedia/src/site/site.xml ___________________________________________________________________ Added: svn:mime-type + text/plain Added: svn:keywords + Author Date Id Revision Added: svn:eol-style + native This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <fg...@us...> - 2009-04-23 08:03:33
|
Revision: 1160 http://openutils.svn.sourceforge.net/openutils/?rev=1160&view=rev Author: fgiust Date: 2009-04-23 08:03:25 +0000 (Thu, 23 Apr 2009) Log Message: ----------- minor improvements - see changelog Modified Paths: -------------- trunk/openutils-mgnlmedia/src/main/java/net/sourceforge/openutils/mgnlmedia/media/utils/ImageUtils.java trunk/openutils-mgnlmedia/src/site/changes/changes.xml trunk/openutils-mgnlmedia/src/test/java/net/sourceforge/openutils/mgnlmedia/media/utils/ImageUtilsTest.java Added Paths: ----------- trunk/openutils-mgnlmedia/src/test/resources/images/openmind.png 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 2009-04-18 08:59:21 UTC (rev 1159) +++ trunk/openutils-mgnlmedia/src/main/java/net/sourceforge/openutils/mgnlmedia/media/utils/ImageUtils.java 2009-04-23 08:03:25 UTC (rev 1160) @@ -130,31 +130,57 @@ */ public static BufferedImage resizeImage(BufferedImage original, int x, int y) { + return resizeImage(original, x, y, x, y, null); + } + + /** + * Resize an image to x,y + * @param original original image + * @param x new width + * @param y new height + * @param canvasX canvas width + * @param canvasY canvas height + * @return resized image + */ + public static BufferedImage resizeImage(BufferedImage original, int x, int y, int canvasX, int canvasY, + Color background) + { BufferedImage resizedImage; try { - resizedImage = new BufferedImage(x, y, getType(original.getColorModel())); + resizedImage = new BufferedImage(canvasX, canvasY, getType(original.getColorModel())); } catch (NegativeArraySizeException e) { throw new RuntimeException("NegativeArraySizeException caught when resizing image to [" - + x + + canvasX + ", " - + y + + canvasY + "]"); } Graphics2D graphics2D = resizedImage.createGraphics(); + + // background color + if (background != null) + { + graphics2D.setBackground(background); + } graphics2D.setRenderingHint(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_ON); graphics2D.setRenderingHint(RenderingHints.KEY_RENDERING, RenderingHints.VALUE_RENDER_QUALITY); + if (canvasX > x || canvasY > y) + { + graphics2D.clearRect(0, 0, canvasX, canvasY); + } if (x > original.getWidth()) { graphics2D.setRenderingHint(RenderingHints.KEY_INTERPOLATION, RenderingHints.VALUE_INTERPOLATION_BICUBIC); - graphics2D.drawImage(original, 0, 0, x, y, null); + graphics2D.drawImage(original, (canvasX - x) / 2, (canvasY - y) / 2, x, y, background, null); } else { - graphics2D.drawImage(original.getScaledInstance(x, y, Image.SCALE_SMOOTH), 0, 0, x, y, null); + Image scaledInstance = original.getScaledInstance(x, y, Image.SCALE_SMOOTH); + graphics2D.drawImage(scaledInstance, (canvasX - x) / 2, (canvasY - y) / 2, x, y, background, null); } return resizedImage; @@ -198,16 +224,21 @@ */ public static BufferedImage fitIn(BufferedImage original, int x, int y) { - return resizeInOut(original, x, y, false); + return resizeInOut(original, x, y, false, null); } public static BufferedImage resizeNoCrop(BufferedImage original, int x, int y) { - return resizeInOut(original, x, y, true); + return resizeInOut(original, x, y, true, null); } - private static BufferedImage resizeInOut(BufferedImage original, int x, int y, boolean external) + public static BufferedImage resizeNoCrop(BufferedImage original, int x, int y, Color background) { + return resizeInOut(original, x, y, true, background); + } + + private static BufferedImage resizeInOut(BufferedImage original, int x, int y, boolean external, Color background) + { if (original == null) { throw new IllegalArgumentException("input image is null"); @@ -223,11 +254,11 @@ double xRatio = (double) x / oX; double yRatio = (double) y / oY; - double ratio = (external ? Math.min(xRatio, yRatio) : Math.min(xRatio, yRatio)); + double ratio = Math.min(xRatio, yRatio); int newX = (int) Math.round(oX * ratio); int newY = (int) Math.round(oY * ratio); - return resizeImage(original, newX, newY); + return resizeImage(original, newX, newY, external ? x : newX, external ? y : newY, background); } /** @@ -596,12 +627,29 @@ { throw new IllegalArgumentException("input image is null"); } + if (resolution == null || resolution.length() < 1) + { + throw new IllegalArgumentException("Invalid resolution: " + resolution); + } BufferedImage img = null; + String params = null; - if (resolution.startsWith("<")) + resolution = StringUtils.lowerCase(resolution); + + if (StringUtils.contains(resolution, ";")) { - String resx = StringUtils.substringBefore(StringUtils.substringAfter(resolution, "<"), "x"); + params = StringUtils.substringAfter(resolution, ";"); + resolution = StringUtils.substringBefore(resolution, ";"); + } + + String controlChar = StringUtils.substring(resolution, 0, 1); + + if ("<".equals(controlChar) || "l".equals(controlChar)) + { + String resx = resolution.startsWith("<") ? StringUtils.substringBefore(StringUtils.substringAfter( + resolution, + "<"), "x") : StringUtils.substringBefore(StringUtils.substringAfter(resolution, "l"), "x"); String resy = StringUtils.substringAfter(resolution, "x"); img = fitIn(original, NumberUtils.toInt(resx), NumberUtils.toInt(resy)); @@ -611,7 +659,22 @@ String resx = StringUtils.substringBefore(StringUtils.substringAfter(resolution, "o"), "x"); String resy = StringUtils.substringAfter(resolution, "x"); - img = resizeNoCrop(original, NumberUtils.toInt(resx), NumberUtils.toInt(resy)); + Color background = null; + + if (StringUtils.contains(params, "background=")) + { + String colorHex = "0x" + StringUtils.trim(StringUtils.substringAfter(params, "background=")); + try + { + background = Color.decode(colorHex); + } + catch (NumberFormatException e) + { + log.error("Invalid color code: " + colorHex, e); + } + } + + img = resizeNoCrop(original, NumberUtils.toInt(resx), NumberUtils.toInt(resy), background); } else { Modified: trunk/openutils-mgnlmedia/src/site/changes/changes.xml =================================================================== --- trunk/openutils-mgnlmedia/src/site/changes/changes.xml 2009-04-18 08:59:21 UTC (rev 1159) +++ trunk/openutils-mgnlmedia/src/site/changes/changes.xml 2009-04-23 08:03:25 UTC (rev 1160) @@ -8,6 +8,11 @@ <author email="fgiust(at)users.sourceforge.net">Fabrizio Giustina</author> </properties> <body> + <release version="4.0-b4" date="2009-04-23" description=""> + <action type="add" dev="fgiust">Support for resize without crop to a fixed size with borders. Background color can + be specified with the syntax: "o100x100;background=FF0096"</action> + <action type="add" dev="fgiust">Alternative prefix for "fit in" resize. In previous versions you had to use < (not very handy in html), now you can use "L" (lower, case insensitive), e.g. "L100x100"</action> + </release> <release version="4.0-b3" date="2009-04-16" description=""> <action type="update" dev="fgiust">Stable release for Magnolia 4.x</action> </release> Modified: trunk/openutils-mgnlmedia/src/test/java/net/sourceforge/openutils/mgnlmedia/media/utils/ImageUtilsTest.java =================================================================== --- trunk/openutils-mgnlmedia/src/test/java/net/sourceforge/openutils/mgnlmedia/media/utils/ImageUtilsTest.java 2009-04-18 08:59:21 UTC (rev 1159) +++ trunk/openutils-mgnlmedia/src/test/java/net/sourceforge/openutils/mgnlmedia/media/utils/ImageUtilsTest.java 2009-04-23 08:03:25 UTC (rev 1160) @@ -45,6 +45,29 @@ } @Test + public void testBorders() throws Exception + { + + NodeData cmyk = new FileNodeData("/images/openmind.png"); + BufferedImage bufferedImage = ImageUtils.createBufferedImage(cmyk); + Assert.assertNotNull(bufferedImage); + + bufferedImage = ImageUtils.getImageForResolution(bufferedImage, "O300x300;background=FF0096"); + + InputStream is = ImageUtils.getStream(bufferedImage, "png"); + + File tempFile = File.createTempFile("image", ".png"); + OutputStream os = new BufferedOutputStream(new FileOutputStream(tempFile)); + IOUtils.copy(is, os); + + IOUtils.closeQuietly(is); + IOUtils.closeQuietly(os); + + tempFile.delete(); + + } + + @Test public void testBadImageTxt() throws Exception { Added: trunk/openutils-mgnlmedia/src/test/resources/images/openmind.png =================================================================== (Binary files differ) Property changes on: trunk/openutils-mgnlmedia/src/test/resources/images/openmind.png ___________________________________________________________________ Added: svn:mime-type + image/png This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <fg...@us...> - 2009-04-23 17:13:43
|
Revision: 1166 http://openutils.svn.sourceforge.net/openutils/?rev=1166&view=rev Author: fgiust Date: 2009-04-23 17:13:28 +0000 (Thu, 23 Apr 2009) Log Message: ----------- handle non-youtube external urls Modified Paths: -------------- trunk/openutils-mgnlmedia/src/main/java/net/sourceforge/openutils/mgnlmedia/media/types/impl/YouTubeVideoTypeHandler.java trunk/openutils-mgnlmedia/src/site/changes/changes.xml Modified: trunk/openutils-mgnlmedia/src/main/java/net/sourceforge/openutils/mgnlmedia/media/types/impl/YouTubeVideoTypeHandler.java =================================================================== --- trunk/openutils-mgnlmedia/src/main/java/net/sourceforge/openutils/mgnlmedia/media/types/impl/YouTubeVideoTypeHandler.java 2009-04-23 08:12:57 UTC (rev 1165) +++ trunk/openutils-mgnlmedia/src/main/java/net/sourceforge/openutils/mgnlmedia/media/types/impl/YouTubeVideoTypeHandler.java 2009-04-23 17:13:28 UTC (rev 1166) @@ -145,16 +145,25 @@ String videoUrl = form.getParameter("videoUrl"); String id = UUID.randomUUID().toString(); URL url; + try { url = new URL(videoUrl); - for (String att : StringUtils.split(url.getQuery(), "&")) + String query = url.getQuery(); + if (query != null) { - if (att.startsWith("v=")) + for (String att : StringUtils.split(url.getQuery(), "&")) { - id = StringUtils.substringAfter(att, "v="); + if (att.startsWith("v=")) + { + id = StringUtils.substringAfter(att, "v="); + } } } + else + { + id = StringUtils.substringAfterLast(videoUrl, "/"); + } } catch (MalformedURLException e) { Modified: trunk/openutils-mgnlmedia/src/site/changes/changes.xml =================================================================== --- trunk/openutils-mgnlmedia/src/site/changes/changes.xml 2009-04-23 08:12:57 UTC (rev 1165) +++ trunk/openutils-mgnlmedia/src/site/changes/changes.xml 2009-04-23 17:13:28 UTC (rev 1166) @@ -8,6 +8,10 @@ <author email="fgiust(at)users.sourceforge.net">Fabrizio Giustina</author> </properties> <body> + <release version="4.0-b4" date="in svn" description=""> + <action type="update" dev="fgiust">YouTubeVideoTypeHandler modified in order to work with generic external urls (not + only youtube)</action> + </release> <release version="4.0-b3" date="2009-04-23" description=""> <action type="update" dev="fgiust">Update openutils-mgnltasks dependency to 4.0</action> <action type="add" dev="fgiust">Support for resize without crop to a fixed size with borders. Background color can This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <fg...@us...> - 2009-04-29 15:17:15
|
Revision: 1168 http://openutils.svn.sourceforge.net/openutils/?rev=1168&view=rev Author: fgiust Date: 2009-04-29 15:17:11 +0000 (Wed, 29 Apr 2009) Log Message: ----------- new MediaLoadUtils Modified Paths: -------------- trunk/openutils-mgnlmedia/src/main/java/net/sourceforge/openutils/mgnlmedia/media/pages/MediaLoadZipFilePage.java trunk/openutils-mgnlmedia/src/site/changes/changes.xml Added Paths: ----------- trunk/openutils-mgnlmedia/src/main/java/net/sourceforge/openutils/mgnlmedia/media/utils/MediaLoadUtils.java Modified: trunk/openutils-mgnlmedia/src/main/java/net/sourceforge/openutils/mgnlmedia/media/pages/MediaLoadZipFilePage.java =================================================================== --- trunk/openutils-mgnlmedia/src/main/java/net/sourceforge/openutils/mgnlmedia/media/pages/MediaLoadZipFilePage.java 2009-04-29 14:51:15 UTC (rev 1167) +++ trunk/openutils-mgnlmedia/src/main/java/net/sourceforge/openutils/mgnlmedia/media/pages/MediaLoadZipFilePage.java 2009-04-29 15:17:11 UTC (rev 1168) @@ -18,34 +18,24 @@ package net.sourceforge.openutils.mgnlmedia.media.pages; import info.magnolia.cms.beans.runtime.Document; -import info.magnolia.cms.core.Content; import info.magnolia.cms.core.HierarchyManager; -import info.magnolia.cms.core.ItemType; -import info.magnolia.cms.core.NodeData; -import info.magnolia.cms.core.Path; -import info.magnolia.cms.i18n.Messages; import info.magnolia.cms.security.AccessDeniedException; -import info.magnolia.cms.util.NodeDataUtil; import info.magnolia.context.MgnlContext; -import info.magnolia.module.admininterface.TemplatedMVCHandler; import java.io.File; -import java.io.FileInputStream; import java.io.FileOutputStream; import java.io.IOException; +import java.io.InputStream; import java.util.Enumeration; import java.util.zip.ZipEntry; import java.util.zip.ZipFile; -import java.util.zip.ZipInputStream; import javax.jcr.RepositoryException; import javax.servlet.http.HttpServletRequest; import javax.servlet.http.HttpServletResponse; -import net.sourceforge.openutils.mgnlmedia.media.configuration.MediaConfigurationManager; -import net.sourceforge.openutils.mgnlmedia.media.configuration.MediaTypeConfiguration; import net.sourceforge.openutils.mgnlmedia.media.lifecycle.MediaModuleLifecycle; -import net.sourceforge.openutils.mgnlmedia.media.types.MediaTypeHandler; +import net.sourceforge.openutils.mgnlmedia.media.utils.MediaLoadUtils; import org.apache.commons.io.IOUtils; import org.apache.commons.lang.StringUtils; @@ -73,13 +63,18 @@ public String loadZip() { + + InputStream zipStream = null; try { HierarchyManager mgr = MgnlContext.getSystemContext().getHierarchyManager(MediaModuleLifecycle.REPO); File temp = File.createTempFile("zipmedia", ".zip"); FileOutputStream fos = new FileOutputStream(temp); - IOUtils.copy(zipFile.getStream(), fos); - fos.close(); + + zipStream = zipFile.getStream(); + IOUtils.copy(zipStream, fos); + + IOUtils.closeQuietly(fos); ZipFile zip = new ZipFile(temp); Enumeration< ? extends ZipEntry> entries = zip.entries(); while (entries.hasMoreElements()) @@ -93,48 +88,16 @@ path = "/" + path; } - if (entry.isDirectory()) + if (!entry.isDirectory()) { - getOrCreateFullPath(mgr, path); - } - else - { + InputStream inputStream = zip.getInputStream(entry); + String parent = StringUtils.substringBeforeLast(path, "/"); String filename = StringUtils.substringAfterLast(path, "/"); - if (StringUtils.isEmpty(parent)) - { - parent = "/"; - } - String extension = StringUtils.substringAfterLast(filename, "."); - String cleanFilename = StringUtils.substringBeforeLast(filename, "."); - MediaTypeConfiguration mtc = MediaConfigurationManager.getMediaHandlerFromExtension(extension); - if (mtc != null) - { - Content parentNode = mgr.getContent(parent); + MediaLoadUtils.loadEntry(inputStream, StringUtils.defaultIfEmpty(parent, "/"), filename, false); - Content media = mgr.createContent( - parent, - Path.getUniqueLabel(parentNode, cleanFilename), - MediaConfigurationManager.MEDIA.getSystemName()); - - NodeData nd = NodeDataUtil.getOrCreate(media, "type"); - nd.setValue(mtc.getName()); - - mgr.save(); - - File f = File.createTempFile("entry", extension); - FileOutputStream fTemp = new FileOutputStream(f); - - IOUtils.copy(zip.getInputStream(entry), fTemp); - - fTemp.close(); - - mtc.getHandler().saveFromZipFile(media, f, cleanFilename, extension); - - mgr.save(); - } } } } @@ -150,6 +113,10 @@ { } + finally + { + IOUtils.closeQuietly(zipStream); + } return this.show(); } @@ -172,27 +139,4 @@ this.zipFile = zipFile; } - private Content getOrCreateFullPath(HierarchyManager mgr, String path) throws RepositoryException - { - try - { - return mgr.getContent(path); - } - catch (RepositoryException ex) - { - String parent = StringUtils.substringBeforeLast(path, "/"); - String label = StringUtils.substringAfterLast(path, "/"); - if (!StringUtils.isEmpty(parent)) - { - getOrCreateFullPath(mgr, parent); - } - else - { - parent = "/"; - } - - return mgr.createContent(parent, label, ItemType.CONTENT.getSystemName()); - } - } - } Added: trunk/openutils-mgnlmedia/src/main/java/net/sourceforge/openutils/mgnlmedia/media/utils/MediaLoadUtils.java =================================================================== --- trunk/openutils-mgnlmedia/src/main/java/net/sourceforge/openutils/mgnlmedia/media/utils/MediaLoadUtils.java (rev 0) +++ trunk/openutils-mgnlmedia/src/main/java/net/sourceforge/openutils/mgnlmedia/media/utils/MediaLoadUtils.java 2009-04-29 15:17:11 UTC (rev 1168) @@ -0,0 +1,142 @@ +/** + * Copyright Openmind http://www.openmindonline.it + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see <http://www.gnu.org/licenses/>. + * + */ +package net.sourceforge.openutils.mgnlmedia.media.utils; + +import info.magnolia.cms.core.Content; +import info.magnolia.cms.core.HierarchyManager; +import info.magnolia.cms.core.NodeData; +import info.magnolia.cms.core.Path; +import info.magnolia.cms.util.ContentUtil; +import info.magnolia.cms.util.NodeDataUtil; +import info.magnolia.context.MgnlContext; + +import java.io.File; +import java.io.FileOutputStream; +import java.io.IOException; +import java.io.InputStream; +import java.util.Calendar; + +import javax.jcr.RepositoryException; + +import net.sourceforge.openutils.mgnlmedia.media.configuration.MediaConfigurationManager; +import net.sourceforge.openutils.mgnlmedia.media.configuration.MediaTypeConfiguration; +import net.sourceforge.openutils.mgnlmedia.media.lifecycle.MediaModuleLifecycle; + +import org.apache.commons.io.IOUtils; +import org.apache.commons.lang.StringUtils; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + + +/** + * @author fgiust + * @version $Id$ + */ +public class MediaLoadUtils +{ + + /** + * Logger. + */ + private static Logger log = LoggerFactory.getLogger(MediaLoadUtils.class); + + public static Content loadEntry(InputStream inputStream, String parent, String filename, boolean overwrite) + throws RepositoryException, IOException + { + + log.debug("loading image {} {}", parent, filename); + + HierarchyManager mgr = MgnlContext.getSystemContext().getHierarchyManager(MediaModuleLifecycle.REPO); + + String extension = StringUtils.substringAfterLast(filename, "."); + String cleanFilename = StringUtils.substringBeforeLast(filename, "."); + MediaTypeConfiguration mtc = MediaConfigurationManager.getMediaHandlerFromExtension(extension); + + if (mtc != null) + { + Content parentNode = getOrCreateFullPath(mgr, parent); + + if (overwrite) + { + Content existing = parentNode.getChildByName(cleanFilename); + if (existing != null) + { + existing.delete(); + mgr.save(); + } + } + + Content media = mgr.createContent( + parent, + Path.getUniqueLabel(parentNode, cleanFilename), + MediaConfigurationManager.MEDIA.getSystemName()); + + NodeData nd = NodeDataUtil.getOrCreate(media, "type"); + nd.setValue(mtc.getName()); + + nd = NodeDataUtil.getOrCreate(media, "creator"); + if (StringUtils.isEmpty(nd.getString())) + { + nd.setValue(MgnlContext.getUser().getName()); + } + + nd = NodeDataUtil.getOrCreate(media, "creationDate"); + if (nd.getDate() == null) + { + nd.setValue(Calendar.getInstance()); + } + nd.setValue(MgnlContext.getUser().getName()); + + nd = NodeDataUtil.getOrCreate(media, "modificationDate"); + nd.setValue(Calendar.getInstance()); + + mgr.save(); + + File f = File.createTempFile("entry", extension); + FileOutputStream fTemp = new FileOutputStream(f); + + IOUtils.copy(inputStream, fTemp); + + IOUtils.closeQuietly(fTemp); + + mtc.getHandler().saveFromZipFile(media, f, cleanFilename, extension); + + mgr.save(); + return media; + } + return null; + } + + private static Content getOrCreateFullPath(HierarchyManager mgr, String path) throws RepositoryException + { + String[] contentNodeNames = path.split("/"); + Content currContent = mgr.getRoot(); + for (String contentNodeName : contentNodeNames) + { + if (StringUtils.isNotEmpty(contentNodeName)) + { + currContent = ContentUtil.getOrCreateContent( + currContent, + contentNodeName, + MediaConfigurationManager.FOLDER); + } + } + return currContent; + + } +} Property changes on: trunk/openutils-mgnlmedia/src/main/java/net/sourceforge/openutils/mgnlmedia/media/utils/MediaLoadUtils.java ___________________________________________________________________ Added: svn:mime-type + text/plain Added: svn:keywords + Author Date Id Revision Added: svn:eol-style + native Modified: trunk/openutils-mgnlmedia/src/site/changes/changes.xml =================================================================== --- trunk/openutils-mgnlmedia/src/site/changes/changes.xml 2009-04-29 14:51:15 UTC (rev 1167) +++ trunk/openutils-mgnlmedia/src/site/changes/changes.xml 2009-04-29 15:17:11 UTC (rev 1168) @@ -11,6 +11,8 @@ <release version="4.0-b4" date="in svn" description=""> <action type="update" dev="fgiust">YouTubeVideoTypeHandler modified in order to work with generic external urls (not only youtube)</action> + <action type="update" dev="fgiust">new utility class net.sourceforge.openutils.mgnlmedia.media.utils.MediaLoadUtils + </action> </release> <release version="4.0-b3" date="2009-04-23" description=""> <action type="update" dev="fgiust">Update openutils-mgnltasks dependency to 4.0</action> This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <fg...@us...> - 2009-04-29 20:40:02
|
Revision: 1169 http://openutils.svn.sourceforge.net/openutils/?rev=1169&view=rev Author: fgiust Date: 2009-04-29 20:39:50 +0000 (Wed, 29 Apr 2009) Log Message: ----------- basic support for autoactivate Modified Paths: -------------- trunk/openutils-mgnlmedia/src/main/java/net/sourceforge/openutils/mgnlmedia/media/configuration/MediaConfigurationManager.java trunk/openutils-mgnlmedia/src/main/java/net/sourceforge/openutils/mgnlmedia/media/dialog/DialogSelectMedia.java trunk/openutils-mgnlmedia/src/main/java/net/sourceforge/openutils/mgnlmedia/media/dialog/LayerDialogMVC.java trunk/openutils-mgnlmedia/src/main/java/net/sourceforge/openutils/mgnlmedia/media/pages/MediaBrowserPage.java 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/MediaLoadZipFilePage.java trunk/openutils-mgnlmedia/src/main/java/net/sourceforge/openutils/mgnlmedia/media/pages/MediaSearchPage.java trunk/openutils-mgnlmedia/src/main/java/net/sourceforge/openutils/mgnlmedia/media/save/MediaCustomSaveHandler.java trunk/openutils-mgnlmedia/src/main/java/net/sourceforge/openutils/mgnlmedia/media/setup/RemoveResolutionsNodeTask.java trunk/openutils-mgnlmedia/src/main/java/net/sourceforge/openutils/mgnlmedia/media/setup/RenameThumbToImageTask.java trunk/openutils-mgnlmedia/src/main/java/net/sourceforge/openutils/mgnlmedia/media/tags/el/MediaEl.java trunk/openutils-mgnlmedia/src/main/java/net/sourceforge/openutils/mgnlmedia/media/tree/MediaModuleTreeConfiguration.java trunk/openutils-mgnlmedia/src/main/java/net/sourceforge/openutils/mgnlmedia/media/types/impl/BaseTypeHandler.java 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/MediaLoadUtils.java trunk/openutils-mgnlmedia/src/main/resources/META-INF/magnolia/media.xml trunk/openutils-mgnlmedia/src/site/changes/changes.xml Added Paths: ----------- trunk/openutils-mgnlmedia/src/main/java/net/sourceforge/openutils/mgnlmedia/media/lifecycle/MediaModule.java Removed Paths: ------------- trunk/openutils-mgnlmedia/src/main/java/net/sourceforge/openutils/mgnlmedia/media/lifecycle/MediaModuleLifecycle.java Modified: trunk/openutils-mgnlmedia/src/main/java/net/sourceforge/openutils/mgnlmedia/media/configuration/MediaConfigurationManager.java =================================================================== --- trunk/openutils-mgnlmedia/src/main/java/net/sourceforge/openutils/mgnlmedia/media/configuration/MediaConfigurationManager.java 2009-04-29 15:17:11 UTC (rev 1168) +++ trunk/openutils-mgnlmedia/src/main/java/net/sourceforge/openutils/mgnlmedia/media/configuration/MediaConfigurationManager.java 2009-04-29 20:39:50 UTC (rev 1169) @@ -46,7 +46,7 @@ import javax.jcr.RepositoryException; import javax.jcr.query.InvalidQueryException; -import net.sourceforge.openutils.mgnlmedia.media.lifecycle.MediaModuleLifecycle; +import net.sourceforge.openutils.mgnlmedia.media.lifecycle.MediaModule; import net.sourceforge.openutils.mgnlmedia.media.pages.MediaFolderViewPage; import net.sourceforge.openutils.mgnlmedia.media.types.MediaTypeHandler; @@ -340,7 +340,7 @@ @SuppressWarnings("unchecked") public Collection<Content> search(String text, final String type) throws RepositoryException { - QueryManager qm = MgnlContext.getQueryManager(MediaModuleLifecycle.REPO); + QueryManager qm = MgnlContext.getQueryManager(MediaModule.REPO); StringBuilder sb = new StringBuilder(); sb.append("//*[jcr:contains(.,'"); sb.append(StringUtils.replace(text, "'", "''")); @@ -406,7 +406,7 @@ .getInstance() .getMappings()) { - if (mapping.getRepository().equals(MediaModuleLifecycle.REPO)) + if (mapping.getRepository().equals(MediaModule.REPO)) { return mapping.getURIPrefix(); } Modified: trunk/openutils-mgnlmedia/src/main/java/net/sourceforge/openutils/mgnlmedia/media/dialog/DialogSelectMedia.java =================================================================== --- trunk/openutils-mgnlmedia/src/main/java/net/sourceforge/openutils/mgnlmedia/media/dialog/DialogSelectMedia.java 2009-04-29 15:17:11 UTC (rev 1168) +++ trunk/openutils-mgnlmedia/src/main/java/net/sourceforge/openutils/mgnlmedia/media/dialog/DialogSelectMedia.java 2009-04-29 20:39:50 UTC (rev 1169) @@ -49,7 +49,7 @@ import net.sourceforge.openutils.mgnlmedia.media.configuration.MediaConfigurationManager; import net.sourceforge.openutils.mgnlmedia.media.configuration.MediaTypeConfiguration; -import net.sourceforge.openutils.mgnlmedia.media.lifecycle.MediaModuleLifecycle; +import net.sourceforge.openutils.mgnlmedia.media.lifecycle.MediaModule; import org.apache.commons.lang.exception.NestableRuntimeException; import org.slf4j.Logger; @@ -220,7 +220,7 @@ { if (this.media == null && this.getValue() != null && this.getValue().length() > 0) { - HierarchyManager hm = MgnlContext.getHierarchyManager(MediaModuleLifecycle.REPO); + HierarchyManager hm = MgnlContext.getHierarchyManager(MediaModule.REPO); this.media = hm.getContentByUUID(this.getValue()); } return this.media; Modified: trunk/openutils-mgnlmedia/src/main/java/net/sourceforge/openutils/mgnlmedia/media/dialog/LayerDialogMVC.java =================================================================== --- trunk/openutils-mgnlmedia/src/main/java/net/sourceforge/openutils/mgnlmedia/media/dialog/LayerDialogMVC.java 2009-04-29 15:17:11 UTC (rev 1168) +++ trunk/openutils-mgnlmedia/src/main/java/net/sourceforge/openutils/mgnlmedia/media/dialog/LayerDialogMVC.java 2009-04-29 20:39:50 UTC (rev 1169) @@ -35,7 +35,7 @@ import javax.servlet.http.HttpServletResponse; import net.sourceforge.openutils.mgnlmedia.media.configuration.MediaConfigurationManager; -import net.sourceforge.openutils.mgnlmedia.media.lifecycle.MediaModuleLifecycle; +import net.sourceforge.openutils.mgnlmedia.media.lifecycle.MediaModule; import org.apache.commons.lang.StringUtils; import org.slf4j.Logger; @@ -160,7 +160,7 @@ if (control.getNodeName().equals("mgnlNew")) { - HierarchyManager hm = MgnlContext.getHierarchyManager(MediaModuleLifecycle.REPO); + HierarchyManager hm = MgnlContext.getHierarchyManager(MediaModule.REPO); Content c = null; try { Copied: trunk/openutils-mgnlmedia/src/main/java/net/sourceforge/openutils/mgnlmedia/media/lifecycle/MediaModule.java (from rev 1163, trunk/openutils-mgnlmedia/src/main/java/net/sourceforge/openutils/mgnlmedia/media/lifecycle/MediaModuleLifecycle.java) =================================================================== --- trunk/openutils-mgnlmedia/src/main/java/net/sourceforge/openutils/mgnlmedia/media/lifecycle/MediaModule.java (rev 0) +++ trunk/openutils-mgnlmedia/src/main/java/net/sourceforge/openutils/mgnlmedia/media/lifecycle/MediaModule.java 2009-04-29 20:39:50 UTC (rev 1169) @@ -0,0 +1,90 @@ +/** + * Copyright Openmind http://www.openmindonline.it + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see <http://www.gnu.org/licenses/>. + * + */ +package net.sourceforge.openutils.mgnlmedia.media.lifecycle; + +import info.magnolia.module.ModuleLifecycle; +import info.magnolia.module.ModuleLifecycleContext; +import net.sourceforge.openutils.mgnlmedia.media.configuration.MediaConfigurationManager; + +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + + +/** + * @author molaschi + */ +public class MediaModule implements ModuleLifecycle +{ + + /** + * + */ + public static final String REPO = "media"; + + private Logger log = LoggerFactory.getLogger(MediaModule.class); + + private boolean autoactivate; + + private static MediaModule instance; + + public MediaModule() + { + instance = this; + } + + public static MediaModule getInstance() + { + return instance; + } + + /** + * {@inheritDoc} + */ + public void start(ModuleLifecycleContext ctx) + { + log.info("Starting module media"); + ctx.registerModuleObservingComponent("mediatypes", MediaConfigurationManager.getInstance()); + } + + /** + * {@inheritDoc} + */ + public void stop(ModuleLifecycleContext ctx) + { + log.info("Stopping module media"); + } + + /** + * Returns the autoactivate. + * @return the autoactivate + */ + public boolean isAutoactivate() + { + return autoactivate; + } + + /** + * Sets the autoactivate. + * @param autoactivate the autoactivate to set + */ + public void setAutoactivate(boolean autoactivate) + { + this.autoactivate = autoactivate; + } + +} Deleted: trunk/openutils-mgnlmedia/src/main/java/net/sourceforge/openutils/mgnlmedia/media/lifecycle/MediaModuleLifecycle.java =================================================================== --- trunk/openutils-mgnlmedia/src/main/java/net/sourceforge/openutils/mgnlmedia/media/lifecycle/MediaModuleLifecycle.java 2009-04-29 15:17:11 UTC (rev 1168) +++ trunk/openutils-mgnlmedia/src/main/java/net/sourceforge/openutils/mgnlmedia/media/lifecycle/MediaModuleLifecycle.java 2009-04-29 20:39:50 UTC (rev 1169) @@ -1,59 +0,0 @@ -/** - * Copyright Openmind http://www.openmindonline.it - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see <http://www.gnu.org/licenses/>. - * - */ -package net.sourceforge.openutils.mgnlmedia.media.lifecycle; - -import info.magnolia.module.ModuleLifecycle; -import info.magnolia.module.ModuleLifecycleContext; -import net.sourceforge.openutils.mgnlmedia.media.configuration.MediaConfigurationManager; - -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; - - -/** - * @author molaschi - */ -public class MediaModuleLifecycle implements ModuleLifecycle -{ - /** - * - */ - public static final String REPO = "media"; - - private Logger log = LoggerFactory.getLogger(MediaModuleLifecycle.class); - - /** - * - * {@inheritDoc} - */ - public void start(ModuleLifecycleContext ctx) - { - log.info("Starting module media"); - ctx.registerModuleObservingComponent("mediatypes", MediaConfigurationManager.getInstance()); - } - - /** - * - * {@inheritDoc} - */ - public void stop(ModuleLifecycleContext ctx) - { - log.info("Stopping module media"); - } - -} Modified: trunk/openutils-mgnlmedia/src/main/java/net/sourceforge/openutils/mgnlmedia/media/pages/MediaBrowserPage.java =================================================================== --- trunk/openutils-mgnlmedia/src/main/java/net/sourceforge/openutils/mgnlmedia/media/pages/MediaBrowserPage.java 2009-04-29 15:17:11 UTC (rev 1168) +++ trunk/openutils-mgnlmedia/src/main/java/net/sourceforge/openutils/mgnlmedia/media/pages/MediaBrowserPage.java 2009-04-29 20:39:50 UTC (rev 1169) @@ -20,17 +20,14 @@ import info.magnolia.cms.beans.runtime.Document; import info.magnolia.cms.core.Content; import info.magnolia.cms.core.HierarchyManager; -import info.magnolia.cms.core.ItemType; -import info.magnolia.cms.core.NodeData; -import info.magnolia.cms.core.Path; import info.magnolia.cms.i18n.Messages; import info.magnolia.cms.security.AccessDeniedException; -import info.magnolia.cms.util.NodeDataUtil; import info.magnolia.context.MgnlContext; import java.io.File; import java.io.FileOutputStream; import java.io.IOException; +import java.io.InputStream; import java.util.Date; import java.util.Enumeration; import java.util.zip.ZipEntry; @@ -40,9 +37,8 @@ import javax.servlet.http.HttpServletRequest; import javax.servlet.http.HttpServletResponse; -import net.sourceforge.openutils.mgnlmedia.media.configuration.MediaConfigurationManager; -import net.sourceforge.openutils.mgnlmedia.media.configuration.MediaTypeConfiguration; -import net.sourceforge.openutils.mgnlmedia.media.lifecycle.MediaModuleLifecycle; +import net.sourceforge.openutils.mgnlmedia.media.lifecycle.MediaModule; +import net.sourceforge.openutils.mgnlmedia.media.utils.MediaLoadUtils; import org.apache.commons.io.IOUtils; import org.apache.commons.lang.StringUtils; @@ -92,7 +88,7 @@ if (actMedia != null) { - HierarchyManager mgr = MgnlContext.getHierarchyManager(MediaModuleLifecycle.REPO); + HierarchyManager mgr = MgnlContext.getHierarchyManager(MediaModule.REPO); try { Content media = mgr.getContentByUUID(actMedia); @@ -110,7 +106,7 @@ { try { - HierarchyManager mgr = MgnlContext.getSystemContext().getHierarchyManager(MediaModuleLifecycle.REPO); + HierarchyManager mgr = MgnlContext.getSystemContext().getHierarchyManager(MediaModule.REPO); File temp = File.createTempFile("zipmedia", ".zip"); FileOutputStream fos = new FileOutputStream(temp); IOUtils.copy(zipFile.getStream(), fos); @@ -132,48 +128,18 @@ path = path.substring(0, path.length() - 1); } - if (entry.isDirectory()) + if (!entry.isDirectory()) { - getOrCreateFullPath(mgr, parentPath + path); - } - else - { + InputStream inputStream = zip.getInputStream(entry); + String parent = StringUtils.substringBeforeLast(path, "/"); String filename = StringUtils.substringAfterLast(path, "/"); - if (StringUtils.isEmpty(parent)) - { - parent = "/"; - } - String extension = StringUtils.substringAfterLast(filename, "."); - String cleanFilename = StringUtils.substringBeforeLast(filename, "."); - MediaTypeConfiguration mtc = MediaConfigurationManager.getMediaHandlerFromExtension(extension); - if (mtc != null) - { - Content parentNode = getOrCreateFullPath(mgr, parentPath + parent); + MediaLoadUtils.loadEntry(inputStream, StringUtils.defaultIfEmpty(parent, "/"), filename, false); - Content media = mgr.createContent(parentPath + parent, Path.getUniqueLabel( - parentNode, - cleanFilename), MediaConfigurationManager.MEDIA.getSystemName()); - - NodeData nd = NodeDataUtil.getOrCreate(media, "type"); - nd.setValue(mtc.getName()); - - mgr.save(); - - File f = File.createTempFile("entry", extension); - FileOutputStream fTemp = new FileOutputStream(f); - - IOUtils.copy(zip.getInputStream(entry), fTemp); - - fTemp.close(); - - mtc.getHandler().saveFromZipFile(media, f, cleanFilename, extension); - - mgr.save(); - } } + } } catch (IOException e) @@ -194,31 +160,6 @@ return this.show(); } - public static Content getOrCreateFullPath(HierarchyManager mgr, String path) throws RepositoryException - { - try - { - return mgr.getContent(path); - } - catch (RepositoryException ex) - { - String parent = StringUtils.substringBeforeLast(path, "/"); - String label = StringUtils.substringAfterLast(path, "/"); - if (!StringUtils.isEmpty(parent)) - { - getOrCreateFullPath(mgr, parent); - } - else - { - parent = "/"; - } - - Content c = mgr.createContent(parent, label, ItemType.CONTENT.getSystemName()); - mgr.save(); - return c; - } - } - /** * Returns the cacheKiller. * @return the cacheKiller 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 2009-04-29 15:17:11 UTC (rev 1168) +++ trunk/openutils-mgnlmedia/src/main/java/net/sourceforge/openutils/mgnlmedia/media/pages/MediaFolderViewPage.java 2009-04-29 20:39:50 UTC (rev 1169) @@ -50,7 +50,7 @@ import net.sourceforge.openutils.mgnlmedia.media.configuration.MediaConfigurationManager; import net.sourceforge.openutils.mgnlmedia.media.configuration.MediaTypeConfiguration; -import net.sourceforge.openutils.mgnlmedia.media.lifecycle.MediaModuleLifecycle; +import net.sourceforge.openutils.mgnlmedia.media.lifecycle.MediaModule; import org.apache.commons.chain.Command; import org.apache.commons.lang.StringUtils; @@ -170,7 +170,7 @@ numberOfMedia = new HashMap<String, Integer>(); for (MediaTypeConfiguration mtc : types) { - QueryManager qm = MgnlContext.getQueryManager(MediaModuleLifecycle.REPO); + QueryManager qm = MgnlContext.getQueryManager(MediaModule.REPO); try { Query q = qm.createQuery( @@ -193,7 +193,7 @@ @Override public String show() { - HierarchyManager hm = MgnlContext.getInstance().getHierarchyManager(MediaModuleLifecycle.REPO); + HierarchyManager hm = MgnlContext.getInstance().getHierarchyManager(MediaModule.REPO); MediaTypeConfiguration mtc = MediaConfigurationManager.getInstance().getTypes().get(type); Collection<Content> mediasOfType = null; @@ -252,7 +252,8 @@ try { mb.setWritable(media.getParent().isGranted(Permission.WRITE)); - mb.setCanPublish(mb.isWritable() + mb.setCanPublish(!MediaModule.getInstance().isAutoactivate() + && mb.isWritable() && ActivationManagerFactory.getActivationManager().hasAnyActiveSubscriber()); mb.getUsedInWebPages().addAll( @@ -275,7 +276,7 @@ */ public String delete() { - HierarchyManager hm = MgnlContext.getInstance().getHierarchyManager(MediaModuleLifecycle.REPO); + HierarchyManager hm = MgnlContext.getInstance().getHierarchyManager(MediaModule.REPO); try { @@ -355,7 +356,7 @@ public Content copyMoveNode(String source, String destination, boolean move) throws ExchangeException, RepositoryException { - HierarchyManager hm = MgnlContext.getHierarchyManager(MediaModuleLifecycle.REPO); + HierarchyManager hm = MgnlContext.getHierarchyManager(MediaModule.REPO); String goTo = destination; @@ -422,7 +423,7 @@ actCmd.setItemTypes(sb.toString()); Context context = MgnlContext.getInstance(); - context.put(Context.ATTRIBUTE_REPOSITORY, MediaModuleLifecycle.REPO); + context.put(Context.ATTRIBUTE_REPOSITORY, MediaModule.REPO); context.put(Context.ATTRIBUTE_PATH, this.node); context.put(Context.ATTRIBUTE_RECURSIVE, false); @@ -444,7 +445,7 @@ Command cmd = CommandsManager.getInstance().getCommand(CommandsManager.DEFAULT_CATALOG, "deactivate"); Context context = MgnlContext.getInstance(); - context.put(Context.ATTRIBUTE_REPOSITORY, MediaModuleLifecycle.REPO); + context.put(Context.ATTRIBUTE_REPOSITORY, MediaModule.REPO); context.put(Context.ATTRIBUTE_PATH, this.node); try @@ -462,7 +463,7 @@ public String download() { - HierarchyManager hm = MgnlContext.getHierarchyManager(MediaModuleLifecycle.REPO); + HierarchyManager hm = MgnlContext.getHierarchyManager(MediaModule.REPO); Content media; try Modified: trunk/openutils-mgnlmedia/src/main/java/net/sourceforge/openutils/mgnlmedia/media/pages/MediaLoadZipFilePage.java =================================================================== --- trunk/openutils-mgnlmedia/src/main/java/net/sourceforge/openutils/mgnlmedia/media/pages/MediaLoadZipFilePage.java 2009-04-29 15:17:11 UTC (rev 1168) +++ trunk/openutils-mgnlmedia/src/main/java/net/sourceforge/openutils/mgnlmedia/media/pages/MediaLoadZipFilePage.java 2009-04-29 20:39:50 UTC (rev 1169) @@ -34,7 +34,7 @@ import javax.servlet.http.HttpServletRequest; import javax.servlet.http.HttpServletResponse; -import net.sourceforge.openutils.mgnlmedia.media.lifecycle.MediaModuleLifecycle; +import net.sourceforge.openutils.mgnlmedia.media.lifecycle.MediaModule; import net.sourceforge.openutils.mgnlmedia.media.utils.MediaLoadUtils; import org.apache.commons.io.IOUtils; @@ -67,7 +67,7 @@ InputStream zipStream = null; try { - HierarchyManager mgr = MgnlContext.getSystemContext().getHierarchyManager(MediaModuleLifecycle.REPO); + HierarchyManager mgr = MgnlContext.getSystemContext().getHierarchyManager(MediaModule.REPO); File temp = File.createTempFile("zipmedia", ".zip"); FileOutputStream fos = new FileOutputStream(temp); @@ -83,7 +83,7 @@ String path = entry.getName(); path = StringUtils.replace(path, "\\", "/"); - if (path.startsWith("/")) + if (!path.startsWith("/")) { path = "/" + path; } Modified: trunk/openutils-mgnlmedia/src/main/java/net/sourceforge/openutils/mgnlmedia/media/pages/MediaSearchPage.java =================================================================== --- trunk/openutils-mgnlmedia/src/main/java/net/sourceforge/openutils/mgnlmedia/media/pages/MediaSearchPage.java 2009-04-29 15:17:11 UTC (rev 1168) +++ trunk/openutils-mgnlmedia/src/main/java/net/sourceforge/openutils/mgnlmedia/media/pages/MediaSearchPage.java 2009-04-29 20:39:50 UTC (rev 1169) @@ -39,7 +39,7 @@ import net.sourceforge.openutils.mgnlmedia.media.configuration.MediaConfigurationManager; import net.sourceforge.openutils.mgnlmedia.media.configuration.MediaTypeConfiguration; -import net.sourceforge.openutils.mgnlmedia.media.lifecycle.MediaModuleLifecycle; +import net.sourceforge.openutils.mgnlmedia.media.lifecycle.MediaModule; import org.apache.commons.lang.StringUtils; import org.slf4j.Logger; @@ -99,7 +99,7 @@ mtc.add(entry.getValue()); } - HierarchyManager mgr = MgnlContext.getHierarchyManager(MediaModuleLifecycle.REPO); + HierarchyManager mgr = MgnlContext.getHierarchyManager(MediaModule.REPO); try { Collection<Content> contents = mgr.getRoot().getChildren(MediaConfigurationManager.FOLDER); Modified: trunk/openutils-mgnlmedia/src/main/java/net/sourceforge/openutils/mgnlmedia/media/save/MediaCustomSaveHandler.java =================================================================== --- trunk/openutils-mgnlmedia/src/main/java/net/sourceforge/openutils/mgnlmedia/media/save/MediaCustomSaveHandler.java 2009-04-29 15:17:11 UTC (rev 1168) +++ trunk/openutils-mgnlmedia/src/main/java/net/sourceforge/openutils/mgnlmedia/media/save/MediaCustomSaveHandler.java 2009-04-29 20:39:50 UTC (rev 1169) @@ -28,7 +28,7 @@ import net.sourceforge.openutils.mgnlmedia.media.configuration.MediaConfigurationManager; import net.sourceforge.openutils.mgnlmedia.media.configuration.MediaTypeConfiguration; -import net.sourceforge.openutils.mgnlmedia.media.lifecycle.MediaModuleLifecycle; +import net.sourceforge.openutils.mgnlmedia.media.lifecycle.MediaModule; import org.apache.commons.lang.StringUtils; @@ -59,7 +59,7 @@ return; } - HierarchyManager hm = MgnlContext.getHierarchyManager(MediaModuleLifecycle.REPO); + HierarchyManager hm = MgnlContext.getHierarchyManager(MediaModule.REPO); Content media = hm.getContentByUUID(value); Modified: trunk/openutils-mgnlmedia/src/main/java/net/sourceforge/openutils/mgnlmedia/media/setup/RemoveResolutionsNodeTask.java =================================================================== --- trunk/openutils-mgnlmedia/src/main/java/net/sourceforge/openutils/mgnlmedia/media/setup/RemoveResolutionsNodeTask.java 2009-04-29 15:17:11 UTC (rev 1168) +++ trunk/openutils-mgnlmedia/src/main/java/net/sourceforge/openutils/mgnlmedia/media/setup/RemoveResolutionsNodeTask.java 2009-04-29 20:39:50 UTC (rev 1169) @@ -31,7 +31,7 @@ import info.magnolia.module.delta.AbstractTask; import info.magnolia.module.delta.TaskExecutionException; import net.sourceforge.openutils.mgnlmedia.media.configuration.MediaConfigurationManager; -import net.sourceforge.openutils.mgnlmedia.media.lifecycle.MediaModuleLifecycle; +import net.sourceforge.openutils.mgnlmedia.media.lifecycle.MediaModule; /** @@ -55,7 +55,7 @@ */ public void execute(InstallContext installContext) throws TaskExecutionException { - HierarchyManager hm = installContext.getHierarchyManager(MediaModuleLifecycle.REPO); + HierarchyManager hm = installContext.getHierarchyManager(MediaModule.REPO); QueryManager mgr = hm.getQueryManager(); try { Modified: trunk/openutils-mgnlmedia/src/main/java/net/sourceforge/openutils/mgnlmedia/media/setup/RenameThumbToImageTask.java =================================================================== --- trunk/openutils-mgnlmedia/src/main/java/net/sourceforge/openutils/mgnlmedia/media/setup/RenameThumbToImageTask.java 2009-04-29 15:17:11 UTC (rev 1168) +++ trunk/openutils-mgnlmedia/src/main/java/net/sourceforge/openutils/mgnlmedia/media/setup/RenameThumbToImageTask.java 2009-04-29 20:39:50 UTC (rev 1169) @@ -34,7 +34,7 @@ import javax.jcr.RepositoryException; import net.sourceforge.openutils.mgnlmedia.media.configuration.MediaConfigurationManager; -import net.sourceforge.openutils.mgnlmedia.media.lifecycle.MediaModuleLifecycle; +import net.sourceforge.openutils.mgnlmedia.media.lifecycle.MediaModule; /** @@ -58,7 +58,7 @@ */ public void execute(InstallContext installContext) throws TaskExecutionException { - HierarchyManager hm = installContext.getHierarchyManager(MediaModuleLifecycle.REPO); + HierarchyManager hm = installContext.getHierarchyManager(MediaModule.REPO); QueryManager mgr = hm.getQueryManager(); try { Modified: trunk/openutils-mgnlmedia/src/main/java/net/sourceforge/openutils/mgnlmedia/media/tags/el/MediaEl.java =================================================================== --- trunk/openutils-mgnlmedia/src/main/java/net/sourceforge/openutils/mgnlmedia/media/tags/el/MediaEl.java 2009-04-29 15:17:11 UTC (rev 1168) +++ trunk/openutils-mgnlmedia/src/main/java/net/sourceforge/openutils/mgnlmedia/media/tags/el/MediaEl.java 2009-04-29 20:39:50 UTC (rev 1169) @@ -36,7 +36,7 @@ import net.sourceforge.openutils.mgnlmedia.media.configuration.MediaConfigurationManager; import net.sourceforge.openutils.mgnlmedia.media.configuration.MediaTypeConfiguration; -import net.sourceforge.openutils.mgnlmedia.media.lifecycle.MediaModuleLifecycle; +import net.sourceforge.openutils.mgnlmedia.media.lifecycle.MediaModule; import net.sourceforge.openutils.mgnlmedia.media.utils.ImageUtils; import org.apache.commons.collections.CollectionUtils; @@ -78,7 +78,7 @@ if (obj instanceof String) { String uuid = (String) obj; - HierarchyManager hm = MgnlContext.getHierarchyManager(MediaModuleLifecycle.REPO); + HierarchyManager hm = MgnlContext.getHierarchyManager(MediaModule.REPO); try { return hm.getContentByUUID(uuid); Modified: trunk/openutils-mgnlmedia/src/main/java/net/sourceforge/openutils/mgnlmedia/media/tree/MediaModuleTreeConfiguration.java =================================================================== --- trunk/openutils-mgnlmedia/src/main/java/net/sourceforge/openutils/mgnlmedia/media/tree/MediaModuleTreeConfiguration.java 2009-04-29 15:17:11 UTC (rev 1168) +++ trunk/openutils-mgnlmedia/src/main/java/net/sourceforge/openutils/mgnlmedia/media/tree/MediaModuleTreeConfiguration.java 2009-04-29 20:39:50 UTC (rev 1169) @@ -35,6 +35,7 @@ import net.sourceforge.openutils.mgnlmedia.media.configuration.MediaConfigurationManager; import net.sourceforge.openutils.mgnlmedia.media.configuration.MediaTypeConfiguration; +import net.sourceforge.openutils.mgnlmedia.media.lifecycle.MediaModule; import org.apache.commons.lang.StringUtils; @@ -191,12 +192,15 @@ tree.addMenuItem(menuCut); tree.addMenuItem(menuCopy); - if (MgnlContext.getUser().hasRole("media-publish") || MgnlContext.getUser().hasRole("superuser")) + if (!MediaModule.getInstance().isAutoactivate()) { - tree.addSeparator(); - tree.addMenuItem(menuActivateExcl); - tree.addMenuItem(menuActivate); - tree.addMenuItem(menuDeactivate); + if (MgnlContext.getUser().hasRole("media-publish") || MgnlContext.getUser().hasRole("superuser")) + { + tree.addSeparator(); + tree.addMenuItem(menuActivateExcl); + tree.addMenuItem(menuActivate); + tree.addMenuItem(menuDeactivate); + } } } else Modified: trunk/openutils-mgnlmedia/src/main/java/net/sourceforge/openutils/mgnlmedia/media/types/impl/BaseTypeHandler.java =================================================================== --- trunk/openutils-mgnlmedia/src/main/java/net/sourceforge/openutils/mgnlmedia/media/types/impl/BaseTypeHandler.java 2009-04-29 15:17:11 UTC (rev 1168) +++ trunk/openutils-mgnlmedia/src/main/java/net/sourceforge/openutils/mgnlmedia/media/types/impl/BaseTypeHandler.java 2009-04-29 20:39:50 UTC (rev 1169) @@ -27,6 +27,7 @@ import javax.jcr.RepositoryException; +import net.sourceforge.openutils.mgnlmedia.media.lifecycle.MediaModule; import net.sourceforge.openutils.mgnlmedia.media.types.MediaTypeHandler; import org.slf4j.Logger; @@ -110,6 +111,12 @@ } media.save(); } + + if (MediaModule.getInstance().isAutoactivate()) + { + media.getMetaData().setActivated(); + media.save(); + } } catch (RepositoryException ex) { 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 2009-04-29 15:17:11 UTC (rev 1168) +++ trunk/openutils-mgnlmedia/src/main/java/net/sourceforge/openutils/mgnlmedia/media/utils/ImageUtils.java 2009-04-29 20:39:50 UTC (rev 1169) @@ -51,7 +51,7 @@ import javax.jcr.RepositoryException; import net.sourceforge.openutils.mgnlmedia.media.configuration.MediaConfigurationManager; -import net.sourceforge.openutils.mgnlmedia.media.lifecycle.MediaModuleLifecycle; +import net.sourceforge.openutils.mgnlmedia.media.lifecycle.MediaModule; import org.apache.commons.io.IOUtils; import org.apache.commons.lang.ClassUtils; @@ -514,7 +514,7 @@ */ public void exec() { - HierarchyManager hm = MgnlContext.getHierarchyManager(MediaModuleLifecycle.REPO); + HierarchyManager hm = MgnlContext.getHierarchyManager(MediaModule.REPO); String resolution = resolutionTarget; if ("thumbnail".equals(resolution)) Modified: trunk/openutils-mgnlmedia/src/main/java/net/sourceforge/openutils/mgnlmedia/media/utils/MediaLoadUtils.java =================================================================== --- trunk/openutils-mgnlmedia/src/main/java/net/sourceforge/openutils/mgnlmedia/media/utils/MediaLoadUtils.java 2009-04-29 15:17:11 UTC (rev 1168) +++ trunk/openutils-mgnlmedia/src/main/java/net/sourceforge/openutils/mgnlmedia/media/utils/MediaLoadUtils.java 2009-04-29 20:39:50 UTC (rev 1169) @@ -35,7 +35,7 @@ import net.sourceforge.openutils.mgnlmedia.media.configuration.MediaConfigurationManager; import net.sourceforge.openutils.mgnlmedia.media.configuration.MediaTypeConfiguration; -import net.sourceforge.openutils.mgnlmedia.media.lifecycle.MediaModuleLifecycle; +import net.sourceforge.openutils.mgnlmedia.media.lifecycle.MediaModule; import org.apache.commons.io.IOUtils; import org.apache.commons.lang.StringUtils; @@ -61,7 +61,7 @@ log.debug("loading image {} {}", parent, filename); - HierarchyManager mgr = MgnlContext.getSystemContext().getHierarchyManager(MediaModuleLifecycle.REPO); + HierarchyManager mgr = MgnlContext.getSystemContext().getHierarchyManager(MediaModule.REPO); String extension = StringUtils.substringAfterLast(filename, "."); String cleanFilename = StringUtils.substringBeforeLast(filename, "."); @@ -105,6 +105,11 @@ nd = NodeDataUtil.getOrCreate(media, "modificationDate"); nd.setValue(Calendar.getInstance()); + if (MediaModule.getInstance().isAutoactivate()) + { + media.getMetaData().setActivated(); + } + mgr.save(); File f = File.createTempFile("entry", extension); @@ -122,7 +127,7 @@ return null; } - private static Content getOrCreateFullPath(HierarchyManager mgr, String path) throws RepositoryException + public static Content getOrCreateFullPath(HierarchyManager mgr, String path) throws RepositoryException { String[] contentNodeNames = path.split("/"); Content currContent = mgr.getRoot(); @@ -134,6 +139,11 @@ currContent, contentNodeName, MediaConfigurationManager.FOLDER); + + if (MediaModule.getInstance().isAutoactivate() && !currContent.getMetaData().getIsActivated()) + { + currContent.getMetaData().setActivated(); + } } } return currContent; Modified: trunk/openutils-mgnlmedia/src/main/resources/META-INF/magnolia/media.xml =================================================================== --- trunk/openutils-mgnlmedia/src/main/resources/META-INF/magnolia/media.xml 2009-04-29 15:17:11 UTC (rev 1168) +++ trunk/openutils-mgnlmedia/src/main/resources/META-INF/magnolia/media.xml 2009-04-29 20:39:50 UTC (rev 1169) @@ -4,7 +4,7 @@ <name>media</name> <displayName>magnolia media module</displayName> <description>magnolia media module</description> - <class>net.sourceforge.openutils.mgnlmedia.media.lifecycle.MediaModuleLifecycle</class> + <class>net.sourceforge.openutils.mgnlmedia.media.lifecycle.MediaModule</class> <versionHandler>net.sourceforge.openutils.mgnlmedia.media.setup.MediaModuleVersionHandler</versionHandler> <version>${project.version}</version> <dependencies> Modified: trunk/openutils-mgnlmedia/src/site/changes/changes.xml =================================================================== --- trunk/openutils-mgnlmedia/src/site/changes/changes.xml 2009-04-29 15:17:11 UTC (rev 1168) +++ trunk/openutils-mgnlmedia/src/site/changes/changes.xml 2009-04-29 20:39:50 UTC (rev 1169) @@ -11,8 +11,10 @@ <release version="4.0-b4" date="in svn" description=""> <action type="update" dev="fgiust">YouTubeVideoTypeHandler modified in order to work with generic external urls (not only youtube)</action> - <action type="update" dev="fgiust">new utility class net.sourceforge.openutils.mgnlmedia.media.utils.MediaLoadUtils + <action type="add" dev="fgiust">new utility class net.sourceforge.openutils.mgnlmedia.media.utils.MediaLoadUtils </action> + <action type="add" dev="fgiust">new property "autoactivate" that can be set in module configuration + (/modules/media/config/autoactivate) to have imported media activated by default.</action> </release> <release version="4.0-b3" date="2009-04-23" description=""> <action type="update" dev="fgiust">Update openutils-mgnltasks dependency to 4.0</action> This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <fg...@us...> - 2009-05-11 17:51:24
|
Revision: 1198 http://openutils.svn.sourceforge.net/openutils/?rev=1198&view=rev Author: fgiust Date: 2009-05-11 17:51:11 +0000 (Mon, 11 May 2009) Log Message: ----------- ignore (log) missing media in MediaCustomSaveHandler Modified Paths: -------------- trunk/openutils-mgnlmedia/src/main/java/net/sourceforge/openutils/mgnlmedia/media/save/MediaCustomSaveHandler.java trunk/openutils-mgnlmedia/src/site/changes/changes.xml Modified: trunk/openutils-mgnlmedia/src/main/java/net/sourceforge/openutils/mgnlmedia/media/save/MediaCustomSaveHandler.java =================================================================== --- trunk/openutils-mgnlmedia/src/main/java/net/sourceforge/openutils/mgnlmedia/media/save/MediaCustomSaveHandler.java 2009-05-11 17:22:11 UTC (rev 1197) +++ trunk/openutils-mgnlmedia/src/main/java/net/sourceforge/openutils/mgnlmedia/media/save/MediaCustomSaveHandler.java 2009-05-11 17:51:11 UTC (rev 1198) @@ -24,6 +24,7 @@ import info.magnolia.context.MgnlContext; import info.magnolia.module.admininterface.FieldSaveHandler; +import javax.jcr.ItemNotFoundException; import javax.jcr.RepositoryException; import net.sourceforge.openutils.mgnlmedia.media.configuration.MediaConfigurationManager; @@ -31,6 +32,8 @@ import net.sourceforge.openutils.mgnlmedia.media.lifecycle.MediaModule; import org.apache.commons.lang.StringUtils; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; /** @@ -41,6 +44,11 @@ { /** + * Logger. + */ + private Logger log = LoggerFactory.getLogger(MediaCustomSaveHandler.class); + + /** * {@inheritDoc} */ public void save(Content parentNode, Content configNode, String name, MultipartForm form, int type, int valueType, @@ -61,19 +69,27 @@ HierarchyManager hm = MgnlContext.getHierarchyManager(MediaModule.REPO); - Content media = hm.getContentByUUID(value); + try + { + Content media = hm.getContentByUUID(value); - MediaTypeConfiguration mtc = MediaConfigurationManager.getInstance().getMediaTypeConfigurationFromMedia(media); - mtc.getHandler().onSavingPropertyMedia( - media, - parentNode, - configNode, - name, - form, - type, - valueType, - isRichEditValue, - encoding); + MediaTypeConfiguration mtc = MediaConfigurationManager.getInstance().getMediaTypeConfigurationFromMedia( + media); + mtc.getHandler().onSavingPropertyMedia( + media, + parentNode, + configNode, + name, + form, + type, + valueType, + isRichEditValue, + encoding); + } + catch (ItemNotFoundException e) + { + log.warn("Missing media {} referenced in node {}", value, parentNode.getHandle()); + } } Modified: trunk/openutils-mgnlmedia/src/site/changes/changes.xml =================================================================== --- trunk/openutils-mgnlmedia/src/site/changes/changes.xml 2009-05-11 17:22:11 UTC (rev 1197) +++ trunk/openutils-mgnlmedia/src/site/changes/changes.xml 2009-05-11 17:51:11 UTC (rev 1198) @@ -8,6 +8,10 @@ <author email="fgiust(at)users.sourceforge.net">Fabrizio Giustina</author> </properties> <body> + <release version="4.0-b5" date="in svn" description=""> + <action type="fix" dev="fgiust">MediaCustomSaveHandler now only warns about missing referenced media without + blocking</action> + </release> <release version="4.0-b4" date="2009-04-29" description=""> <action type="update" dev="fgiust">YouTubeVideoTypeHandler modified in order to work with generic external urls (not only youtube)</action> This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <fg...@us...> - 2009-06-04 09:39:38
|
Revision: 1222 http://openutils.svn.sourceforge.net/openutils/?rev=1222&view=rev Author: fgiust Date: 2009-06-04 09:39:32 +0000 (Thu, 04 Jun 2009) Log Message: ----------- jcr browser fix + fckedit integration Modified Paths: -------------- trunk/openutils-mgnlmedia/src/main/java/net/sourceforge/openutils/mgnlmedia/media/tree/JcrBrowserWithNodeTypeTreeConfiguration.java trunk/openutils-mgnlmedia/src/main/resources/META-INF/magnolia/media.xml trunk/openutils-mgnlmedia/src/main/resources/mgnl-bootstrap/media/config.server.URI2RepositoryMapping.mappings.media.xml trunk/openutils-mgnlmedia/src/site/changes/changes.xml Added Paths: ----------- trunk/openutils-mgnlmedia/src/main/java/net/sourceforge/openutils/mgnlmedia/media/tree/MediaBrowserConfiguration.java trunk/openutils-mgnlmedia/src/main/java/net/sourceforge/openutils/mgnlmedia/media/uri/ trunk/openutils-mgnlmedia/src/main/java/net/sourceforge/openutils/mgnlmedia/media/uri/MediaURI2RepositoryMapping.java trunk/openutils-mgnlmedia/src/main/resources/mgnl-bootstrap/media/config.modules.fckEditor.config.browsableRepositories.media-selector.xml trunk/openutils-mgnlmedia/src/main/resources/mgnl-bootstrap/media/config.modules.media.trees.media-selector.xml Modified: trunk/openutils-mgnlmedia/src/main/java/net/sourceforge/openutils/mgnlmedia/media/tree/JcrBrowserWithNodeTypeTreeConfiguration.java =================================================================== --- trunk/openutils-mgnlmedia/src/main/java/net/sourceforge/openutils/mgnlmedia/media/tree/JcrBrowserWithNodeTypeTreeConfiguration.java 2009-06-04 09:38:57 UTC (rev 1221) +++ trunk/openutils-mgnlmedia/src/main/java/net/sourceforge/openutils/mgnlmedia/media/tree/JcrBrowserWithNodeTypeTreeConfiguration.java 2009-06-04 09:39:32 UTC (rev 1222) @@ -18,6 +18,7 @@ package net.sourceforge.openutils.mgnlmedia.media.tree; import info.magnolia.cms.core.Content; +import info.magnolia.cms.core.ItemType; import info.magnolia.cms.gui.control.Tree; import info.magnolia.cms.gui.control.TreeColumn; import info.magnolia.cms.gui.control.TreeColumnHtmlRenderer; @@ -44,9 +45,13 @@ { // TODO Auto-generated method stub super.prepareTree(tree, browseMode, request); - + + tree.getItemTypes().clear(); + + tree.addItemType(ItemType.CONTENT); tree.addItemType(MediaConfigurationManager.MEDIA); tree.addItemType(MediaConfigurationManager.RESOLUTIONS); + tree.addItemType(Tree.ITEM_TYPE_NODEDATA); TreeColumn tc = TreeColumn.createColumn(tree, "Node type", new TreeColumnHtmlRenderer() { Added: trunk/openutils-mgnlmedia/src/main/java/net/sourceforge/openutils/mgnlmedia/media/tree/MediaBrowserConfiguration.java =================================================================== --- trunk/openutils-mgnlmedia/src/main/java/net/sourceforge/openutils/mgnlmedia/media/tree/MediaBrowserConfiguration.java (rev 0) +++ trunk/openutils-mgnlmedia/src/main/java/net/sourceforge/openutils/mgnlmedia/media/tree/MediaBrowserConfiguration.java 2009-06-04 09:39:32 UTC (rev 1222) @@ -0,0 +1,68 @@ +/** + * Copyright Openmind http://www.openmindonline.it + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see <http://www.gnu.org/licenses/>. + * + */ +package net.sourceforge.openutils.mgnlmedia.media.tree; + +import info.magnolia.cms.core.Content; +import info.magnolia.cms.core.ItemType; +import info.magnolia.cms.gui.control.Tree; +import info.magnolia.cms.gui.control.TreeColumn; +import info.magnolia.cms.gui.control.TreeColumnHtmlRenderer; +import info.magnolia.module.admininterface.trees.JcrBrowserTreeConfiguration; + +import javax.servlet.http.HttpServletRequest; + +import net.sourceforge.openutils.mgnlmedia.media.configuration.MediaConfigurationManager; + + +/** + * @author molaschi + * @version $Id$ + */ +public class MediaBrowserConfiguration extends JcrBrowserTreeConfiguration +{ + + /** + * {@inheritDoc} + */ + @Override + public void prepareTree(Tree tree, boolean browseMode, HttpServletRequest request) + { + super.prepareTree(tree, browseMode, request); + + tree.getItemTypes().clear(); + + tree.addItemType(ItemType.CONTENT); + tree.addItemType(MediaConfigurationManager.MEDIA); + + TreeColumn tc = TreeColumn.createColumn(tree, "Media type", new TreeColumnHtmlRenderer() + { + + /** + * {@inheritDoc} + */ + public String renderHtml(TreeColumn treeColumn, Content content) + { + return content.getNodeData("type").getString(); + } + + }); + + tree.addColumn(tc); + } + +} Property changes on: trunk/openutils-mgnlmedia/src/main/java/net/sourceforge/openutils/mgnlmedia/media/tree/MediaBrowserConfiguration.java ___________________________________________________________________ Added: svn:mime-type + text/plain Added: svn:keywords + Author Date Id Revision Added: svn:eol-style + native Added: trunk/openutils-mgnlmedia/src/main/java/net/sourceforge/openutils/mgnlmedia/media/uri/MediaURI2RepositoryMapping.java =================================================================== --- trunk/openutils-mgnlmedia/src/main/java/net/sourceforge/openutils/mgnlmedia/media/uri/MediaURI2RepositoryMapping.java (rev 0) +++ trunk/openutils-mgnlmedia/src/main/java/net/sourceforge/openutils/mgnlmedia/media/uri/MediaURI2RepositoryMapping.java 2009-06-04 09:39:32 UTC (rev 1222) @@ -0,0 +1,94 @@ +/** + * Copyright Openmind http://www.openmindonline.it + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see <http://www.gnu.org/licenses/>. + * + */ +package net.sourceforge.openutils.mgnlmedia.media.uri; + +import info.magnolia.cms.beans.config.URI2RepositoryMapping; +import info.magnolia.context.MgnlContext; +import info.magnolia.link.Link; + +import javax.jcr.RepositoryException; + +import net.sourceforge.openutils.mgnlmedia.media.tags.el.MediaEl; + +import org.apache.commons.lang.StringUtils; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + + +/** + * @author fgiust + * @version $Id$ + */ +public class MediaURI2RepositoryMapping extends URI2RepositoryMapping +{ + + /** + * Logger. + */ + private Logger log = LoggerFactory.getLogger(MediaURI2RepositoryMapping.class); + + /** + * {@inheritDoc} + */ + @Override + public String getURI(Link uuidLink) + { + String urisimple = uuidLink.getHandle(); + + String uri; + try + { + uri = MediaEl.getUrl(MgnlContext.getHierarchyManager(getRepository()).getContent(urisimple)); + } + catch (RepositoryException e) + { + log.warn(e.getClass().getName() + " resolving " + urisimple, e); + uri = urisimple; + + if (StringUtils.isNotEmpty(getHandlePrefix())) + { + uri = StringUtils.removeStart(uri, getHandlePrefix()); + } + if (StringUtils.isNotEmpty(getURIPrefix())) + { + uri = getURIPrefix() + "/" + uri; + } + } + + return cleanHandle(uri); + } + + /** + * Clean a handle. Remove double / and add always a leading / + * @param handle + * @return + */ + private String cleanHandle(String handle) + { + if (!handle.startsWith("/")) + { + handle = "/" + handle; + } + while (handle.indexOf("//") != -1) + { + handle = StringUtils.replace(handle, "//", "/"); + } + return handle; + } + +} Property changes on: trunk/openutils-mgnlmedia/src/main/java/net/sourceforge/openutils/mgnlmedia/media/uri/MediaURI2RepositoryMapping.java ___________________________________________________________________ Added: svn:mime-type + text/plain Added: svn:keywords + Author Date Id Revision Added: svn:eol-style + native Modified: trunk/openutils-mgnlmedia/src/main/resources/META-INF/magnolia/media.xml =================================================================== --- trunk/openutils-mgnlmedia/src/main/resources/META-INF/magnolia/media.xml 2009-06-04 09:38:57 UTC (rev 1221) +++ trunk/openutils-mgnlmedia/src/main/resources/META-INF/magnolia/media.xml 2009-06-04 09:39:32 UTC (rev 1222) @@ -13,6 +13,10 @@ <version>4.0/*</version> </dependency> <dependency> + <name>fckEditor</name> + <version>4.0/*</version> + </dependency> + <dependency> <name>cache</name> <version>4.0/*</version> </dependency> Added: trunk/openutils-mgnlmedia/src/main/resources/mgnl-bootstrap/media/config.modules.fckEditor.config.browsableRepositories.media-selector.xml =================================================================== --- trunk/openutils-mgnlmedia/src/main/resources/mgnl-bootstrap/media/config.modules.fckEditor.config.browsableRepositories.media-selector.xml (rev 0) +++ trunk/openutils-mgnlmedia/src/main/resources/mgnl-bootstrap/media/config.modules.fckEditor.config.browsableRepositories.media-selector.xml 2009-06-04 09:39:32 UTC (rev 1222) @@ -0,0 +1,43 @@ +<?xml version="1.0" encoding="UTF-8"?> +<sv:node sv:name="media-selector" + xmlns:jcr="http://www.jcp.org/jcr/1.0" + xmlns:mgnl="http://www.magnolia.info/jcr/mgnl" xmlns:rep="internal" xmlns:mix="http://www.jcp.org/jcr/mix/1.0" + xmlns:nt="http://www.jcp.org/jcr/nt/1.0" xmlns:fn="http://www.w3.org/2005/xpath-functions" + xmlns:xs="http://www.w3.org/2001/XMLSchema" xmlns:sv="http://www.jcp.org/jcr/sv/1.0" + xmlns:fn_old="http://www.w3.org/2004/10/xpath-functions" xmlns:jcrfn="http://www.jcp.org/jcr/xpath-functions/1.0"> + <sv:property sv:name="jcr:primaryType" sv:type="Name"> + <sv:value>mgnl:contentNode</sv:value> + </sv:property> + <sv:property sv:name="jcr:mixinTypes" sv:type="Name"> + <sv:value>mix:lockable</sv:value> + </sv:property> + <sv:property sv:name="jcr:uuid" sv:type="String"> + <sv:value>c84e835e-839f-46d2-8e07-3eb85b12e537</sv:value> + </sv:property> + <sv:property sv:name="label" sv:type="String"> + <sv:value>Media</sv:value> + </sv:property> + <sv:node sv:name="MetaData"> + <sv:property sv:name="jcr:primaryType" sv:type="Name"> + <sv:value>mgnl:metaData</sv:value> + </sv:property> + <sv:property sv:name="mgnl:activated" sv:type="Boolean"> + <sv:value>false</sv:value> + </sv:property> + <sv:property sv:name="mgnl:activatorid" sv:type="String"> + <sv:value>superuser</sv:value> + </sv:property> + <sv:property sv:name="mgnl:authorid" sv:type="String"> + <sv:value>admin</sv:value> + </sv:property> + <sv:property sv:name="mgnl:creationdate" sv:type="Date"> + <sv:value>2007-11-07T19:40:13.406+01:00</sv:value> + </sv:property> + <sv:property sv:name="mgnl:lastaction" sv:type="Date"> + <sv:value>2007-11-07T19:40:17.156+01:00</sv:value> + </sv:property> + <sv:property sv:name="mgnl:lastmodified" sv:type="Date"> + <sv:value>2009-06-02T18:49:49.759+02:00</sv:value> + </sv:property> + </sv:node> +</sv:node> Property changes on: trunk/openutils-mgnlmedia/src/main/resources/mgnl-bootstrap/media/config.modules.fckEditor.config.browsableRepositories.media-selector.xml ___________________________________________________________________ Added: svn:mime-type + text/plain Added: svn:keywords + Author Date Id Revision Added: svn:eol-style + native Added: trunk/openutils-mgnlmedia/src/main/resources/mgnl-bootstrap/media/config.modules.media.trees.media-selector.xml =================================================================== --- trunk/openutils-mgnlmedia/src/main/resources/mgnl-bootstrap/media/config.modules.media.trees.media-selector.xml (rev 0) +++ trunk/openutils-mgnlmedia/src/main/resources/mgnl-bootstrap/media/config.modules.media.trees.media-selector.xml 2009-06-04 09:39:32 UTC (rev 1222) @@ -0,0 +1,52 @@ +<?xml version="1.0" encoding="UTF-8"?> +<sv:node sv:name="media-selector" + xmlns:jcr="http://www.jcp.org/jcr/1.0" + xmlns:mgnl="http://www.magnolia.info/jcr/mgnl" xmlns:rep="internal" xmlns:mix="http://www.jcp.org/jcr/mix/1.0" + xmlns:nt="http://www.jcp.org/jcr/nt/1.0" xmlns:fn="http://www.w3.org/2005/xpath-functions" + xmlns:xs="http://www.w3.org/2001/XMLSchema" xmlns:sv="http://www.jcp.org/jcr/sv/1.0" + xmlns:fn_old="http://www.w3.org/2004/10/xpath-functions" xmlns:jcrfn="http://www.jcp.org/jcr/xpath-functions/1.0"> + <sv:property sv:name="jcr:primaryType" sv:type="Name"> + <sv:value>mgnl:contentNode</sv:value> + </sv:property> + <sv:property sv:name="jcr:uuid" sv:type="String"> + <sv:value>6df4c72d-f71e-4a9d-a71b-11f7632a4fc9</sv:value> + </sv:property> + <sv:property sv:name="class" sv:type="String"> + <sv:value>info.magnolia.module.admininterface.AdminTreeMVCHandler</sv:value> + </sv:property> + <sv:property sv:name="configurationClass" sv:type="String"> + <sv:value>net.sourceforge.openutils.mgnlmedia.media.tree.MediaBrowserConfiguration</sv:value> + </sv:property> + <sv:property sv:name="i18nBasename" sv:type="String"> + <sv:value>net.sourceforge.openutils.mgnlmedia.media.lang.messages</sv:value> + </sv:property> + <sv:property sv:name="repository" sv:type="String"> + <sv:value>media</sv:value> + </sv:property> + <sv:node sv:name="MetaData"> + <sv:property sv:name="jcr:primaryType" sv:type="Name"> + <sv:value>mgnl:metaData</sv:value> + </sv:property> + <sv:property sv:name="mgnl:Data" sv:type="String"> + <sv:value>MetaData</sv:value> + </sv:property> + <sv:property sv:name="mgnl:activated" sv:type="Boolean"> + <sv:value>false</sv:value> + </sv:property> + <sv:property sv:name="mgnl:activatorid" sv:type="String"> + <sv:value>superuser</sv:value> + </sv:property> + <sv:property sv:name="mgnl:authorid" sv:type="String"> + <sv:value>admin</sv:value> + </sv:property> + <sv:property sv:name="mgnl:creationdate" sv:type="Date"> + <sv:value>2005-05-06T16:18:38.686+02:00</sv:value> + </sv:property> + <sv:property sv:name="mgnl:lastaction" sv:type="Date"> + <sv:value>2008-06-20T12:14:54.070Z</sv:value> + </sv:property> + <sv:property sv:name="mgnl:lastmodified" sv:type="Date"> + <sv:value>2009-06-02T19:20:17.371+02:00</sv:value> + </sv:property> + </sv:node> +</sv:node> Property changes on: trunk/openutils-mgnlmedia/src/main/resources/mgnl-bootstrap/media/config.modules.media.trees.media-selector.xml ___________________________________________________________________ Added: svn:mime-type + text/plain Added: svn:keywords + Author Date Id Revision Added: svn:eol-style + native Modified: trunk/openutils-mgnlmedia/src/main/resources/mgnl-bootstrap/media/config.server.URI2RepositoryMapping.mappings.media.xml =================================================================== --- trunk/openutils-mgnlmedia/src/main/resources/mgnl-bootstrap/media/config.server.URI2RepositoryMapping.mappings.media.xml 2009-06-04 09:38:57 UTC (rev 1221) +++ trunk/openutils-mgnlmedia/src/main/resources/mgnl-bootstrap/media/config.server.URI2RepositoryMapping.mappings.media.xml 2009-06-04 09:39:32 UTC (rev 1222) @@ -1,5 +1,5 @@ <?xml version="1.0" encoding="UTF-8"?> -<sv:node sv:name="media" +<sv:node sv:name="media" xmlns:jcr="http://www.jcp.org/jcr/1.0" xmlns:mgnl="http://www.magnolia.info/jcr/mgnl" xmlns:rep="internal" xmlns:mix="http://www.jcp.org/jcr/mix/1.0" xmlns:nt="http://www.jcp.org/jcr/nt/1.0" xmlns:fn="http://www.w3.org/2005/xpath-functions" @@ -14,6 +14,9 @@ <sv:property sv:name="URIPrefix" sv:type="String"> <sv:value>/mediaObject</sv:value> </sv:property> + <sv:property sv:name="class" sv:type="String"> + <sv:value>net.sourceforge.openutils.mgnlmedia.media.uri.MediaURI2RepositoryMapping</sv:value> + </sv:property> <sv:property sv:name="handlePrefix" sv:type="String"> <sv:value/> </sv:property> Modified: trunk/openutils-mgnlmedia/src/site/changes/changes.xml =================================================================== --- trunk/openutils-mgnlmedia/src/site/changes/changes.xml 2009-06-04 09:38:57 UTC (rev 1221) +++ trunk/openutils-mgnlmedia/src/site/changes/changes.xml 2009-06-04 09:39:32 UTC (rev 1222) @@ -11,6 +11,10 @@ <release version="4.0-b5" date="in svn" description=""> <action type="fix" dev="fgiust">MediaCustomSaveHandler now only warns about missing referenced media without blocking</action> + <action type="fix" dev="fgiust">Media jcr browser was displying duplicate nodes</action> + <action type="add" dev="fgiust">Fckeditor integration for creating links to objects in the media repository. + Requires the fix for MAGNOLIA-2759 to be applied to work (hopefully it will work out-of-the-box only starting + from magnolia 4.1.1)</action> </release> <release version="4.0-b4" date="2009-04-29" description=""> <action type="update" dev="fgiust">YouTubeVideoTypeHandler modified in order to work with generic external urls (not This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <fg...@us...> - 2009-08-12 16:20:54
|
Revision: 1256 http://openutils.svn.sourceforge.net/openutils/?rev=1256&view=rev Author: fgiust Date: 2009-08-12 16:20:46 +0000 (Wed, 12 Aug 2009) Log Message: ----------- Avoid image processing when the requested size is identical to the original image Modified Paths: -------------- trunk/openutils-mgnlmedia/src/main/java/net/sourceforge/openutils/mgnlmedia/media/tags/el/MediaEl.java trunk/openutils-mgnlmedia/src/main/java/net/sourceforge/openutils/mgnlmedia/media/utils/ImageUtils.java trunk/openutils-mgnlmedia/src/site/changes/changes.xml Modified: trunk/openutils-mgnlmedia/src/main/java/net/sourceforge/openutils/mgnlmedia/media/tags/el/MediaEl.java =================================================================== --- trunk/openutils-mgnlmedia/src/main/java/net/sourceforge/openutils/mgnlmedia/media/tags/el/MediaEl.java 2009-08-12 14:26:58 UTC (rev 1255) +++ trunk/openutils-mgnlmedia/src/main/java/net/sourceforge/openutils/mgnlmedia/media/tags/el/MediaEl.java 2009-08-12 16:20:46 UTC (rev 1256) @@ -24,6 +24,7 @@ import info.magnolia.cms.util.NodeDataUtil; import info.magnolia.context.MgnlContext; +import java.awt.Point; import java.util.ArrayList; import java.util.Collection; import java.util.Collections; @@ -273,6 +274,15 @@ */ public static String getResolutionUrl(Content media, String resolution) { + FileProperties prop = new FileProperties(media, "image"); + Integer width = NumberUtils.toInt(prop.getProperty(FileProperties.PROPERTY_WIDTH)); + Integer height = NumberUtils.toInt(prop.getProperty(FileProperties.PROPERTY_HEIGHT)); + Point size = ImageUtils.parseForSize(resolution); + if (width == size.x && height == size.y) + { + return mcm.getURIMappingPrefix() + prop.getProperty(FileProperties.PATH); + } + if (media == null || !ImageUtils.checkOrCreateResolution(media, resolution)) { return null; 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 2009-08-12 14:26:58 UTC (rev 1255) +++ trunk/openutils-mgnlmedia/src/main/java/net/sourceforge/openutils/mgnlmedia/media/utils/ImageUtils.java 2009-08-12 16:20:46 UTC (rev 1256) @@ -1,3 +1,5 @@ +package net.sourceforge.openutils.mgnlmedia.media.utils; + /** * Copyright Openmind http://www.openmindonline.it * @@ -15,7 +17,6 @@ * along with this program. If not, see <http://www.gnu.org/licenses/>. * */ -package net.sourceforge.openutils.mgnlmedia.media.utils; import info.magnolia.cms.beans.runtime.FileProperties; import info.magnolia.cms.core.Content; @@ -27,6 +28,7 @@ import java.awt.Color; import java.awt.Graphics2D; import java.awt.Image; +import java.awt.Point; import java.awt.RenderingHints; import java.awt.geom.RoundRectangle2D; import java.awt.image.BufferedImage; @@ -254,6 +256,13 @@ double xRatio = (double) x / oX; double yRatio = (double) y / oY; + + if (xRatio * yRatio == 1) + { + log.debug("Nothing to resize, return original"); + return original; + } + double ratio = Math.min(xRatio, yRatio); int newX = (int) Math.round(oX * ratio); int newY = (int) Math.round(oY * ratio); @@ -289,7 +298,8 @@ } else { - return resizeImage(original, x, y); + return original; + // return resizeImage(original, x, y); } } @@ -654,20 +664,14 @@ String controlChar = StringUtils.substring(resolution, 0, 1); + Point size = parseForSize(resolution); + if ("<".equals(controlChar) || "l".equals(controlChar)) { - String resx = resolution.startsWith("<") ? StringUtils.substringBefore(StringUtils.substringAfter( - resolution, - "<"), "x") : StringUtils.substringBefore(StringUtils.substringAfter(resolution, "l"), "x"); - String resy = StringUtils.substringAfter(resolution, "x"); - - img = fitIn(original, NumberUtils.toInt(resx), NumberUtils.toInt(resy)); + img = fitIn(original, size.x, size.y); } else if (resolution.startsWith("o")) { - String resx = StringUtils.substringBefore(StringUtils.substringAfter(resolution, "o"), "x"); - String resy = StringUtils.substringAfter(resolution, "x"); - Color background = null; if (StringUtils.contains(params, "background=")) @@ -682,21 +686,12 @@ log.error("Invalid color code: " + colorHex, e); } } - - img = resizeNoCrop(original, NumberUtils.toInt(resx), NumberUtils.toInt(resy), background); + img = resizeNoCrop(original, size.x, size.y, background); } else { - String resx = StringUtils.substringBefore(resolution, "x"); - String resy = StringUtils.substringAfter(resolution, "x"); - - if (resx.charAt(0) < '0' || resx.charAt(0) > '9') - { - resx = resx.substring(1); - } - - img = fillAndCropCentered(original, NumberUtils.toInt(resx), NumberUtils.toInt(resy)); + img = fillAndCropCentered(original, size.x, size.y); } return img; @@ -747,4 +742,43 @@ } } + public static java.awt.Point parseForSize(String res) + { + Point size = new Point(); + String resolution = StringUtils.lowerCase(res); + String resx, resy; + + if (StringUtils.contains(resolution, ";")) + { + resolution = StringUtils.substringBefore(resolution, ";"); + } + String controlChar = StringUtils.substring(resolution, 0, 1); + + if ("<".equals(controlChar) || "l".equals(controlChar)) + { + resx = resolution.startsWith("<") ? StringUtils.substringBefore( + StringUtils.substringAfter(resolution, "<"), + "x") : StringUtils.substringBefore(StringUtils.substringAfter(resolution, "l"), "x"); + resy = StringUtils.substringAfter(resolution, "x"); + } + else if (resolution.startsWith("o")) + { + resx = StringUtils.substringBefore(StringUtils.substringAfter(resolution, "o"), "x"); + resy = StringUtils.substringAfter(resolution, "x"); + } + else + { + resx = StringUtils.substringBefore(resolution, "x"); + resy = StringUtils.substringAfter(resolution, "x"); + + if (resx.charAt(0) < '0' || resx.charAt(0) > '9') + { + resx = resx.substring(1); + } + } + size.x = NumberUtils.toInt(resx); + size.y = NumberUtils.toInt(resy); + return size; + } + } Modified: trunk/openutils-mgnlmedia/src/site/changes/changes.xml =================================================================== --- trunk/openutils-mgnlmedia/src/site/changes/changes.xml 2009-08-12 14:26:58 UTC (rev 1255) +++ trunk/openutils-mgnlmedia/src/site/changes/changes.xml 2009-08-12 16:20:46 UTC (rev 1256) @@ -8,6 +8,10 @@ <author email="fgiust(at)users.sourceforge.net">Fabrizio Giustina</author> </properties> <body> + <release version="4.0-b6" date="in svn" description=""> + <action type="fix" dev="fgiust">Avoid image processing when the requested size is identical to the original image + </action> + </release> <release version="4.0-b5" date="2009-06-04" description=""> <action type="fix" dev="fgiust">MediaCustomSaveHandler now only warns about missing referenced media without blocking</action> @@ -28,7 +32,8 @@ <action type="update" dev="fgiust">Update openutils-mgnltasks dependency to 4.0</action> <action type="add" dev="fgiust">Support for resize without crop to a fixed size with borders. Background color can be specified with the syntax: "o100x100;background=FF0096"</action> - <action type="add" dev="fgiust">Alternative prefix for "fit in" resize. In previous versions you had to use < (not very handy in html), now you can use "L" (lower, case insensitive), e.g. "L100x100"</action> + <action type="add" dev="fgiust">Alternative prefix for "fit in" resize. In previous versions you had to use < + (not very handy in html), now you can use "L" (lower, case insensitive), e.g. "L100x100"</action> </release> <release version="4.0-b2" date="2009-04-16" description=""> <action type="update" dev="fgiust">Stable release for Magnolia 4.x</action> This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <mol...@us...> - 2009-09-04 16:15:34
|
Revision: 1361 http://openutils.svn.sourceforge.net/openutils/?rev=1361&view=rev Author: molaschi Date: 2009-09-04 16:15:19 +0000 (Fri, 04 Sep 2009) Log Message: ----------- Deep refactor of simplemedia module: - refactoring media types for better OO design - add OO architecture for resolution handling - add OO architecture for image post processing - rename all nodedata properties in which was stored the base media to from "image","video","audio" to "original" - added a new DialogFileNoPreview which doesn't show media preview but shows media download, shows a list of accepted file extensions and validates the file extension to be in this list - removed mgnl-messages - fix tests Modified Paths: -------------- trunk/openutils-mgnlmedia/src/main/java/net/sourceforge/openutils/mgnlmedia/media/configuration/MediaConfigurationManager.java trunk/openutils-mgnlmedia/src/main/java/net/sourceforge/openutils/mgnlmedia/media/dialog/DialogFileAudio.java trunk/openutils-mgnlmedia/src/main/java/net/sourceforge/openutils/mgnlmedia/media/dialog/LayerDialogMVC.java trunk/openutils-mgnlmedia/src/main/java/net/sourceforge/openutils/mgnlmedia/media/lifecycle/MediaModule.java trunk/openutils-mgnlmedia/src/main/java/net/sourceforge/openutils/mgnlmedia/media/save/MediaCustomSaveHandler.java trunk/openutils-mgnlmedia/src/main/java/net/sourceforge/openutils/mgnlmedia/media/setup/MediaModuleVersionHandler.java trunk/openutils-mgnlmedia/src/main/java/net/sourceforge/openutils/mgnlmedia/media/tags/el/MediaEl.java trunk/openutils-mgnlmedia/src/main/java/net/sourceforge/openutils/mgnlmedia/media/types/MediaTypeHandler.java trunk/openutils-mgnlmedia/src/main/java/net/sourceforge/openutils/mgnlmedia/media/types/impl/AudioTypeHandler.java trunk/openutils-mgnlmedia/src/main/java/net/sourceforge/openutils/mgnlmedia/media/types/impl/BaseTypeHandler.java trunk/openutils-mgnlmedia/src/main/java/net/sourceforge/openutils/mgnlmedia/media/types/impl/ImageTypeHandler.java trunk/openutils-mgnlmedia/src/main/java/net/sourceforge/openutils/mgnlmedia/media/types/impl/VideoTypeHandler.java trunk/openutils-mgnlmedia/src/main/java/net/sourceforge/openutils/mgnlmedia/media/types/impl/YouTubeVideoTypeHandler.java trunk/openutils-mgnlmedia/src/main/java/net/sourceforge/openutils/mgnlmedia/media/utils/ImageUtils.java trunk/openutils-mgnlmedia/src/main/resources/mgnl-bootstrap/media/config.modules.media.dialogs.mediaAudioDlg.xml trunk/openutils-mgnlmedia/src/main/resources/mgnl-bootstrap/media/config.modules.media.dialogs.mediaImageDlg.xml trunk/openutils-mgnlmedia/src/main/resources/mgnl-bootstrap/media/config.modules.media.dialogs.mediaVideoDlg.xml trunk/openutils-mgnlmedia/src/main/resources/mgnl-bootstrap/media/config.modules.media.dialogs.mediaYoutubeDlg.xml trunk/openutils-mgnlmedia/src/main/resources/mgnl-bootstrap/media/config.modules.media.mediatypes.audio.xml trunk/openutils-mgnlmedia/src/main/resources/mgnl-bootstrap/media/config.modules.media.mediatypes.image.xml trunk/openutils-mgnlmedia/src/main/resources/mgnl-bootstrap/media/config.modules.media.mediatypes.video.xml trunk/openutils-mgnlmedia/src/main/resources/mgnl-bootstrap/media/config.modules.media.mediatypes.youtube.xml trunk/openutils-mgnlmedia/src/main/resources/net/sourceforge/openutils/mgnlmedia/media/lang/messages_en.properties trunk/openutils-mgnlmedia/src/main/resources/net/sourceforge/openutils/mgnlmedia/media/lang/messages_it.properties trunk/openutils-mgnlmedia/src/test/java/net/sourceforge/openutils/mgnlmedia/media/utils/ImageUtilsTest.java Added Paths: ----------- trunk/openutils-mgnlmedia/src/main/java/META-INF/ trunk/openutils-mgnlmedia/src/main/java/META-INF/MANIFEST.MF trunk/openutils-mgnlmedia/src/main/java/net/sourceforge/openutils/mgnlmedia/media/configuration/ImageProcessorsManager.java trunk/openutils-mgnlmedia/src/main/java/net/sourceforge/openutils/mgnlmedia/media/dialog/DialogFileNoPreview.java trunk/openutils-mgnlmedia/src/main/java/net/sourceforge/openutils/mgnlmedia/media/processors/ trunk/openutils-mgnlmedia/src/main/java/net/sourceforge/openutils/mgnlmedia/media/processors/BaseImageResolutionProcessor.java trunk/openutils-mgnlmedia/src/main/java/net/sourceforge/openutils/mgnlmedia/media/processors/FitInAndFillWithBandsImageResolutionProcessor.java trunk/openutils-mgnlmedia/src/main/java/net/sourceforge/openutils/mgnlmedia/media/processors/FitInImageResolutionProcessor.java trunk/openutils-mgnlmedia/src/main/java/net/sourceforge/openutils/mgnlmedia/media/processors/ImagePostProcessor.java trunk/openutils-mgnlmedia/src/main/java/net/sourceforge/openutils/mgnlmedia/media/processors/ImageResolutionProcessor.java trunk/openutils-mgnlmedia/src/main/java/net/sourceforge/openutils/mgnlmedia/media/processors/LogSizePostProcessor.java trunk/openutils-mgnlmedia/src/main/java/net/sourceforge/openutils/mgnlmedia/media/processors/ResizeCropCenteredImageResolutionProcessor.java trunk/openutils-mgnlmedia/src/main/java/net/sourceforge/openutils/mgnlmedia/media/processors/ResizeNoCropImageResolutionProcessor.java trunk/openutils-mgnlmedia/src/main/java/net/sourceforge/openutils/mgnlmedia/media/types/impl/MediaWithPreviewImageTypeHandler.java trunk/openutils-mgnlmedia/src/main/resources/mgnl-bootstrap/media/config.modules.media.controls.mediaFile.xml trunk/openutils-mgnlmedia/src/main/resources/mgnl-bootstrap/media/config.modules.media.processors.image-post.logsize.xml trunk/openutils-mgnlmedia/src/main/resources/mgnl-bootstrap/media/config.modules.media.processors.image-resolution.b.xml trunk/openutils-mgnlmedia/src/main/resources/mgnl-bootstrap/media/config.modules.media.processors.image-resolution.default.xml trunk/openutils-mgnlmedia/src/main/resources/mgnl-bootstrap/media/config.modules.media.processors.image-resolution.l.xml trunk/openutils-mgnlmedia/src/main/resources/mgnl-bootstrap/media/config.modules.media.processors.image-resolution.x.xml trunk/openutils-mgnlmedia/src/test/java/net/sourceforge/openutils/mgnlmedia/media/utils/ImageProcessorsManagerMock.java Removed Paths: ------------- trunk/openutils-mgnlmedia/src/main/resources/mgnl-messages/ Added: trunk/openutils-mgnlmedia/src/main/java/META-INF/MANIFEST.MF =================================================================== --- trunk/openutils-mgnlmedia/src/main/java/META-INF/MANIFEST.MF (rev 0) +++ trunk/openutils-mgnlmedia/src/main/java/META-INF/MANIFEST.MF 2009-09-04 16:15:19 UTC (rev 1361) @@ -0,0 +1,3 @@ +Manifest-Version: 1.0 +Class-Path: + Added: trunk/openutils-mgnlmedia/src/main/java/net/sourceforge/openutils/mgnlmedia/media/configuration/ImageProcessorsManager.java =================================================================== --- trunk/openutils-mgnlmedia/src/main/java/net/sourceforge/openutils/mgnlmedia/media/configuration/ImageProcessorsManager.java (rev 0) +++ trunk/openutils-mgnlmedia/src/main/java/net/sourceforge/openutils/mgnlmedia/media/configuration/ImageProcessorsManager.java 2009-09-04 16:15:19 UTC (rev 1361) @@ -0,0 +1,176 @@ +package net.sourceforge.openutils.mgnlmedia.media.configuration; + +import info.magnolia.cms.beans.config.ObservedManager; +import info.magnolia.cms.core.Content; +import info.magnolia.cms.util.ContentUtil; +import info.magnolia.cms.util.FactoryUtil; +import info.magnolia.cms.util.NodeDataUtil; + +import java.util.Collection; +import java.util.HashMap; +import java.util.Iterator; +import java.util.Map; + +import javax.jcr.RepositoryException; + +import net.sourceforge.openutils.mgnlmedia.media.processors.ImagePostProcessor; +import net.sourceforge.openutils.mgnlmedia.media.processors.ImageResolutionProcessor; + +import org.apache.commons.lang.StringUtils; + + +/** + * @author molaschi + * @version $Id: $ + */ +public class ImageProcessorsManager extends ObservedManager +{ + + private static final String IMAGE_RESOLUTION_PROCESSORS_NAME = "image-resolution"; + + private static final String IMAGE_POST_PROCESSORS_NAME = "image-post"; + + private Map<String, ImageResolutionProcessor> imageResProcs = new HashMap<String, ImageResolutionProcessor>(); + + private Map<String, ImagePostProcessor> imagePostProcs = new HashMap<String, ImagePostProcessor>(); + + public static ImageProcessorsManager getInstance() + { + return (ImageProcessorsManager) FactoryUtil.getSingleton(ImageProcessorsManager.class); + } + + /** + * {@inheritDoc} + */ + @Override + protected void onClear() + { + imageResProcs.clear(); + imagePostProcs.clear(); + } + + /** + * {@inheritDoc} + */ + @Override + protected void onRegister(Content parentNode) + { + for (Iterator iter = ContentUtil.getAllChildren(parentNode).iterator(); iter.hasNext();) + { + Content processorsNode = (Content) iter.next(); + + for (Iterator iterProcessor = ContentUtil.getAllChildren(processorsNode).iterator(); iterProcessor + .hasNext();) + { + Content node = (Content) iterProcessor.next(); + + try + { + + if (IMAGE_POST_PROCESSORS_NAME.equals(processorsNode.getName())) + { + String classNameHandler = NodeDataUtil.getString(node, "class"); + Class classHandler = Class.forName(classNameHandler); + if (!ImagePostProcessor.class.isAssignableFrom(classHandler)) + { + log.error( + "Error getting post processor for {}: class {} not implements ImagePostProcessor", + node.getHandle(), + classHandler); + continue; + } + + ImagePostProcessor imagePostProcessor = (ImagePostProcessor) classHandler.newInstance(); + imagePostProcs.put(node.getName(), imagePostProcessor); + } + + if (IMAGE_RESOLUTION_PROCESSORS_NAME.equals(processorsNode.getName())) + { + String controlChar = node.getName(); + + String classNameHandler = NodeDataUtil.getString(node, "class"); + Class classHandler = Class.forName(classNameHandler); + if (!ImageResolutionProcessor.class.isAssignableFrom(classHandler)) + { + log + .error( + "Error getting resolution processor for {}: class {} not implements ImageResolutionProcessor", + node.getHandle(), + classHandler); + continue; + } + + ImageResolutionProcessor imageResolutionProcessor = (ImageResolutionProcessor) classHandler + .newInstance(); + if (!controlChar.equals("default")) + { + controlChar = controlChar.substring(0, 1); + } + imageResProcs.put(controlChar, imageResolutionProcessor); + try + { + if (node.hasNodeData("aliases")) + { + String[] aliases = StringUtils.split(NodeDataUtil.getString(node, "aliases"), ","); + for (String alias : aliases) + { + imageResProcs.put(alias, imageResolutionProcessor); + } + } + } + catch (RepositoryException ex) + { + // go on + } + } + } + catch (InstantiationException ex) + { + log.error("Error getting media type configuration for {}", node.getHandle(), ex); + } + catch (IllegalAccessException ex) + { + log.error("Error getting media type configuration for {}", node.getHandle(), ex); + } + catch (ClassNotFoundException ex) + { + log.error("Error getting media type configuration for {}", node.getHandle(), ex); + } + catch (RuntimeException ex) + { + log.error("Error getting media type configuration for {}", node.getHandle(), ex); + } + } + } + } + + public ImageResolutionProcessor getImageResolutionProcessor(char controlChar) + { + return imageResProcs.get(String.valueOf(controlChar)); + } + + public boolean isValidControlChar(char controlChar) + { + return imageResProcs.keySet().contains(String.valueOf(controlChar)); + } + + public ImageResolutionProcessor getDefaultImageResolutionProcessor() + { + return imageResProcs.get("default"); + } + + public ImagePostProcessor getImagePostProcessor(String name) + { + return imagePostProcs.get(name); + } + + public Collection<ImagePostProcessor> getImagePostProcessorsList() + { + return imagePostProcs.values(); + } + + public Map<String, ImagePostProcessor> getImagePostProcessorsMap() + { + return imagePostProcs; + } +} Modified: trunk/openutils-mgnlmedia/src/main/java/net/sourceforge/openutils/mgnlmedia/media/configuration/MediaConfigurationManager.java =================================================================== --- trunk/openutils-mgnlmedia/src/main/java/net/sourceforge/openutils/mgnlmedia/media/configuration/MediaConfigurationManager.java 2009-09-04 14:44:47 UTC (rev 1360) +++ trunk/openutils-mgnlmedia/src/main/java/net/sourceforge/openutils/mgnlmedia/media/configuration/MediaConfigurationManager.java 2009-09-04 16:15:19 UTC (rev 1361) @@ -48,6 +48,7 @@ import net.sourceforge.openutils.mgnlmedia.media.lifecycle.MediaModule; import net.sourceforge.openutils.mgnlmedia.media.pages.MediaFolderViewPage; +import net.sourceforge.openutils.mgnlmedia.media.processors.ImageResolutionProcessor; import net.sourceforge.openutils.mgnlmedia.media.types.MediaTypeHandler; import org.apache.commons.collections.CollectionUtils; Modified: trunk/openutils-mgnlmedia/src/main/java/net/sourceforge/openutils/mgnlmedia/media/dialog/DialogFileAudio.java =================================================================== --- trunk/openutils-mgnlmedia/src/main/java/net/sourceforge/openutils/mgnlmedia/media/dialog/DialogFileAudio.java 2009-09-04 14:44:47 UTC (rev 1360) +++ trunk/openutils-mgnlmedia/src/main/java/net/sourceforge/openutils/mgnlmedia/media/dialog/DialogFileAudio.java 2009-09-04 16:15:19 UTC (rev 1361) @@ -28,6 +28,8 @@ import javax.jcr.PropertyType; +import org.apache.commons.lang.StringUtils; + import net.sourceforge.openutils.mgnlmedia.media.configuration.MediaConfigurationManager; @@ -45,7 +47,11 @@ @Override public void initImageExtensions() { - this.getImageExtensions().add("mp3"); + String extensions = this.getConfigValue("extensions"); + for (String extension : StringUtils.split(extensions, ",")) + { + this.getImageExtensions().add(extension); + } } /** Added: trunk/openutils-mgnlmedia/src/main/java/net/sourceforge/openutils/mgnlmedia/media/dialog/DialogFileNoPreview.java =================================================================== --- trunk/openutils-mgnlmedia/src/main/java/net/sourceforge/openutils/mgnlmedia/media/dialog/DialogFileNoPreview.java (rev 0) +++ trunk/openutils-mgnlmedia/src/main/java/net/sourceforge/openutils/mgnlmedia/media/dialog/DialogFileNoPreview.java 2009-09-04 16:15:19 UTC (rev 1361) @@ -0,0 +1,122 @@ +package net.sourceforge.openutils.mgnlmedia.media.dialog; + +import info.magnolia.cms.beans.runtime.Document; +import info.magnolia.cms.beans.runtime.MultipartForm; +import info.magnolia.cms.gui.dialog.DialogFile; +import info.magnolia.cms.gui.misc.Spacer; +import info.magnolia.cms.i18n.Messages; +import info.magnolia.cms.i18n.MessagesManager; +import info.magnolia.cms.i18n.MessagesUtil; + +import java.io.IOException; +import java.io.Writer; + +import org.apache.commons.lang.StringUtils; + + +/** + * @author molaschi + * @version $Id: $ + */ +public class DialogFileNoPreview extends DialogFile +{ + + private final String i18nBasename = "net.sourceforge.openutils.mgnlmedia.media.lang.messages"; + + private Messages messages; + + /** + * {@inheritDoc} + */ + @Override + public void drawHtml(Writer out) throws IOException + { + this.getImageExtensions().clear(); + this.setConfig("preview", false); + super.drawHtml(out); + } + + /** + * {@inheritDoc} + */ + @Override + public void drawHtmlPre(Writer out) throws IOException + { + super.drawHtmlPre(out); + String extensions = this.getConfigValue("extensions"); + if (StringUtils.isNotBlank(extensions)) + { + StringBuffer sb = new StringBuffer(); + sb + .append("<span class=\"mgnlDialogDescription\">") + .append(getMessage("dialog.filenopreview.extensions")) + .append(" ") + .append(extensions) + .append("</span>") + .append(Spacer.getHtml(0, 0)); + out.write(sb.toString()); + } + } + + /** + * {@inheritDoc} + */ + @Override + public boolean validate() + { + boolean valid = super.validate(); + if (valid) + { + MultipartForm form = (MultipartForm) getRequest().getAttribute(MultipartForm.REQUEST_ATTRIBUTE_NAME); + if (form != null) + { + Document doc = form.getDocument(getName()); + String extensions = this.getConfigValue("extensions"); + if (StringUtils.isNotBlank(extensions)) + { + String[] allowedExtensions = StringUtils.split(extensions, ','); + for (String allowedExtension : allowedExtensions) + { + if (StringUtils.trimToEmpty(allowedExtension).equals(doc.getExtension())) + { + return true; + } + + } + + setValidationMessage(getMessage("dialog.filenopreview.error.extension")); + return false; + } + // String extensions = doc.getExtension(); + } + } + return valid; + } + + @Override + protected Messages getMessages() + { + if (messages == null) + { + // if this is the root + if (this.getParent() == null) + { + messages = MessagesManager.getMessages(); + } + else + { + // try to get it from the control nearest to the root + messages = super.getMessages(); + } + // if this control defines a bundle (basename in the terms of jstl) + String basename = this.getConfigValue("i18nBasename", i18nBasename); + if (StringUtils.isNotEmpty(basename)) + { + // extend the chain with this bundle + messages = MessagesUtil.chain(basename, messages); + } + } + return messages; + } + +} Modified: trunk/openutils-mgnlmedia/src/main/java/net/sourceforge/openutils/mgnlmedia/media/dialog/LayerDialogMVC.java =================================================================== --- trunk/openutils-mgnlmedia/src/main/java/net/sourceforge/openutils/mgnlmedia/media/dialog/LayerDialogMVC.java 2009-09-04 14:44:47 UTC (rev 1360) +++ trunk/openutils-mgnlmedia/src/main/java/net/sourceforge/openutils/mgnlmedia/media/dialog/LayerDialogMVC.java 2009-09-04 16:15:19 UTC (rev 1361) @@ -155,8 +155,7 @@ @Override protected boolean onPreSave(SaveHandler control) { - // TODO non mi piace molto... - String type = form.getParameter("type"); + String type = this.request.getParameter("type"); if (control.getNodeName().equals("mgnlNew")) { @@ -176,7 +175,7 @@ .getTypes() .get(type) .getHandler() - .getNewNodeName(form)))); + .getNewNodeName(form, request)))); } return super.onPreSave(control); Modified: trunk/openutils-mgnlmedia/src/main/java/net/sourceforge/openutils/mgnlmedia/media/lifecycle/MediaModule.java =================================================================== --- trunk/openutils-mgnlmedia/src/main/java/net/sourceforge/openutils/mgnlmedia/media/lifecycle/MediaModule.java 2009-09-04 14:44:47 UTC (rev 1360) +++ trunk/openutils-mgnlmedia/src/main/java/net/sourceforge/openutils/mgnlmedia/media/lifecycle/MediaModule.java 2009-09-04 16:15:19 UTC (rev 1361) @@ -19,6 +19,7 @@ import info.magnolia.module.ModuleLifecycle; import info.magnolia.module.ModuleLifecycleContext; +import net.sourceforge.openutils.mgnlmedia.media.configuration.ImageProcessorsManager; import net.sourceforge.openutils.mgnlmedia.media.configuration.MediaConfigurationManager; import org.slf4j.Logger; @@ -59,6 +60,7 @@ { log.info("Starting module media"); ctx.registerModuleObservingComponent("mediatypes", MediaConfigurationManager.getInstance()); + ctx.registerModuleObservingComponent("processors", ImageProcessorsManager.getInstance()); } /** Added: trunk/openutils-mgnlmedia/src/main/java/net/sourceforge/openutils/mgnlmedia/media/processors/BaseImageResolutionProcessor.java =================================================================== --- trunk/openutils-mgnlmedia/src/main/java/net/sourceforge/openutils/mgnlmedia/media/processors/BaseImageResolutionProcessor.java (rev 0) +++ trunk/openutils-mgnlmedia/src/main/java/net/sourceforge/openutils/mgnlmedia/media/processors/BaseImageResolutionProcessor.java 2009-09-04 16:15:19 UTC (rev 1361) @@ -0,0 +1,109 @@ +package net.sourceforge.openutils.mgnlmedia.media.processors; + +import java.awt.Color; +import java.awt.image.BufferedImage; + +import net.sourceforge.openutils.mgnlmedia.media.utils.ImageUtils; + +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + + +/** + * @author molaschi + * @version $Id: $ + */ +public abstract class BaseImageResolutionProcessor implements ImageResolutionProcessor +{ + + /** + * Logger. + */ + private Logger log = LoggerFactory.getLogger(BaseImageResolutionProcessor.class); + + /** + * Resize an image to fit into x,y not changing x/y + * @param original original image + * @param x max width + * @param y max height + * @return resized image + */ + public BufferedImage fitIn(BufferedImage original, int x, int y) + { + return resizeInOut(original, x, y, false, null); + } + + public BufferedImage resizeNoCrop(BufferedImage original, int x, int y) + { + return resizeInOut(original, x, y, true, null); + } + + public BufferedImage resizeNoCrop(BufferedImage original, int x, int y, Color background) + { + return resizeInOut(original, x, y, true, background); + } + + protected BufferedImage resizeInOut(BufferedImage original, int x, int y, boolean external, Color background) + { + if (original == null) + { + throw new IllegalArgumentException("input image is null"); + } + + float oX = original.getWidth(); + float oY = original.getHeight(); + + if (oX < 1 || oY < 1) + { + throw new IllegalArgumentException("Broken input image (width=" + oX + ",height=" + oY + ")"); + } + + double xRatio = (double) x / oX; + double yRatio = (double) y / oY; + + if (xRatio * yRatio == 1) + { + log.debug("Nothing to resize, return original"); + return original; + } + + double ratio = Math.min(xRatio, yRatio); + int newX = (int) Math.round(oX * ratio); + int newY = (int) Math.round(oY * ratio); + + return ImageUtils.resizeImage(original, newX, newY, external ? x : newX, external ? y : newY, background); + } + + /** + * Resize an image to fill x or y and (if set) center and crop what is out + * @param original original image + * @param x min width + * @param y min height + * @param cropCentered crop image + * @return resized image + */ + public BufferedImage fill(BufferedImage original, int x, int y, boolean cropCentered) + { + float oX = original.getWidth(); + float oY = original.getHeight(); + float oDelta = oX / oY; + float delta = ((float) x) / ((float) y); + + if (oDelta > delta) + { + int newX = (int) (y * oX / oY); + BufferedImage filled = ImageUtils.resizeImage(original, newX, y); + return cropCentered ? ImageUtils.cropImage(filled, (newX - x) / 2, 0, x, y) : filled; + } + else if (oDelta < delta) + { + int newY = (int) (x * oY / oX); + BufferedImage filled = ImageUtils.resizeImage(original, x, newY); + return cropCentered ? ImageUtils.cropImage(filled, 0, (newY - y) / 2, x, y) : filled; + } + else + { + return original; + } + } +} Added: trunk/openutils-mgnlmedia/src/main/java/net/sourceforge/openutils/mgnlmedia/media/processors/FitInAndFillWithBandsImageResolutionProcessor.java =================================================================== --- trunk/openutils-mgnlmedia/src/main/java/net/sourceforge/openutils/mgnlmedia/media/processors/FitInAndFillWithBandsImageResolutionProcessor.java (rev 0) +++ trunk/openutils-mgnlmedia/src/main/java/net/sourceforge/openutils/mgnlmedia/media/processors/FitInAndFillWithBandsImageResolutionProcessor.java 2009-09-04 16:15:19 UTC (rev 1361) @@ -0,0 +1,46 @@ +package net.sourceforge.openutils.mgnlmedia.media.processors; + +import java.awt.Color; +import java.awt.image.BufferedImage; +import java.util.Map; + +import org.apache.commons.lang.StringUtils; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + + +/** + * @author molaschi + * @version $Id: $ + */ +public class FitInAndFillWithBandsImageResolutionProcessor extends BaseImageResolutionProcessor +{ + + /** + * Logger. + */ + private Logger log = LoggerFactory.getLogger(FitInAndFillWithBandsImageResolutionProcessor.class); + + /** + * {@inheritDoc} + */ + public BufferedImage getImageForResolution(BufferedImage original, int x, int y, Map<String, String> parameters) + { + Color color = Color.WHITE; + String hexColor = parameters.get("background"); + + if (StringUtils.isNotBlank(hexColor)) + { + try + { + hexColor = "0x" + (hexColor.startsWith("#") ? hexColor.substring(1) : hexColor); + color = Color.decode(hexColor); + } + catch (NumberFormatException e) + { + log.error("Invalid color code: " + hexColor, e); + } + } + return resizeInOut(original, x, y, false, color); + } +} Added: trunk/openutils-mgnlmedia/src/main/java/net/sourceforge/openutils/mgnlmedia/media/processors/FitInImageResolutionProcessor.java =================================================================== --- trunk/openutils-mgnlmedia/src/main/java/net/sourceforge/openutils/mgnlmedia/media/processors/FitInImageResolutionProcessor.java (rev 0) +++ trunk/openutils-mgnlmedia/src/main/java/net/sourceforge/openutils/mgnlmedia/media/processors/FitInImageResolutionProcessor.java 2009-09-04 16:15:19 UTC (rev 1361) @@ -0,0 +1,22 @@ +package net.sourceforge.openutils.mgnlmedia.media.processors; + +import java.awt.image.BufferedImage; +import java.util.Map; + + +/** + * @author molaschi + * @version $Id: $ + */ +public class FitInImageResolutionProcessor extends BaseImageResolutionProcessor +{ + + /** + * {@inheritDoc} + */ + public BufferedImage getImageForResolution(BufferedImage original, int x, int y, Map<String, String> parameters) + { + return resizeInOut(original, x, y, false, null); + } + +} Added: trunk/openutils-mgnlmedia/src/main/java/net/sourceforge/openutils/mgnlmedia/media/processors/ImagePostProcessor.java =================================================================== --- trunk/openutils-mgnlmedia/src/main/java/net/sourceforge/openutils/mgnlmedia/media/processors/ImagePostProcessor.java (rev 0) +++ trunk/openutils-mgnlmedia/src/main/java/net/sourceforge/openutils/mgnlmedia/media/processors/ImagePostProcessor.java 2009-09-04 16:15:19 UTC (rev 1361) @@ -0,0 +1,15 @@ +package net.sourceforge.openutils.mgnlmedia.media.processors; + +import java.awt.image.BufferedImage; +import java.util.Map; + + +/** + * @author molaschi + * @version $Id: $ + */ +public interface ImagePostProcessor +{ + + BufferedImage processImage(BufferedImage image, int x, int y, Map<String, String> parameters); +} Added: trunk/openutils-mgnlmedia/src/main/java/net/sourceforge/openutils/mgnlmedia/media/processors/ImageResolutionProcessor.java =================================================================== --- trunk/openutils-mgnlmedia/src/main/java/net/sourceforge/openutils/mgnlmedia/media/processors/ImageResolutionProcessor.java (rev 0) +++ trunk/openutils-mgnlmedia/src/main/java/net/sourceforge/openutils/mgnlmedia/media/processors/ImageResolutionProcessor.java 2009-09-04 16:15:19 UTC (rev 1361) @@ -0,0 +1,16 @@ +package net.sourceforge.openutils.mgnlmedia.media.processors; + +import java.awt.image.BufferedImage; +import java.util.Map; + + +/** + * @author molaschi + * @version $Id: $ + */ +public interface ImageResolutionProcessor +{ + + BufferedImage getImageForResolution(BufferedImage original, int x, int y, Map<String, String> parameters); + +} Added: trunk/openutils-mgnlmedia/src/main/java/net/sourceforge/openutils/mgnlmedia/media/processors/LogSizePostProcessor.java =================================================================== --- trunk/openutils-mgnlmedia/src/main/java/net/sourceforge/openutils/mgnlmedia/media/processors/LogSizePostProcessor.java (rev 0) +++ trunk/openutils-mgnlmedia/src/main/java/net/sourceforge/openutils/mgnlmedia/media/processors/LogSizePostProcessor.java 2009-09-04 16:15:19 UTC (rev 1361) @@ -0,0 +1,38 @@ +package net.sourceforge.openutils.mgnlmedia.media.processors; + +import java.awt.image.BufferedImage; +import java.util.Map; + +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + + +/** + * @author molaschi + * @version $Id: $ + */ +public class LogSizePostProcessor implements ImagePostProcessor +{ + + /** + * Logger. + */ + private Logger log = LoggerFactory.getLogger(LogSizePostProcessor.class); + + /** + * {@inheritDoc} + */ + public BufferedImage processImage(BufferedImage image, int x, int y, Map<String, String> parameters) + { + if (parameters.containsKey("logsize")) + { + log.info("Image size [{},{}] - Required size [{},{}]", new Object[]{ + image.getWidth(), + image.getHeight(), + x, + y }); + } + return image; + } + +} Added: trunk/openutils-mgnlmedia/src/main/java/net/sourceforge/openutils/mgnlmedia/media/processors/ResizeCropCenteredImageResolutionProcessor.java =================================================================== --- trunk/openutils-mgnlmedia/src/main/java/net/sourceforge/openutils/mgnlmedia/media/processors/ResizeCropCenteredImageResolutionProcessor.java (rev 0) +++ trunk/openutils-mgnlmedia/src/main/java/net/sourceforge/openutils/mgnlmedia/media/processors/ResizeCropCenteredImageResolutionProcessor.java 2009-09-04 16:15:19 UTC (rev 1361) @@ -0,0 +1,22 @@ +package net.sourceforge.openutils.mgnlmedia.media.processors; + +import java.awt.image.BufferedImage; +import java.util.Map; + + +/** + * @author molaschi + * @version $Id: $ + */ +public class ResizeCropCenteredImageResolutionProcessor extends BaseImageResolutionProcessor +{ + + /** + * {@inheritDoc} + */ + public BufferedImage getImageForResolution(BufferedImage original, int x, int y, Map<String, String> parameters) + { + return fill(original, x, y, true); + } + +} Added: trunk/openutils-mgnlmedia/src/main/java/net/sourceforge/openutils/mgnlmedia/media/processors/ResizeNoCropImageResolutionProcessor.java =================================================================== --- trunk/openutils-mgnlmedia/src/main/java/net/sourceforge/openutils/mgnlmedia/media/processors/ResizeNoCropImageResolutionProcessor.java (rev 0) +++ trunk/openutils-mgnlmedia/src/main/java/net/sourceforge/openutils/mgnlmedia/media/processors/ResizeNoCropImageResolutionProcessor.java 2009-09-04 16:15:19 UTC (rev 1361) @@ -0,0 +1,22 @@ +package net.sourceforge.openutils.mgnlmedia.media.processors; + +import java.awt.image.BufferedImage; +import java.util.Map; + + +/** + * @author molaschi + * @version $Id: $ + */ +public class ResizeNoCropImageResolutionProcessor extends BaseImageResolutionProcessor +{ + + /** + * {@inheritDoc} + */ + public BufferedImage getImageForResolution(BufferedImage original, int x, int y, Map<String, String> parameters) + { + return fill(original, x, y, false); + } + +} Modified: trunk/openutils-mgnlmedia/src/main/java/net/sourceforge/openutils/mgnlmedia/media/save/MediaCustomSaveHandler.java =================================================================== --- trunk/openutils-mgnlmedia/src/main/java/net/sourceforge/openutils/mgnlmedia/media/save/MediaCustomSaveHandler.java 2009-09-04 14:44:47 UTC (rev 1360) +++ trunk/openutils-mgnlmedia/src/main/java/net/sourceforge/openutils/mgnlmedia/media/save/MediaCustomSaveHandler.java 2009-09-04 16:15:19 UTC (rev 1361) @@ -26,6 +26,7 @@ import javax.jcr.ItemNotFoundException; import javax.jcr.RepositoryException; +import javax.servlet.http.HttpServletRequest; import net.sourceforge.openutils.mgnlmedia.media.configuration.MediaConfigurationManager; import net.sourceforge.openutils.mgnlmedia.media.configuration.MediaTypeConfiguration; @@ -54,9 +55,9 @@ public void save(Content parentNode, Content configNode, String name, MultipartForm form, int type, int valueType, int isRichEditValue, int encoding) throws RepositoryException, AccessDeniedException { + HttpServletRequest request = MgnlContext.getWebContext().getRequest(); + String value = request.getParameter(name); - String value = form.getParameter(name); - if (value == null || StringUtils.EMPTY.equals(value)) { if (parentNode.hasNodeData(name)) @@ -80,6 +81,7 @@ parentNode, configNode, name, + request, form, type, valueType, Modified: trunk/openutils-mgnlmedia/src/main/java/net/sourceforge/openutils/mgnlmedia/media/setup/MediaModuleVersionHandler.java =================================================================== --- trunk/openutils-mgnlmedia/src/main/java/net/sourceforge/openutils/mgnlmedia/media/setup/MediaModuleVersionHandler.java 2009-09-04 14:44:47 UTC (rev 1360) +++ trunk/openutils-mgnlmedia/src/main/java/net/sourceforge/openutils/mgnlmedia/media/setup/MediaModuleVersionHandler.java 2009-09-04 16:15:19 UTC (rev 1361) @@ -17,15 +17,37 @@ */ package net.sourceforge.openutils.mgnlmedia.media.setup; +import info.magnolia.cms.core.Content; +import info.magnolia.cms.core.NodeData; +import info.magnolia.cms.core.SystemProperty; +import info.magnolia.cms.core.search.Query; +import info.magnolia.cms.core.search.QueryManager; +import info.magnolia.cms.core.search.QueryResult; import info.magnolia.module.InstallContext; +import info.magnolia.module.delta.Delta; +import info.magnolia.module.delta.DeltaBuilder; import info.magnolia.module.delta.Task; +import info.magnolia.module.delta.TaskExecutionException; +import info.magnolia.module.model.Version; import it.openutils.mgnltasks.NodeSortTask; import it.openutils.mgnltasks.SimpleModuleVersionHandler; import java.util.ArrayList; +import java.util.Collection; import java.util.List; +import javax.jcr.RepositoryException; +import javax.jcr.nodetype.ConstraintViolationException; +import net.sourceforge.openutils.mgnlmedia.media.configuration.MediaConfigurationManager; +import net.sourceforge.openutils.mgnlmedia.media.lifecycle.MediaModule; +import net.sourceforge.openutils.mgnlmedia.media.types.impl.BaseTypeHandler; + +import org.apache.commons.lang.ObjectUtils; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + + /** * @author manuel * @version $Id @@ -36,6 +58,7 @@ /** * {@inheritDoc} */ + @SuppressWarnings("unchecked") @Override protected List getStartupTasks(InstallContext installContext) { @@ -43,6 +66,72 @@ tasks.add(new NodeSortTask("config", "/modules/media/mediatypes", "order")); + tasks.add(new Task() + { + + /** + * Logger. + */ + private Logger log = LoggerFactory.getLogger(this.getClass()); + + public String getName() + { + return "file store nodedata name updater"; + } + + public String getDescription() + { + return "update custom nodedata names (where original files are stored) to \"original\""; + } + + public void execute(InstallContext installContext) throws TaskExecutionException + { + QueryManager mgr = installContext.getHierarchyManager(MediaModule.REPO).getQueryManager(); + try + { + reset(mgr, "image", "image"); + reset(mgr, "video", "video"); + reset(mgr, "audio", "audio"); + } + catch (RepositoryException ex) + { + log.error(ex.getMessage(), ex); + } + } + + private void reset(QueryManager queryManager, String type, String nodedataOldName) + throws RepositoryException + { + Query query = queryManager.createQuery( + "//*[" + nodedataOldName + " and type='" + type + "']", + Query.XPATH); + QueryResult queryResult = query.execute(); + Collection<Content> medias = queryResult.getContent(MediaConfigurationManager.MEDIA.getSystemName()); + for (Content media : medias) + { + NodeData nd = media.getNodeData(nodedataOldName); + if (nd.getValue() != null) + { + NodeData ndNew = media.createNodeData(BaseTypeHandler.ORGINAL_NODEDATA_NAME, nd.getValue()); + for (String attributeName : ((List<String>) nd.getAttributeNames())) + { + try + { + ndNew.setAttribute(attributeName, nd.getAttribute(attributeName)); + } + catch (ConstraintViolationException ex) + { + // go on + } + } + nd.delete(); + } + // media.deleteNodeData(nd.getName()); + media.save(); + } + } + }); + return tasks; } Modified: trunk/openutils-mgnlmedia/src/main/java/net/sourceforge/openutils/mgnlmedia/media/tags/el/MediaEl.java =================================================================== --- trunk/openutils-mgnlmedia/src/main/java/net/sourceforge/openutils/mgnlmedia/media/tags/el/MediaEl.java 2009-09-04 14:44:47 UTC (rev 1360) +++ trunk/openutils-mgnlmedia/src/main/java/net/sourceforge/openutils/mgnlmedia/media/tags/el/MediaEl.java 2009-09-04 16:15:19 UTC (rev 1361) @@ -303,7 +303,7 @@ try { - String resString = "res-" + URLEncoder.encode(resolution, "utf-8"); + String resString = "res-" + ImageUtils.getResolutionPath(resolution); if (resolutions != null && resolutions.hasNodeData(resString)) { String resPath = new FileProperties(resolutions, resString).getProperty(FileProperties.PATH); @@ -316,10 +316,6 @@ { log.debug(e.getMessage(), e); } - catch (UnsupportedEncodingException e) - { - log.debug(e.getMessage(), e); - } return null; } @@ -331,40 +327,43 @@ */ public static int[] getSize(Content media, String resolution) { - NodeData res = null; - if ("original".equals(resolution)) + if (media != null) { - res = media.getNodeData("original"); - } - else - { - Content resolutions = media.getChildByName("resolutions"); - try + + NodeData res = null; + if ("original".equals(resolution)) { - if (resolutions.hasNodeData("res-" + resolution)) + res = media.getNodeData("original"); + } + else + { + Content resolutions = media.getChildByName("resolutions"); + try { - res = resolutions.getNodeData("res-" + resolution); + if (resolutions.hasNodeData("res-" + resolution)) + { + res = resolutions.getNodeData("res-" + resolution); + } + else + { + res = null; + } } - else + catch (RepositoryException e) { res = null; } } - catch (RepositoryException e) + + if (res != null) { - res = null; + return new int[]{ + NumberUtils.toInt(res.getAttribute(FileProperties.PROPERTY_WIDTH)), + NumberUtils.toInt(res.getAttribute(FileProperties.PROPERTY_HEIGHT)) }; } } - if (res != null) - { - return new int[]{ - NumberUtils.toInt(res.getAttribute(FileProperties.PROPERTY_WIDTH)), - NumberUtils.toInt(res.getAttribute(FileProperties.PROPERTY_HEIGHT)) }; - } - return new int[]{-1, -1 }; - } /** Modified: trunk/openutils-mgnlmedia/src/main/java/net/sourceforge/openutils/mgnlmedia/media/types/MediaTypeHandler.java =================================================================== --- trunk/openutils-mgnlmedia/src/main/java/net/sourceforge/openutils/mgnlmedia/media/types/MediaTypeHandler.java 2009-09-04 14:44:47 UTC (rev 1360) +++ trunk/openutils-mgnlmedia/src/main/java/net/sourceforge/openutils/mgnlmedia/media/types/MediaTypeHandler.java 2009-09-04 16:15:19 UTC (rev 1361) @@ -27,6 +27,7 @@ import java.util.Map; import javax.jcr.RepositoryException; +import javax.servlet.http.HttpServletRequest; /** @@ -134,9 +135,10 @@ /** * Get the name for a new node * @param form multipart form + * @param request current request * @return new name */ - String getNewNodeName(MultipartForm form); + String getNewNodeName(MultipartForm form, HttpServletRequest request); /** * Called when a media is going to be associated with a node @@ -144,6 +146,7 @@ * @param parentNode node to be associated * @param configNode configuration node * @param name property name + * @param request current request * @param form request form * @param type typee * @param valueType value type @@ -154,8 +157,8 @@ * @exception AccessDeniedException access denied exception */ boolean onSavingPropertyMedia(Content media, Content parentNode, Content configNode, String name, - MultipartForm form, int type, int valueType, int isRichEditValue, int encoding) throws RepositoryException, - AccessDeniedException; + HttpServletRequest request, MultipartForm form, int type, int valueType, int isRichEditValue, int encoding) + throws RepositoryException, AccessDeniedException; /** * save a media file to a newly created media content Modified: trunk/openutils-mgnlmedia/src/main/java/net/sourceforge/openutils/mgnlmedia/media/types/impl/AudioTypeHandler.java =================================================================== --- trunk/openutils-mgnlmedia/src/main/java/net/sourceforge/openutils/mgnlmedia/media/types/impl/AudioTypeHandler.java 2009-09-04 14:44:47 UTC (rev 1360) +++ trunk/openutils-mgnlmedia/src/main/java/net/sourceforge/openutils/mgnlmedia/media/types/impl/AudioTypeHandler.java 2009-09-04 16:15:19 UTC (rev 1361) @@ -17,23 +17,9 @@ */ package net.sourceforge.openutils.mgnlmedia.media.types.impl; -import info.magnolia.cms.beans.runtime.Document; -import info.magnolia.cms.beans.runtime.FileProperties; -import info.magnolia.cms.beans.runtime.MultipartForm; import info.magnolia.cms.core.Content; -import info.magnolia.cms.core.NodeData; -import info.magnolia.cms.security.AccessDeniedException; -import info.magnolia.cms.util.NodeDataUtil; -import info.magnolia.module.admininterface.SaveHandlerImpl; -import java.io.File; -import java.util.Map; -import javax.jcr.RepositoryException; - -import net.sourceforge.openutils.mgnlmedia.media.configuration.MediaConfigurationManager; - - /** * @author molaschi * @version $Id$ @@ -44,115 +30,9 @@ /** * {@inheritDoc} */ - public void init(Content typeDefinitionNode) - { - - } - - /** - * {@inheritDoc} - */ - public String getUrl(Content media) - { - NodeData file = media.getNodeData("audio"); - String fileName = file.getAttribute(FileProperties.PROPERTY_FILENAME) - + "." - + file.getAttribute(FileProperties.EXTENSION); - - return MediaConfigurationManager.getInstance().getURIMappingPrefix() + media.getHandle() + "/audio/" + fileName; - } - - /** - * {@inheritDoc} - */ - public String getUrl(Content media, Map<String, String> options) - { - return getUrl(media); - } - - /** - * {@inheritDoc} - */ - public String getFilename(Content media) - { - NodeData file = media.getNodeData("audio"); - return file.getAttribute(FileProperties.PROPERTY_FILENAME); - } - - /** - * {@inheritDoc} - */ - public String getExtension(Content media) - { - NodeData file = media.getNodeData("audio"); - return file.getAttribute(FileProperties.PROPERTY_EXTENSION); - } - - /** - * {@inheritDoc} - */ - public String getFullFilename(Content media) - { - return getFilename(media) + "." + getExtension(media); - } - - /** - * {@inheritDoc} - */ public String getThumbnailUrl(Content media) { return "/.resources/media/icons/audioThumb.jpg"; } - /** - * {@inheritDoc} - */ - public String getPreviewUrl(Content media) - { - return getUrl(media); - } - - /** - * {@inheritDoc} - */ - @Override - public boolean onPostSave(Content media) - { - return super.onPostSave(media); - } - - public void saveFromZipFile(Content media, File f, String cleanFileName, String extension) - throws AccessDeniedException, RepositoryException - { - Document doc = new Document(f, "audio/" + extension); - doc.setExtention(extension); - SaveHandlerImpl.saveDocument(media, doc, "audio", cleanFileName, cleanFileName - + "_" - + FileProperties.PROPERTY_TEMPLATE); - this.onPostSave(media); - } - - /** - * {@inheritDoc} - */ - public String getNewNodeName(MultipartForm form) - { - return form.getParameter("audio_" + FileProperties.PROPERTY_FILENAME); - } - - /** - * {@inheritDoc} - */ - public boolean onSavingPropertyMedia(Content media, Content parentNode, Content configNode, String name, - MultipartForm form, int type, int valueType, int isRichEditValue, int encoding) throws RepositoryException, - AccessDeniedException - { - String value = form.getParameter(name); - - NodeData nd = NodeDataUtil.getOrCreate(parentNode, name); - nd.setValue(value); - - return true; - } - } Modified: trunk/openutils-mgnlmedia/src/main/java/net/sourceforge/openutils/mgnlmedia/media/types/impl/BaseTypeHandler.java =================================================================== --- trunk/openutils-mgnlmedia/src/main/java/net/sourceforge/openutils/mgnlmedia/media/types/impl/BaseTypeHandler.java 2009-09-04 14:44:47 UTC (rev 1360) +++ trunk/openutils-mgnlmedia/src/main/java/net/sourceforge/openutils/mgnlmedia/media/types/impl/BaseTypeHandler.java 2009-09-04 16:15:19 UTC (rev 1361) @@ -17,19 +17,29 @@ */ package net.sourceforge.openutils.mgnlmedia.media.types.impl; +import info.magnolia.cms.beans.runtime.Document; +import info.magnolia.cms.beans.runtime.FileProperties; +import info.magnolia.cms.beans.runtime.MultipartForm; import info.magnolia.cms.core.Content; import info.magnolia.cms.core.NodeData; +import info.magnolia.cms.security.AccessDeniedException; import info.magnolia.cms.util.NodeDataUtil; import info.magnolia.context.MgnlContext; +import info.magnolia.module.admininterface.SaveHandlerImpl; +import java.io.File; import java.util.Collection; import java.util.Locale; +import java.util.Map; import javax.jcr.RepositoryException; +import javax.servlet.http.HttpServletRequest; +import net.sourceforge.openutils.mgnlmedia.media.configuration.MediaConfigurationManager; import net.sourceforge.openutils.mgnlmedia.media.lifecycle.MediaModule; import net.sourceforge.openutils.mgnlmedia.media.types.MediaTypeHandler; +import org.apache.commons.lang.StringUtils; import org.slf4j.Logger; import org.slf4j.LoggerFactory; @@ -41,11 +51,164 @@ public abstract class BaseTypeHandler implements MediaTypeHandler { + public static final String ORGINAL_NODEDATA_NAME = "original"; + /** * Logger. */ private Logger log = LoggerFactory.getLogger(BaseTypeHandler.class); + private String type = null; + + /** + * {@inheritDoc} + */ + public void init(Content typeDefinitionNode) + { + type = typeDefinitionNode.getName(); + } + + /** + * {@inheritDoc} + */ + public String getNewNodeName(MultipartForm form, HttpServletRequest request) + { + return form.getParameter(ORGINAL_NODEDATA_NAME + "_" + FileProperties.PROPERTY_FILENAME); + } + + /** + * {@inheritDoc} + */ + public boolean onSavingPropertyMedia(Content media, Content parentNode, Content configNode, String name, + HttpServletRequest request, MultipartForm form, int type, int valueType, int isRichEditValue, int encoding) + throws RepositoryException, AccessDeniedException + { + String uuid = request.getParameter(name); + + NodeData nd = NodeDataUtil.getOrCreate(parentNode, name); + nd.setValue(uuid); + + return true; + } + + public void saveFromZipFile(Content media, File f, String cleanFileName, String extension) + throws AccessDeniedException, RepositoryException + { + Document doc = new Document(f, type + extension); + doc.setExtention(extension); + SaveHandlerImpl.saveDocument(media, doc, ORGINAL_NODEDATA_NAME, cleanFileName, cleanFileName + + "_" + + FileProperties.PROPERTY_TEMPLATE); + this.onPostSave(media); + } + + /** + * {@inheritDoc} + */ + @SuppressWarnings("unchecked") + public boolean onPostSave(Content media) + { + try + { + if (media.hasContent("resolutions")) + { + Collection<NodeData> nodedatas = media.getChildByName("resolutions").getNodeDataCollection(); + for (NodeData nd : nodedatas) + { + nd.delete(); + } + media.save(); + } + + if (MediaModule.getInstance().isAutoactivate()) + { + media.getMetaData().setActivated(); + media.save(); + } + } + catch (RepositoryException ex) + { + log.error("Error removing resolutions", ex); + } + + Collection<NodeData> nds = media.getNodeDataCollection("tags*"); + for (NodeData nd : nds) + { + if (nd.getString() != null) + { + try + { + nd.setValue(nd.getString().toLowerCase()); + nd.save(); + } + catch (RepositoryException ex) + { + log.warn("Error putting property to lower case", ex); + } + } + } + return true; + } + + protected NodeData getOriginalFileNodeData(Content media) + { + return media.getNodeData(ORGINAL_NODEDATA_NAME); + } + + /** + * {@inheritDoc} + */ + public String getExtension(Content media) + { + return getOriginalFileNodeData(media).getAttribute(FileProperties.PROPERTY_EXTENSION); + } + + /** + * {@inheritDoc} + */ + public String getFilename(Content media) + { + return getOriginalFileNodeData(media).getAttribute(FileProperties.PROPERTY_FILENAME); + } + + /** + * {@inheritDoc} + */ + public String getFullFilename(Content media) + { + return getFilename(media) + + (StringUtils.isNotBlank(getExtension(media)) ? "." + getExtension(media) : StringUtils.EMPTY); + } + + /** + * {@inheritDoc} + */ + public String getUrl(Content media, Map<String, String> options) + { + return MediaConfigurationManager.getInstance().getURIMappingPrefix() + + media.getHandle() + + "/" + + ORGINAL_NODEDATA_NAME + + "/" + + getFullFilename(media); + } + + /** + * {@inheritDoc} + */ + public String getUrl(Content media) + { + return getUrl(media, null); + } + + /** + * {@inheritDoc} + */ + public String getPreviewUrl(Content media) + { + return getUrl(media); + } + protected String getPropertyLocalized(Content media, String property) { Locale locale = MgnlContext.getLocale(); @@ -104,36 +267,4 @@ { return getPropertyLocalized(media, "abstract"); } - - /** - * {@inheritDoc} - */ - @SuppressWarnings("unchecked") - public boolean onPostSave(Content media) - { - try - { - if (media.hasContent("resolutions")) - { - Collection<NodeData> nodedatas = media.getChildByName("resolutions").getNodeDataCollection(); - for (NodeData nd : nodedatas) - { - nd.delete(); - } - media.save(); - } - - if (MediaModule.getInstance().isAutoactivate()) - { - media.getMetaData().setActivated(); - media.save(); - } - } - catch (RepositoryException ex) - { - log.error("Error removing resolutions", ex); - } - return true; - } - } Modified: trunk/openutils-mgnlmedia/src/main/java/net/sourceforge/openutils/mgnlmedia/media/types/impl/ImageTypeHandler.java =================================================================== --- trunk/openutils-mgnlmedia/src/main/java/net/sourceforge/openutils/mgnlmedia/media/types/impl/ImageTypeHandler.java 2009-09-04 14:44:47 UTC (rev 1360) +++ trunk/openutils-mgnlmedia/src/main/java/net/sourceforge/openutils/mgnlmedia/media/types/impl/ImageTypeHandler.java 2009-09-04 16:15:19 UTC (rev 1361) @@ -17,21 +17,7 @@ */ package net.sourceforge.openutils.mgnlmedia.media.types.impl; -import info.magnolia.cms.beans.runtime.Document; -import info.magnolia.cms.beans.runtime.FileProperties; -import info.magnolia.cms.beans.runtime.MultipartForm; import info.magnolia.cms.core.Content; -import info.magnolia.cms.core.NodeData; -import info.magnolia.cms.security.AccessDeniedException; -import info.magnolia.cms.util.NodeDataUtil; -import info.magnolia.module.admininterface.SaveHandlerImpl; - -import java.io.File; -import java.util.Collection; -import java.util.Map; - -import javax.jcr.RepositoryException; - import net.sourceforge.openutils.mgnlmedia.media.configuration.MediaConfigurationManager; import net.sourceforge.openutils.mgnlmedia.media.utils.ImageUtils; @@ -55,61 +41,6 @@ /** * {@inheritDoc} */ - public void init(Content typeDefinitionNode) - { - - } - - /** - * {@inheritDoc} - */ - public String getFilename(Content media) - { - NodeData file = media.getNodeData("image"); - return file.getAttribute(FileProperties.PROPERTY_FILENAME); - } - - /** - * {@inheritDoc} - */ - public String getExtension(Content media) - { - NodeData file = media.getNodeData("image"); - return file.getAttribute(FileProperties.PROPERTY_EXTENSION); - } - - /** - * {@inheritDoc} - */ - public String getFullFilename(Content media) - { - return getFilename(media) + "." + getExtension(media); - } - - /** - * {@inheritDoc} - */ - public String getUrl(Content media) - { - NodeData file = media.getNodeData("image"); - String fileName = file.getAttribute(FileProperties.PROPERTY_FILENAME) - + "." - + file.getAttribute(FileProperties.EXTENSION); - - return MediaConfigurationManager.getInstance().getURIMappingPrefix() + media.getHandle() + "/image/" + fileName; - } - - /** - * {@inheritDoc} - */ - public String getUrl(Content media, Map<String, String> options) - { - return getUrl(media); - } - - /** - * {@inheritDoc} - */ public String getThumbnailUrl(Content media) { if (!ImageUtils.checkOrCreateResolution(media, "thumbnail")) @@ -125,6 +56,7 @@ /** * {@inheritDoc} */ + @Override public String getPreviewUrl(Content media) { if (!ImageUtils.checkOrCreateResolution(media, "preview")) @@ -136,67 +68,4 @@ + "/resolutions/preview/data." + ImageUtils.getExtension(media, "preview"); } - - /** - * {@inheritDoc} - */ - @Override - @SuppressWarnings("unchecked") - public boolean onPostSave(Content media) - { - Collection<NodeData> nds = media.getNodeDataCollection("tags-*"); - for (NodeData nd : nds) - { - if (nd.getString() != null) - { - try - { - nd.setValue(nd.getString().toLowerCase()); - nd.save(); - } - catch (RepositoryException ex) - { - log.warn("Error putting property to lower case", ex); - } - ... [truncated message content] |
From: <mol...@us...> - 2009-10-16 09:47:07
|
Revision: 1489 http://openutils.svn.sourceforge.net/openutils/?rev=1489&view=rev Author: molaschi Date: 2009-10-16 09:46:56 +0000 (Fri, 16 Oct 2009) Log Message: ----------- fix broken javadocs, clean some code and update tld docs 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/dialog/DialogSelectMedia.java trunk/openutils-mgnlmedia/src/main/java/net/sourceforge/openutils/mgnlmedia/media/lifecycle/MediaModule.java trunk/openutils-mgnlmedia/src/main/java/net/sourceforge/openutils/mgnlmedia/media/pages/MediaSearchPage.java trunk/openutils-mgnlmedia/src/main/java/net/sourceforge/openutils/mgnlmedia/media/processors/ImagePostProcessor.java trunk/openutils-mgnlmedia/src/main/java/net/sourceforge/openutils/mgnlmedia/media/processors/ImageResolutionProcessor.java trunk/openutils-mgnlmedia/src/main/java/net/sourceforge/openutils/mgnlmedia/media/processors/RoundedCornersProcessor.java trunk/openutils-mgnlmedia/src/main/java/net/sourceforge/openutils/mgnlmedia/media/setup/RemoveResolutionsNodeTask.java trunk/openutils-mgnlmedia/src/main/java/net/sourceforge/openutils/mgnlmedia/media/setup/RenameThumbToImageTask.java trunk/openutils-mgnlmedia/src/main/java/net/sourceforge/openutils/mgnlmedia/media/tags/el/MediaEl.java trunk/openutils-mgnlmedia/src/main/java/net/sourceforge/openutils/mgnlmedia/media/types/MediaTypeHandler.java trunk/openutils-mgnlmedia/src/main/java/net/sourceforge/openutils/mgnlmedia/media/types/impl/BaseTypeHandler.java trunk/openutils-mgnlmedia/src/main/java/net/sourceforge/openutils/mgnlmedia/media/types/impl/ImageTypeHandler.java 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/JpegUtils.java trunk/openutils-mgnlmedia/src/main/resources/META-INF/media.tld trunk/openutils-mgnlmedia/src/test/java/net/sourceforge/openutils/mgnlmedia/media/utils/FileNodeData.java trunk/openutils-mgnlmedia/src/test/java/net/sourceforge/openutils/mgnlmedia/media/utils/ImageUtilsTest.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 2009-10-14 15:07:43 UTC (rev 1488) +++ trunk/openutils-mgnlmedia/src/main/java/net/sourceforge/openutils/mgnlmedia/media/commands/MediaActivationCommand.java 2009-10-16 09:46:56 UTC (rev 1489) @@ -116,6 +116,13 @@ } } + /** + * Activate recursive one level + * @param parentPath parent node + * @param node node to activate + * @throws RepositoryException exception + * @throws ExchangeException exception exchanging node + */ @SuppressWarnings("unchecked") public void activateRecursiveOneLevel(String parentPath, Content node) throws RepositoryException, ExchangeException Modified: trunk/openutils-mgnlmedia/src/main/java/net/sourceforge/openutils/mgnlmedia/media/dialog/DialogSelectMedia.java =================================================================== --- trunk/openutils-mgnlmedia/src/main/java/net/sourceforge/openutils/mgnlmedia/media/dialog/DialogSelectMedia.java 2009-10-14 15:07:43 UTC (rev 1488) +++ trunk/openutils-mgnlmedia/src/main/java/net/sourceforge/openutils/mgnlmedia/media/dialog/DialogSelectMedia.java 2009-10-16 09:46:56 UTC (rev 1489) @@ -222,9 +222,6 @@ return MessagesUtil.chain("net.sourceforge.openutils.mgnlmedia.media.lang.messages", super.getMessages()); } - /** - * {@inheritDoc} - */ protected String getPath() { return "dialog/selectMedia.ftl"; Modified: trunk/openutils-mgnlmedia/src/main/java/net/sourceforge/openutils/mgnlmedia/media/lifecycle/MediaModule.java =================================================================== --- trunk/openutils-mgnlmedia/src/main/java/net/sourceforge/openutils/mgnlmedia/media/lifecycle/MediaModule.java 2009-10-14 15:07:43 UTC (rev 1488) +++ trunk/openutils-mgnlmedia/src/main/java/net/sourceforge/openutils/mgnlmedia/media/lifecycle/MediaModule.java 2009-10-16 09:46:56 UTC (rev 1489) @@ -52,11 +52,18 @@ private static MediaModule instance; + /** + * Constructor + */ public MediaModule() { instance = this; } + /** + * Get instance + * @return media module instance + */ public static MediaModule getInstance() { return instance; Modified: trunk/openutils-mgnlmedia/src/main/java/net/sourceforge/openutils/mgnlmedia/media/pages/MediaSearchPage.java =================================================================== --- trunk/openutils-mgnlmedia/src/main/java/net/sourceforge/openutils/mgnlmedia/media/pages/MediaSearchPage.java 2009-10-14 15:07:43 UTC (rev 1488) +++ trunk/openutils-mgnlmedia/src/main/java/net/sourceforge/openutils/mgnlmedia/media/pages/MediaSearchPage.java 2009-10-16 09:46:56 UTC (rev 1489) @@ -159,11 +159,6 @@ return super.show(); } - public String search() - { - return null; - } - /** * Returns the mtc. * @return the mtc Modified: trunk/openutils-mgnlmedia/src/main/java/net/sourceforge/openutils/mgnlmedia/media/processors/ImagePostProcessor.java =================================================================== --- trunk/openutils-mgnlmedia/src/main/java/net/sourceforge/openutils/mgnlmedia/media/processors/ImagePostProcessor.java 2009-10-14 15:07:43 UTC (rev 1488) +++ trunk/openutils-mgnlmedia/src/main/java/net/sourceforge/openutils/mgnlmedia/media/processors/ImagePostProcessor.java 2009-10-16 09:46:56 UTC (rev 1489) @@ -38,5 +38,13 @@ public interface ImagePostProcessor { + /** + * Process image + * @param image image to process + * @param x width + * @param y height + * @param parameters parameters map + * @return processed image + */ BufferedImage processImage(BufferedImage image, int x, int y, Map<String, String> parameters); } Modified: trunk/openutils-mgnlmedia/src/main/java/net/sourceforge/openutils/mgnlmedia/media/processors/ImageResolutionProcessor.java =================================================================== --- trunk/openutils-mgnlmedia/src/main/java/net/sourceforge/openutils/mgnlmedia/media/processors/ImageResolutionProcessor.java 2009-10-14 15:07:43 UTC (rev 1488) +++ trunk/openutils-mgnlmedia/src/main/java/net/sourceforge/openutils/mgnlmedia/media/processors/ImageResolutionProcessor.java 2009-10-16 09:46:56 UTC (rev 1489) @@ -40,6 +40,14 @@ public interface ImageResolutionProcessor { + /** + * Process image + * @param original original image + * @param x required width + * @param y required height + * @param parameters parameters + * @return resized image + */ BufferedImage getImageForResolution(BufferedImage original, int x, int y, Map<String, String> parameters); } Modified: trunk/openutils-mgnlmedia/src/main/java/net/sourceforge/openutils/mgnlmedia/media/processors/RoundedCornersProcessor.java =================================================================== --- trunk/openutils-mgnlmedia/src/main/java/net/sourceforge/openutils/mgnlmedia/media/processors/RoundedCornersProcessor.java 2009-10-14 15:07:43 UTC (rev 1488) +++ trunk/openutils-mgnlmedia/src/main/java/net/sourceforge/openutils/mgnlmedia/media/processors/RoundedCornersProcessor.java 2009-10-16 09:46:56 UTC (rev 1489) @@ -13,6 +13,14 @@ /** + * Generate rounded corners on images.<br/> + * Activated by declaring the parameter <strong>roundcorners</strong>; its value can be: + * <ul> + * <li>no value or true: processor draws roundcorners with 5px radius</li> + * <li>int value: processor draws roundcorners with passed radius</li> + * </ul> + * If the "background" parameter is specified (hex color), it will be applied when rounding corners.<br/> + * If no "background" parameter is found, if the image format is png a transparent background is applied else a white background is applied. * @author molaschi * @version $Id: $ */ Modified: trunk/openutils-mgnlmedia/src/main/java/net/sourceforge/openutils/mgnlmedia/media/setup/RemoveResolutionsNodeTask.java =================================================================== --- trunk/openutils-mgnlmedia/src/main/java/net/sourceforge/openutils/mgnlmedia/media/setup/RemoveResolutionsNodeTask.java 2009-10-14 15:07:43 UTC (rev 1488) +++ trunk/openutils-mgnlmedia/src/main/java/net/sourceforge/openutils/mgnlmedia/media/setup/RemoveResolutionsNodeTask.java 2009-10-16 09:46:56 UTC (rev 1489) @@ -50,8 +50,7 @@ { /** - * @param taskName - * @param taskDescription + * Constructor */ public RemoveResolutionsNodeTask() { @@ -61,6 +60,7 @@ /** * {@inheritDoc} */ + @SuppressWarnings("unchecked") public void execute(InstallContext installContext) throws TaskExecutionException { HierarchyManager hm = installContext.getHierarchyManager(MediaModule.REPO); Modified: trunk/openutils-mgnlmedia/src/main/java/net/sourceforge/openutils/mgnlmedia/media/setup/RenameThumbToImageTask.java =================================================================== --- trunk/openutils-mgnlmedia/src/main/java/net/sourceforge/openutils/mgnlmedia/media/setup/RenameThumbToImageTask.java 2009-10-14 15:07:43 UTC (rev 1488) +++ trunk/openutils-mgnlmedia/src/main/java/net/sourceforge/openutils/mgnlmedia/media/setup/RenameThumbToImageTask.java 2009-10-16 09:46:56 UTC (rev 1489) @@ -53,8 +53,7 @@ { /** - * @param taskName - * @param taskDescription + * Constructor */ public RenameThumbToImageTask() { @@ -64,6 +63,7 @@ /** * {@inheritDoc} */ + @SuppressWarnings("unchecked") public void execute(InstallContext installContext) throws TaskExecutionException { HierarchyManager hm = installContext.getHierarchyManager(MediaModule.REPO); Modified: trunk/openutils-mgnlmedia/src/main/java/net/sourceforge/openutils/mgnlmedia/media/tags/el/MediaEl.java =================================================================== --- trunk/openutils-mgnlmedia/src/main/java/net/sourceforge/openutils/mgnlmedia/media/tags/el/MediaEl.java 2009-10-14 15:07:43 UTC (rev 1488) +++ trunk/openutils-mgnlmedia/src/main/java/net/sourceforge/openutils/mgnlmedia/media/tags/el/MediaEl.java 2009-10-16 09:46:56 UTC (rev 1489) @@ -42,7 +42,6 @@ import javax.jcr.RepositoryException; import javax.jcr.query.InvalidQueryException; -import javax.servlet.jsp.JspTagException; import net.sourceforge.openutils.mgnlmedia.media.configuration.MediaConfigurationManager; import net.sourceforge.openutils.mgnlmedia.media.configuration.MediaTypeConfiguration; @@ -77,7 +76,7 @@ /** * Get content node for media - * @param uuid media uuid + * @param obj content node or node UUID * @return content node */ public static Content getNode(Object obj) Modified: trunk/openutils-mgnlmedia/src/main/java/net/sourceforge/openutils/mgnlmedia/media/types/MediaTypeHandler.java =================================================================== --- trunk/openutils-mgnlmedia/src/main/java/net/sourceforge/openutils/mgnlmedia/media/types/MediaTypeHandler.java 2009-10-14 15:07:43 UTC (rev 1488) +++ trunk/openutils-mgnlmedia/src/main/java/net/sourceforge/openutils/mgnlmedia/media/types/MediaTypeHandler.java 2009-10-16 09:46:56 UTC (rev 1489) @@ -67,7 +67,8 @@ /** * @param media * @param options - * @return + * @param aaaa + * @return url */ String getUrl(Content media, Map<String, String> options); @@ -175,6 +176,8 @@ * @param f file input stream * @param cleanFileName file name without extension * @param extension file extension + * @exception RepositoryException exception working on repository + * @exception AccessDeniedException exception accessing node */ void saveFromZipFile(Content media, File f, String cleanFileName, String extension) throws AccessDeniedException, RepositoryException; Modified: trunk/openutils-mgnlmedia/src/main/java/net/sourceforge/openutils/mgnlmedia/media/types/impl/BaseTypeHandler.java =================================================================== --- trunk/openutils-mgnlmedia/src/main/java/net/sourceforge/openutils/mgnlmedia/media/types/impl/BaseTypeHandler.java 2009-10-14 15:07:43 UTC (rev 1488) +++ trunk/openutils-mgnlmedia/src/main/java/net/sourceforge/openutils/mgnlmedia/media/types/impl/BaseTypeHandler.java 2009-10-16 09:46:56 UTC (rev 1489) @@ -60,6 +60,9 @@ public abstract class BaseTypeHandler implements MediaTypeHandler { + /** + * Nodedata name where original media content is saved + */ public static final String ORGINAL_NODEDATA_NAME = "original"; /** @@ -82,7 +85,7 @@ */ public String getNewNodeName(MultipartForm form, HttpServletRequest request) { - return form.getParameter(ORGINAL_NODEDATA_NAME + "_" + FileProperties.PROPERTY_FILENAME); + return request.getParameter(ORGINAL_NODEDATA_NAME + "_" + FileProperties.PROPERTY_FILENAME); } /** Modified: trunk/openutils-mgnlmedia/src/main/java/net/sourceforge/openutils/mgnlmedia/media/types/impl/ImageTypeHandler.java =================================================================== --- trunk/openutils-mgnlmedia/src/main/java/net/sourceforge/openutils/mgnlmedia/media/types/impl/ImageTypeHandler.java 2009-10-14 15:07:43 UTC (rev 1488) +++ trunk/openutils-mgnlmedia/src/main/java/net/sourceforge/openutils/mgnlmedia/media/types/impl/ImageTypeHandler.java 2009-10-16 09:46:56 UTC (rev 1489) @@ -30,8 +30,6 @@ import net.sourceforge.openutils.mgnlmedia.media.utils.ImageUtils; import org.apache.commons.lang.StringUtils; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; /** @@ -43,11 +41,6 @@ { /** - * Logger. - */ - private final Logger log = LoggerFactory.getLogger(ImageTypeHandler.class); - - /** * {@inheritDoc} */ public String getThumbnailUrl(Content media) 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 2009-10-14 15:07:43 UTC (rev 1488) +++ trunk/openutils-mgnlmedia/src/main/java/net/sourceforge/openutils/mgnlmedia/media/utils/ImageUtils.java 2009-10-16 09:46:56 UTC (rev 1489) @@ -92,6 +92,9 @@ private static SimpleDateFormat sdf; + /** + * Nodedata name where resolution is saved + */ public static String RESOLUTION_PROPERTY = "resolution"; private static final String[] extensions = new String[]{"jpg", "gif", "png" }; @@ -157,6 +160,7 @@ * @param y new height * @param canvasX canvas width * @param canvasY canvas height + * @param background background color * @return resized image */ public static BufferedImage resizeImage(BufferedImage original, int x, int y, int canvasX, int canvasY, @@ -248,49 +252,13 @@ return resizedImage; } - private static int[] convertHexToRGB(String hexColor) - { - String hex = hexColor.trim(); - if (hex.startsWith("#")) - { - hex = hex.substring(1); - } - if (hex.equals("transparent")) - { - return new int[]{0, 0, 0, 0 }; - } - if (hex.length() == 3) - { - // allow three digit codes like for css - hex = String.valueOf(hex.charAt(0)) - + String.valueOf(hex.charAt(0)) - + String.valueOf(hex.charAt(1)) - + String.valueOf(hex.charAt(1)) - + String.valueOf(hex.charAt(2)) - + String.valueOf(hex.charAt(2)); - } - - int[] rgb = new int[4]; - try - { - // Convert rrggbb string to hex ints - rgb[0] = Integer.parseInt(hex.substring(0, 2), 16); - rgb[1] = Integer.parseInt(hex.substring(2, 4), 16); - rgb[2] = Integer.parseInt(hex.substring(4), 16); - rgb[3] = 255; - } - catch (NumberFormatException e) - { - log.error("NumberFormatException occured during text-to-image conversion: " - + "Attempting to convert Hex [" - + hex - + "] color to RGB color: " - + e.getMessage(), e); - rgb = new int[]{255, 0, 0, 255 }; // red - } - return rgb; - } - + /** + * Create rounded corners on image + * @param original original image + * @param backgroundColor optional background color + * @param radius corners radius + * @return image with rounded corners + */ public static BufferedImage addRoundedCorners(BufferedImage original, Color backgroundColor, int radius) { int originalImageType = getType(original.getColorModel()); @@ -450,6 +418,8 @@ * Get an inputstream for an image and the target file extension * @param image image to get the inputstream from * @param extension target file extension + * @param quality image quality + * @param forceProgressive true if image has to be saved as progressive mode * @return inputstream * @throws IOException */ @@ -462,7 +432,7 @@ try { - Iterator writers; + Iterator<ImageWriter> writers; ImageOutputStream imageOutputStream; ImageWriteParam params; ImageWriter imageWriter; @@ -472,7 +442,7 @@ if (writers != null && writers.hasNext()) { // Fetch the first writer in the list - imageWriter = (ImageWriter) writers.next(); + imageWriter = writers.next(); // Specify the parameters according to those the output file will be written @@ -752,6 +722,7 @@ * Get image for a resolution * @param original original image * @param resolution resolution + * @param params parameters * @return new image */ public static BufferedImage getImageForResolution(BufferedImage original, String resolution, Modified: trunk/openutils-mgnlmedia/src/main/java/net/sourceforge/openutils/mgnlmedia/media/utils/JpegUtils.java =================================================================== --- trunk/openutils-mgnlmedia/src/main/java/net/sourceforge/openutils/mgnlmedia/media/utils/JpegUtils.java 2009-10-14 15:07:43 UTC (rev 1488) +++ trunk/openutils-mgnlmedia/src/main/java/net/sourceforge/openutils/mgnlmedia/media/utils/JpegUtils.java 2009-10-16 09:46:56 UTC (rev 1489) @@ -70,6 +70,9 @@ * raster data to RGB. Technique due to MArk Stephens. Free for any use. See * http://bugs.sun.com/bugdatabase/view_bug.do?bug_id=4799903 or * http://www.mail-archive.com/jav...@ca.../msg03247.html + * @param raster raster image + * @param ycckProfile true for YCCK color profile (else CMYK) + * @return image */ public static BufferedImage createJPEG4(Raster raster, boolean ycckProfile) { @@ -144,7 +147,9 @@ } /** + * process image * @param image + * @return image */ public static BufferedImage processNonStandardImage(NodeData image) { @@ -153,13 +158,13 @@ { // Get an ImageReader. ImageInputStream input = ImageIO.createImageInputStream(is2); - Iterator readers = ImageIO.getImageReaders(input); + Iterator<ImageReader> readers = ImageIO.getImageReaders(input); if (readers == null || !readers.hasNext()) { throw new RuntimeException("No ImageReaders found"); } - ImageReader reader = (ImageReader) readers.next(); + ImageReader reader = readers.next(); reader.setInput(input); String format = reader.getFormatName(); Modified: trunk/openutils-mgnlmedia/src/main/resources/META-INF/media.tld =================================================================== --- trunk/openutils-mgnlmedia/src/main/resources/META-INF/media.tld 2009-10-14 15:07:43 UTC (rev 1488) +++ trunk/openutils-mgnlmedia/src/main/resources/META-INF/media.tld 2009-10-16 09:46:56 UTC (rev 1489) @@ -180,6 +180,28 @@ set player skin </td> </tr> + <tr> + <td> + useEm + </td> + <td> + false + </td> + <td> + if true, and ignoreDimensions is not true it will apply style attribute on img tags with sidth and height in "em". the em values will be computed using as width in pixel * emRatio (see next attribute) + </td> + </tr> + <tr> + <td> + emRatio + </td> + <td> + false + </td> + <td> + float value to convert dimensions from px to em + </td> + </tr> </table> For videos or mp3s it needs the following scripts loaded in page: Modified: trunk/openutils-mgnlmedia/src/test/java/net/sourceforge/openutils/mgnlmedia/media/utils/FileNodeData.java =================================================================== --- trunk/openutils-mgnlmedia/src/test/java/net/sourceforge/openutils/mgnlmedia/media/utils/FileNodeData.java 2009-10-14 15:07:43 UTC (rev 1488) +++ trunk/openutils-mgnlmedia/src/test/java/net/sourceforge/openutils/mgnlmedia/media/utils/FileNodeData.java 2009-10-16 09:46:56 UTC (rev 1489) @@ -54,6 +54,10 @@ private byte[] content; + /** + * @param classpathLocation + * @throws IOException + */ public FileNodeData(String classpathLocation) throws IOException { InputStream is = getClass().getResourceAsStream(classpathLocation); @@ -92,6 +96,7 @@ /** * {@inheritDoc} */ + @SuppressWarnings("unchecked") public Collection getAttributeNames() throws RepositoryException { // TODO Auto-generated method stub Modified: trunk/openutils-mgnlmedia/src/test/java/net/sourceforge/openutils/mgnlmedia/media/utils/ImageUtilsTest.java =================================================================== --- trunk/openutils-mgnlmedia/src/test/java/net/sourceforge/openutils/mgnlmedia/media/utils/ImageUtilsTest.java 2009-10-14 15:07:43 UTC (rev 1488) +++ trunk/openutils-mgnlmedia/src/test/java/net/sourceforge/openutils/mgnlmedia/media/utils/ImageUtilsTest.java 2009-10-16 09:46:56 UTC (rev 1489) @@ -52,6 +52,9 @@ public class ImageUtilsTest { + /** + * + */ @BeforeMethod public void setup() { @@ -65,6 +68,9 @@ }); } + /** + * @throws Exception + */ @Test public void testYcck() throws Exception { @@ -88,6 +94,9 @@ } + /** + * @throws Exception + */ @Test public void testBorders() throws Exception { @@ -113,6 +122,9 @@ } + /** + * @throws Exception + */ @Test public void testBadImageTxt() throws Exception { @@ -122,6 +134,9 @@ Assert.assertNull(bufferedImage); } + /** + * @throws Exception + */ @Test public void testBadImageJpg() throws Exception { This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <fg...@us...> - 2009-12-30 22:31:55
|
Revision: 1566 http://openutils.svn.sourceforge.net/openutils/?rev=1566&view=rev Author: fgiust Date: 2009-12-30 22:31:48 +0000 (Wed, 30 Dec 2009) Log Message: ----------- MEDIA-33 workaround for empty gifs Modified Paths: -------------- trunk/openutils-mgnlmedia/src/main/java/net/sourceforge/openutils/mgnlmedia/media/utils/ImageUtils.java trunk/openutils-mgnlmedia/src/test/java/net/sourceforge/openutils/mgnlmedia/media/utils/ImageUtilsTest.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 2009-12-30 21:42:59 UTC (rev 1565) +++ trunk/openutils-mgnlmedia/src/main/java/net/sourceforge/openutils/mgnlmedia/media/utils/ImageUtils.java 2009-12-30 22:31:48 UTC (rev 1566) @@ -533,12 +533,23 @@ imageOutputStream = ImageIO.createImageOutputStream(out); imageWriter.setOutput(imageOutputStream); + IIOImage iioimage = new IIOImage(image, null, null); + try { // Write the changed Image - IIOImage iioimage = new IIOImage(image, null, null); imageWriter.write(null, iioimage, params); } + catch (NullPointerException e) + { + // http://bugs.sun.com/bugdatabase/view_bug.do?bug_id=6287936 + // GIF writer is buggy for totally transparent gifs + + // workaround: draw a point! + image.createGraphics().drawRect(0, 0, 1, 1); + imageWriter.write(null, iioimage, params); + + } finally { // Close the streams Modified: trunk/openutils-mgnlmedia/src/test/java/net/sourceforge/openutils/mgnlmedia/media/utils/ImageUtilsTest.java =================================================================== --- trunk/openutils-mgnlmedia/src/test/java/net/sourceforge/openutils/mgnlmedia/media/utils/ImageUtilsTest.java 2009-12-30 21:42:59 UTC (rev 1565) +++ trunk/openutils-mgnlmedia/src/test/java/net/sourceforge/openutils/mgnlmedia/media/utils/ImageUtilsTest.java 2009-12-30 22:31:48 UTC (rev 1566) @@ -158,6 +158,8 @@ BufferedImage bufferedImage = ImageUtils.createBufferedImage(badpalette); Assert.assertNotNull(bufferedImage); + bufferedImage = ImageUtils.resizeImage(bufferedImage, 1, 1); + InputStream is = ImageUtils.getStream(bufferedImage, "gif", 0.8F, false); File tempFile = File.createTempFile("image", ".gif"); This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <fg...@us...> - 2010-01-09 17:39:03
|
Revision: 1628 http://openutils.svn.sourceforge.net/openutils/?rev=1628&view=rev Author: fgiust Date: 2010-01-09 17:38:55 +0000 (Sat, 09 Jan 2010) Log Message: ----------- MEDIA-52 updating license headers Modified Paths: -------------- trunk/openutils-mgnlmedia/src/main/etc/header.txt 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/configuration/ImageProcessorsManager.java trunk/openutils-mgnlmedia/src/main/java/net/sourceforge/openutils/mgnlmedia/media/configuration/MediaConfigurationManager.java trunk/openutils-mgnlmedia/src/main/java/net/sourceforge/openutils/mgnlmedia/media/configuration/MediaTypeConfiguration.java trunk/openutils-mgnlmedia/src/main/java/net/sourceforge/openutils/mgnlmedia/media/dialog/DialogCustomSaveHandler.java trunk/openutils-mgnlmedia/src/main/java/net/sourceforge/openutils/mgnlmedia/media/dialog/DialogFileAudio.java trunk/openutils-mgnlmedia/src/main/java/net/sourceforge/openutils/mgnlmedia/media/dialog/DialogFileImage.java trunk/openutils-mgnlmedia/src/main/java/net/sourceforge/openutils/mgnlmedia/media/dialog/DialogFileNoPreview.java trunk/openutils-mgnlmedia/src/main/java/net/sourceforge/openutils/mgnlmedia/media/dialog/DialogFileVideo.java trunk/openutils-mgnlmedia/src/main/java/net/sourceforge/openutils/mgnlmedia/media/dialog/DialogMetadata.java trunk/openutils-mgnlmedia/src/main/java/net/sourceforge/openutils/mgnlmedia/media/dialog/DialogSelectMedia.java trunk/openutils-mgnlmedia/src/main/java/net/sourceforge/openutils/mgnlmedia/media/dialog/LayerDialog.java trunk/openutils-mgnlmedia/src/main/java/net/sourceforge/openutils/mgnlmedia/media/dialog/LayerDialogMVC.java trunk/openutils-mgnlmedia/src/main/java/net/sourceforge/openutils/mgnlmedia/media/lifecycle/MediaModule.java trunk/openutils-mgnlmedia/src/main/java/net/sourceforge/openutils/mgnlmedia/media/pages/MediaBean.java trunk/openutils-mgnlmedia/src/main/java/net/sourceforge/openutils/mgnlmedia/media/pages/MediaBrowserPage.java trunk/openutils-mgnlmedia/src/main/java/net/sourceforge/openutils/mgnlmedia/media/pages/MediaFolderSelectionPage.java 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/MediaSearchPage.java trunk/openutils-mgnlmedia/src/main/java/net/sourceforge/openutils/mgnlmedia/media/pages/MessagesTemplatedMVCHandler.java trunk/openutils-mgnlmedia/src/main/java/net/sourceforge/openutils/mgnlmedia/media/processors/BaseImageResolutionProcessor.java trunk/openutils-mgnlmedia/src/main/java/net/sourceforge/openutils/mgnlmedia/media/processors/BlackAndWhitePostProcessor.java trunk/openutils-mgnlmedia/src/main/java/net/sourceforge/openutils/mgnlmedia/media/processors/FitInAndFillWithBandsImageResolutionProcessor.java trunk/openutils-mgnlmedia/src/main/java/net/sourceforge/openutils/mgnlmedia/media/processors/FitInImageResolutionProcessor.java trunk/openutils-mgnlmedia/src/main/java/net/sourceforge/openutils/mgnlmedia/media/processors/ImagePostProcessor.java trunk/openutils-mgnlmedia/src/main/java/net/sourceforge/openutils/mgnlmedia/media/processors/ImageResolutionProcessor.java trunk/openutils-mgnlmedia/src/main/java/net/sourceforge/openutils/mgnlmedia/media/processors/LogSizePostProcessor.java trunk/openutils-mgnlmedia/src/main/java/net/sourceforge/openutils/mgnlmedia/media/processors/ResizeCropCenteredImageResolutionProcessor.java trunk/openutils-mgnlmedia/src/main/java/net/sourceforge/openutils/mgnlmedia/media/processors/ResizeNoCropImageResolutionProcessor.java trunk/openutils-mgnlmedia/src/main/java/net/sourceforge/openutils/mgnlmedia/media/processors/RoundedCornersProcessor.java trunk/openutils-mgnlmedia/src/main/java/net/sourceforge/openutils/mgnlmedia/media/save/MediaCustomSaveHandler.java trunk/openutils-mgnlmedia/src/main/java/net/sourceforge/openutils/mgnlmedia/media/setup/MediaModuleVersionHandler.java trunk/openutils-mgnlmedia/src/main/java/net/sourceforge/openutils/mgnlmedia/media/setup/RemoveResolutionsNodeTask.java trunk/openutils-mgnlmedia/src/main/java/net/sourceforge/openutils/mgnlmedia/media/setup/RenameThumbToImageTask.java trunk/openutils-mgnlmedia/src/main/java/net/sourceforge/openutils/mgnlmedia/media/setup/SamplesExtractionTask.java trunk/openutils-mgnlmedia/src/main/java/net/sourceforge/openutils/mgnlmedia/media/tags/el/MediaEl.java trunk/openutils-mgnlmedia/src/main/java/net/sourceforge/openutils/mgnlmedia/media/tree/JcrBrowserWithNodeTypeTreeConfiguration.java trunk/openutils-mgnlmedia/src/main/java/net/sourceforge/openutils/mgnlmedia/media/tree/MediaBrowserConfiguration.java trunk/openutils-mgnlmedia/src/main/java/net/sourceforge/openutils/mgnlmedia/media/tree/MediaModuleTree.java trunk/openutils-mgnlmedia/src/main/java/net/sourceforge/openutils/mgnlmedia/media/tree/MediaModuleTreeConfiguration.java trunk/openutils-mgnlmedia/src/main/java/net/sourceforge/openutils/mgnlmedia/media/tree/MediaModuleTreeMVCHandler.java trunk/openutils-mgnlmedia/src/main/java/net/sourceforge/openutils/mgnlmedia/media/types/MediaTypeHandler.java trunk/openutils-mgnlmedia/src/main/java/net/sourceforge/openutils/mgnlmedia/media/types/impl/AudioTypeHandler.java trunk/openutils-mgnlmedia/src/main/java/net/sourceforge/openutils/mgnlmedia/media/types/impl/BaseTypeHandler.java trunk/openutils-mgnlmedia/src/main/java/net/sourceforge/openutils/mgnlmedia/media/types/impl/ImageTypeHandler.java trunk/openutils-mgnlmedia/src/main/java/net/sourceforge/openutils/mgnlmedia/media/types/impl/MediaWithPreviewImageTypeHandler.java trunk/openutils-mgnlmedia/src/main/java/net/sourceforge/openutils/mgnlmedia/media/types/impl/VideoTypeHandler.java trunk/openutils-mgnlmedia/src/main/java/net/sourceforge/openutils/mgnlmedia/media/types/impl/YouTubeVideoTypeHandler.java trunk/openutils-mgnlmedia/src/main/java/net/sourceforge/openutils/mgnlmedia/media/uri/MediaURI2RepositoryMapping.java trunk/openutils-mgnlmedia/src/main/java/net/sourceforge/openutils/mgnlmedia/media/utils/BadImageFormatException.java 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/JpegUtils.java trunk/openutils-mgnlmedia/src/main/java/net/sourceforge/openutils/mgnlmedia/media/utils/MediaLoadUtils.java trunk/openutils-mgnlmedia/src/main/resources/META-INF/magnolia/media.xml trunk/openutils-mgnlmedia/src/main/resources/info/magnolia/cms/gui/control/MediaTreeAddress.ftl trunk/openutils-mgnlmedia/src/main/resources/info/magnolia/cms/gui/control/MediaTreeFooter.ftl trunk/openutils-mgnlmedia/src/main/resources/net/sourceforge/openutils/mgnlmedia/media/lang/messages_en.properties trunk/openutils-mgnlmedia/src/main/resources/net/sourceforge/openutils/mgnlmedia/media/lang/messages_it.properties trunk/openutils-mgnlmedia/src/main/resources/net/sourceforge/openutils/mgnlmedia/media/pages/MediaBrowserPage.html trunk/openutils-mgnlmedia/src/main/resources/net/sourceforge/openutils/mgnlmedia/media/pages/MediaFolderSelectionPage.html trunk/openutils-mgnlmedia/src/main/resources/net/sourceforge/openutils/mgnlmedia/media/pages/MediaFolderViewPage.html trunk/openutils-mgnlmedia/src/main/resources/net/sourceforge/openutils/mgnlmedia/media/pages/MediaSearchPage.html trunk/openutils-mgnlmedia/src/test/java/net/sourceforge/openutils/mgnlmedia/media/utils/FileNodeData.java trunk/openutils-mgnlmedia/src/test/java/net/sourceforge/openutils/mgnlmedia/media/utils/ImageProcessorsManagerMock.java trunk/openutils-mgnlmedia/src/test/java/net/sourceforge/openutils/mgnlmedia/media/utils/ImageUtilsTest.java Modified: trunk/openutils-mgnlmedia/src/main/etc/header.txt =================================================================== --- trunk/openutils-mgnlmedia/src/main/etc/header.txt 2010-01-09 17:32:04 UTC (rev 1627) +++ trunk/openutils-mgnlmedia/src/main/etc/header.txt 2010-01-09 17:38:55 UTC (rev 1628) @@ -2,21 +2,15 @@ ${name} (${url}) Copyright (C)${year}, Openmind S.r.l. http://www.openmindonline.it + This program is free software: you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation, either version 3 of the License, or + (at your option) any later version. -This library is free software; you can redistribute it and/or -modify it under the terms of the GNU Lesser General Public -License as published by the Free Software Foundation; either -version 2.1 of the License, or (at your option) any later version. -You may obtain a copy of the License at + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. -http://www.gnu.org/licenses/lgpl-2.1.html - -This library is distributed in the hope that it will be useful, -but WITHOUT ANY WARRANTY; without even the implied warranty of -MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU -Lesser General Public License for more details. - -You should have received a copy of the GNU Lesser General Public -License along with this library; if not, write to the Free Software -Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA - + You should have received a copy of the GNU General Public License + along with this program. If not, see <http://www.gnu.org/licenses/>. \ No newline at end of file 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 2010-01-09 17:32:04 UTC (rev 1627) +++ trunk/openutils-mgnlmedia/src/main/java/net/sourceforge/openutils/mgnlmedia/media/commands/MediaActivationCommand.java 2010-01-09 17:38:55 UTC (rev 1628) @@ -3,23 +3,18 @@ * Magnolia SimpleMedia Module (http://www.openmindlab.com/lab/products/media.html) * Copyright (C)2008 - 2010, Openmind S.r.l. http://www.openmindonline.it * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 2.1 of the License, or (at your option) any later version. - * You may obtain a copy of the License at + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. * - * http://www.gnu.org/licenses/lgpl-2.1.html - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with this library; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + * You should have received a copy of the GNU General Public License + * along with this program. If not, see <http://www.gnu.org/licenses/>. */ package net.sourceforge.openutils.mgnlmedia.media.commands; Modified: trunk/openutils-mgnlmedia/src/main/java/net/sourceforge/openutils/mgnlmedia/media/configuration/ImageProcessorsManager.java =================================================================== --- trunk/openutils-mgnlmedia/src/main/java/net/sourceforge/openutils/mgnlmedia/media/configuration/ImageProcessorsManager.java 2010-01-09 17:32:04 UTC (rev 1627) +++ trunk/openutils-mgnlmedia/src/main/java/net/sourceforge/openutils/mgnlmedia/media/configuration/ImageProcessorsManager.java 2010-01-09 17:38:55 UTC (rev 1628) @@ -3,23 +3,18 @@ * Magnolia SimpleMedia Module (http://www.openmindlab.com/lab/products/media.html) * Copyright (C)2008 - 2010, Openmind S.r.l. http://www.openmindonline.it * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 2.1 of the License, or (at your option) any later version. - * You may obtain a copy of the License at + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. * - * http://www.gnu.org/licenses/lgpl-2.1.html - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with this library; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + * You should have received a copy of the GNU General Public License + * along with this program. If not, see <http://www.gnu.org/licenses/>. */ package net.sourceforge.openutils.mgnlmedia.media.configuration; Modified: trunk/openutils-mgnlmedia/src/main/java/net/sourceforge/openutils/mgnlmedia/media/configuration/MediaConfigurationManager.java =================================================================== --- trunk/openutils-mgnlmedia/src/main/java/net/sourceforge/openutils/mgnlmedia/media/configuration/MediaConfigurationManager.java 2010-01-09 17:32:04 UTC (rev 1627) +++ trunk/openutils-mgnlmedia/src/main/java/net/sourceforge/openutils/mgnlmedia/media/configuration/MediaConfigurationManager.java 2010-01-09 17:38:55 UTC (rev 1628) @@ -3,23 +3,18 @@ * Magnolia SimpleMedia Module (http://www.openmindlab.com/lab/products/media.html) * Copyright (C)2008 - 2010, Openmind S.r.l. http://www.openmindonline.it * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 2.1 of the License, or (at your option) any later version. - * You may obtain a copy of the License at + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. * - * http://www.gnu.org/licenses/lgpl-2.1.html - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with this library; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + * You should have received a copy of the GNU General Public License + * along with this program. If not, see <http://www.gnu.org/licenses/>. */ package net.sourceforge.openutils.mgnlmedia.media.configuration; Modified: trunk/openutils-mgnlmedia/src/main/java/net/sourceforge/openutils/mgnlmedia/media/configuration/MediaTypeConfiguration.java =================================================================== --- trunk/openutils-mgnlmedia/src/main/java/net/sourceforge/openutils/mgnlmedia/media/configuration/MediaTypeConfiguration.java 2010-01-09 17:32:04 UTC (rev 1627) +++ trunk/openutils-mgnlmedia/src/main/java/net/sourceforge/openutils/mgnlmedia/media/configuration/MediaTypeConfiguration.java 2010-01-09 17:38:55 UTC (rev 1628) @@ -3,23 +3,18 @@ * Magnolia SimpleMedia Module (http://www.openmindlab.com/lab/products/media.html) * Copyright (C)2008 - 2010, Openmind S.r.l. http://www.openmindonline.it * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 2.1 of the License, or (at your option) any later version. - * You may obtain a copy of the License at + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. * - * http://www.gnu.org/licenses/lgpl-2.1.html - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with this library; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + * You should have received a copy of the GNU General Public License + * along with this program. If not, see <http://www.gnu.org/licenses/>. */ package net.sourceforge.openutils.mgnlmedia.media.configuration; Modified: trunk/openutils-mgnlmedia/src/main/java/net/sourceforge/openutils/mgnlmedia/media/dialog/DialogCustomSaveHandler.java =================================================================== --- trunk/openutils-mgnlmedia/src/main/java/net/sourceforge/openutils/mgnlmedia/media/dialog/DialogCustomSaveHandler.java 2010-01-09 17:32:04 UTC (rev 1627) +++ trunk/openutils-mgnlmedia/src/main/java/net/sourceforge/openutils/mgnlmedia/media/dialog/DialogCustomSaveHandler.java 2010-01-09 17:38:55 UTC (rev 1628) @@ -3,23 +3,18 @@ * Magnolia SimpleMedia Module (http://www.openmindlab.com/lab/products/media.html) * Copyright (C)2008 - 2010, Openmind S.r.l. http://www.openmindonline.it * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 2.1 of the License, or (at your option) any later version. - * You may obtain a copy of the License at + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. * - * http://www.gnu.org/licenses/lgpl-2.1.html - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with this library; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + * You should have received a copy of the GNU General Public License + * along with this program. If not, see <http://www.gnu.org/licenses/>. */ package net.sourceforge.openutils.mgnlmedia.media.dialog; Modified: trunk/openutils-mgnlmedia/src/main/java/net/sourceforge/openutils/mgnlmedia/media/dialog/DialogFileAudio.java =================================================================== --- trunk/openutils-mgnlmedia/src/main/java/net/sourceforge/openutils/mgnlmedia/media/dialog/DialogFileAudio.java 2010-01-09 17:32:04 UTC (rev 1627) +++ trunk/openutils-mgnlmedia/src/main/java/net/sourceforge/openutils/mgnlmedia/media/dialog/DialogFileAudio.java 2010-01-09 17:38:55 UTC (rev 1628) @@ -3,23 +3,18 @@ * Magnolia SimpleMedia Module (http://www.openmindlab.com/lab/products/media.html) * Copyright (C)2008 - 2010, Openmind S.r.l. http://www.openmindonline.it * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 2.1 of the License, or (at your option) any later version. - * You may obtain a copy of the License at + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. * - * http://www.gnu.org/licenses/lgpl-2.1.html - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with this library; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + * You should have received a copy of the GNU General Public License + * along with this program. If not, see <http://www.gnu.org/licenses/>. */ package net.sourceforge.openutils.mgnlmedia.media.dialog; Modified: trunk/openutils-mgnlmedia/src/main/java/net/sourceforge/openutils/mgnlmedia/media/dialog/DialogFileImage.java =================================================================== --- trunk/openutils-mgnlmedia/src/main/java/net/sourceforge/openutils/mgnlmedia/media/dialog/DialogFileImage.java 2010-01-09 17:32:04 UTC (rev 1627) +++ trunk/openutils-mgnlmedia/src/main/java/net/sourceforge/openutils/mgnlmedia/media/dialog/DialogFileImage.java 2010-01-09 17:38:55 UTC (rev 1628) @@ -3,23 +3,18 @@ * Magnolia SimpleMedia Module (http://www.openmindlab.com/lab/products/media.html) * Copyright (C)2008 - 2010, Openmind S.r.l. http://www.openmindonline.it * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 2.1 of the License, or (at your option) any later version. - * You may obtain a copy of the License at + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. * - * http://www.gnu.org/licenses/lgpl-2.1.html - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with this library; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + * You should have received a copy of the GNU General Public License + * along with this program. If not, see <http://www.gnu.org/licenses/>. */ package net.sourceforge.openutils.mgnlmedia.media.dialog; Modified: trunk/openutils-mgnlmedia/src/main/java/net/sourceforge/openutils/mgnlmedia/media/dialog/DialogFileNoPreview.java =================================================================== --- trunk/openutils-mgnlmedia/src/main/java/net/sourceforge/openutils/mgnlmedia/media/dialog/DialogFileNoPreview.java 2010-01-09 17:32:04 UTC (rev 1627) +++ trunk/openutils-mgnlmedia/src/main/java/net/sourceforge/openutils/mgnlmedia/media/dialog/DialogFileNoPreview.java 2010-01-09 17:38:55 UTC (rev 1628) @@ -3,23 +3,18 @@ * Magnolia SimpleMedia Module (http://www.openmindlab.com/lab/products/media.html) * Copyright (C)2008 - 2010, Openmind S.r.l. http://www.openmindonline.it * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 2.1 of the License, or (at your option) any later version. - * You may obtain a copy of the License at + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. * - * http://www.gnu.org/licenses/lgpl-2.1.html - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with this library; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + * You should have received a copy of the GNU General Public License + * along with this program. If not, see <http://www.gnu.org/licenses/>. */ package net.sourceforge.openutils.mgnlmedia.media.dialog; Modified: trunk/openutils-mgnlmedia/src/main/java/net/sourceforge/openutils/mgnlmedia/media/dialog/DialogFileVideo.java =================================================================== --- trunk/openutils-mgnlmedia/src/main/java/net/sourceforge/openutils/mgnlmedia/media/dialog/DialogFileVideo.java 2010-01-09 17:32:04 UTC (rev 1627) +++ trunk/openutils-mgnlmedia/src/main/java/net/sourceforge/openutils/mgnlmedia/media/dialog/DialogFileVideo.java 2010-01-09 17:38:55 UTC (rev 1628) @@ -3,23 +3,18 @@ * Magnolia SimpleMedia Module (http://www.openmindlab.com/lab/products/media.html) * Copyright (C)2008 - 2010, Openmind S.r.l. http://www.openmindonline.it * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 2.1 of the License, or (at your option) any later version. - * You may obtain a copy of the License at + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. * - * http://www.gnu.org/licenses/lgpl-2.1.html - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with this library; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + * You should have received a copy of the GNU General Public License + * along with this program. If not, see <http://www.gnu.org/licenses/>. */ package net.sourceforge.openutils.mgnlmedia.media.dialog; Modified: trunk/openutils-mgnlmedia/src/main/java/net/sourceforge/openutils/mgnlmedia/media/dialog/DialogMetadata.java =================================================================== --- trunk/openutils-mgnlmedia/src/main/java/net/sourceforge/openutils/mgnlmedia/media/dialog/DialogMetadata.java 2010-01-09 17:32:04 UTC (rev 1627) +++ trunk/openutils-mgnlmedia/src/main/java/net/sourceforge/openutils/mgnlmedia/media/dialog/DialogMetadata.java 2010-01-09 17:38:55 UTC (rev 1628) @@ -3,23 +3,18 @@ * Magnolia SimpleMedia Module (http://www.openmindlab.com/lab/products/media.html) * Copyright (C)2008 - 2010, Openmind S.r.l. http://www.openmindonline.it * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 2.1 of the License, or (at your option) any later version. - * You may obtain a copy of the License at + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. * - * http://www.gnu.org/licenses/lgpl-2.1.html - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with this library; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + * You should have received a copy of the GNU General Public License + * along with this program. If not, see <http://www.gnu.org/licenses/>. */ package net.sourceforge.openutils.mgnlmedia.media.dialog; Modified: trunk/openutils-mgnlmedia/src/main/java/net/sourceforge/openutils/mgnlmedia/media/dialog/DialogSelectMedia.java =================================================================== --- trunk/openutils-mgnlmedia/src/main/java/net/sourceforge/openutils/mgnlmedia/media/dialog/DialogSelectMedia.java 2010-01-09 17:32:04 UTC (rev 1627) +++ trunk/openutils-mgnlmedia/src/main/java/net/sourceforge/openutils/mgnlmedia/media/dialog/DialogSelectMedia.java 2010-01-09 17:38:55 UTC (rev 1628) @@ -3,23 +3,18 @@ * Magnolia SimpleMedia Module (http://www.openmindlab.com/lab/products/media.html) * Copyright (C)2008 - 2010, Openmind S.r.l. http://www.openmindonline.it * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 2.1 of the License, or (at your option) any later version. - * You may obtain a copy of the License at + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. * - * http://www.gnu.org/licenses/lgpl-2.1.html - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with this library; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + * You should have received a copy of the GNU General Public License + * along with this program. If not, see <http://www.gnu.org/licenses/>. */ package net.sourceforge.openutils.mgnlmedia.media.dialog; Modified: trunk/openutils-mgnlmedia/src/main/java/net/sourceforge/openutils/mgnlmedia/media/dialog/LayerDialog.java =================================================================== --- trunk/openutils-mgnlmedia/src/main/java/net/sourceforge/openutils/mgnlmedia/media/dialog/LayerDialog.java 2010-01-09 17:32:04 UTC (rev 1627) +++ trunk/openutils-mgnlmedia/src/main/java/net/sourceforge/openutils/mgnlmedia/media/dialog/LayerDialog.java 2010-01-09 17:38:55 UTC (rev 1628) @@ -3,23 +3,18 @@ * Magnolia SimpleMedia Module (http://www.openmindlab.com/lab/products/media.html) * Copyright (C)2008 - 2010, Openmind S.r.l. http://www.openmindonline.it * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 2.1 of the License, or (at your option) any later version. - * You may obtain a copy of the License at + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. * - * http://www.gnu.org/licenses/lgpl-2.1.html - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with this library; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + * You should have received a copy of the GNU General Public License + * along with this program. If not, see <http://www.gnu.org/licenses/>. */ package net.sourceforge.openutils.mgnlmedia.media.dialog; Modified: trunk/openutils-mgnlmedia/src/main/java/net/sourceforge/openutils/mgnlmedia/media/dialog/LayerDialogMVC.java =================================================================== --- trunk/openutils-mgnlmedia/src/main/java/net/sourceforge/openutils/mgnlmedia/media/dialog/LayerDialogMVC.java 2010-01-09 17:32:04 UTC (rev 1627) +++ trunk/openutils-mgnlmedia/src/main/java/net/sourceforge/openutils/mgnlmedia/media/dialog/LayerDialogMVC.java 2010-01-09 17:38:55 UTC (rev 1628) @@ -3,23 +3,18 @@ * Magnolia SimpleMedia Module (http://www.openmindlab.com/lab/products/media.html) * Copyright (C)2008 - 2010, Openmind S.r.l. http://www.openmindonline.it * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 2.1 of the License, or (at your option) any later version. - * You may obtain a copy of the License at + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. * - * http://www.gnu.org/licenses/lgpl-2.1.html - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with this library; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + * You should have received a copy of the GNU General Public License + * along with this program. If not, see <http://www.gnu.org/licenses/>. */ package net.sourceforge.openutils.mgnlmedia.media.dialog; Modified: trunk/openutils-mgnlmedia/src/main/java/net/sourceforge/openutils/mgnlmedia/media/lifecycle/MediaModule.java =================================================================== --- trunk/openutils-mgnlmedia/src/main/java/net/sourceforge/openutils/mgnlmedia/media/lifecycle/MediaModule.java 2010-01-09 17:32:04 UTC (rev 1627) +++ trunk/openutils-mgnlmedia/src/main/java/net/sourceforge/openutils/mgnlmedia/media/lifecycle/MediaModule.java 2010-01-09 17:38:55 UTC (rev 1628) @@ -3,23 +3,18 @@ * Magnolia SimpleMedia Module (http://www.openmindlab.com/lab/products/media.html) * Copyright (C)2008 - 2010, Openmind S.r.l. http://www.openmindonline.it * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 2.1 of the License, or (at your option) any later version. - * You may obtain a copy of the License at + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. * - * http://www.gnu.org/licenses/lgpl-2.1.html - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with this library; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + * You should have received a copy of the GNU General Public License + * along with this program. If not, see <http://www.gnu.org/licenses/>. */ package net.sourceforge.openutils.mgnlmedia.media.lifecycle; Modified: trunk/openutils-mgnlmedia/src/main/java/net/sourceforge/openutils/mgnlmedia/media/pages/MediaBean.java =================================================================== --- trunk/openutils-mgnlmedia/src/main/java/net/sourceforge/openutils/mgnlmedia/media/pages/MediaBean.java 2010-01-09 17:32:04 UTC (rev 1627) +++ trunk/openutils-mgnlmedia/src/main/java/net/sourceforge/openutils/mgnlmedia/media/pages/MediaBean.java 2010-01-09 17:38:55 UTC (rev 1628) @@ -3,23 +3,18 @@ * Magnolia SimpleMedia Module (http://www.openmindlab.com/lab/products/media.html) * Copyright (C)2008 - 2010, Openmind S.r.l. http://www.openmindonline.it * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 2.1 of the License, or (at your option) any later version. - * You may obtain a copy of the License at + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. * - * http://www.gnu.org/licenses/lgpl-2.1.html - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with this library; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + * You should have received a copy of the GNU General Public License + * along with this program. If not, see <http://www.gnu.org/licenses/>. */ package net.sourceforge.openutils.mgnlmedia.media.pages; Modified: trunk/openutils-mgnlmedia/src/main/java/net/sourceforge/openutils/mgnlmedia/media/pages/MediaBrowserPage.java =================================================================== --- trunk/openutils-mgnlmedia/src/main/java/net/sourceforge/openutils/mgnlmedia/media/pages/MediaBrowserPage.java 2010-01-09 17:32:04 UTC (rev 1627) +++ trunk/openutils-mgnlmedia/src/main/java/net/sourceforge/openutils/mgnlmedia/media/pages/MediaBrowserPage.java 2010-01-09 17:38:55 UTC (rev 1628) @@ -3,23 +3,18 @@ * Magnolia SimpleMedia Module (http://www.openmindlab.com/lab/products/media.html) * Copyright (C)2008 - 2010, Openmind S.r.l. http://www.openmindonline.it * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 2.1 of the License, or (at your option) any later version. - * You may obtain a copy of the License at + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. * - * http://www.gnu.org/licenses/lgpl-2.1.html - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with this library; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + * You should have received a copy of the GNU General Public License + * along with this program. If not, see <http://www.gnu.org/licenses/>. */ package net.sourceforge.openutils.mgnlmedia.media.pages; Modified: trunk/openutils-mgnlmedia/src/main/java/net/sourceforge/openutils/mgnlmedia/media/pages/MediaFolderSelectionPage.java =================================================================== --- trunk/openutils-mgnlmedia/src/main/java/net/sourceforge/openutils/mgnlmedia/media/pages/MediaFolderSelectionPage.java 2010-01-09 17:32:04 UTC (rev 1627) +++ trunk/openutils-mgnlmedia/src/main/java/net/sourceforge/openutils/mgnlmedia/media/pages/MediaFolderSelectionPage.java 2010-01-09 17:38:55 UTC (rev 1628) @@ -3,23 +3,18 @@ * Magnolia SimpleMedia Module (http://www.openmindlab.com/lab/products/media.html) * Copyright (C)2008 - 2010, Openmind S.r.l. http://www.openmindonline.it * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 2.1 of the License, or (at your option) any later version. - * You may obtain a copy of the License at + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. * - * http://www.gnu.org/licenses/lgpl-2.1.html - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with this library; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + * You should have received a copy of the GNU General Public License + * along with this program. If not, see <http://www.gnu.org/licenses/>. */ package net.sourceforge.openutils.mgnlmedia.media.pages; 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 2010-01-09 17:32:04 UTC (rev 1627) +++ trunk/openutils-mgnlmedia/src/main/java/net/sourceforge/openutils/mgnlmedia/media/pages/MediaFolderViewPage.java 2010-01-09 17:38:55 UTC (rev 1628) @@ -3,23 +3,18 @@ * Magnolia SimpleMedia Module (http://www.openmindlab.com/lab/products/media.html) * Copyright (C)2008 - 2010, Openmind S.r.l. http://www.openmindonline.it * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 2.1 of the License, or (at your option) any later version. - * You may obtain a copy of the License at + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. * - * http://www.gnu.org/licenses/lgpl-2.1.html - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with this library; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + * You should have received a copy of the GNU General Public License + * along with this program. If not, see <http://www.gnu.org/licenses/>. */ package net.sourceforge.openutils.mgnlmedia.media.pages; Modified: trunk/openutils-mgnlmedia/src/main/java/net/sourceforge/openutils/mgnlmedia/media/pages/MediaSearchPage.java =================================================================== --- trunk/openutils-mgnlmedia/src/main/java/net/sourceforge/openutils/mgnlmedia/media/pages/MediaSearchPage.java 2010-01-09 17:32:04 UTC (rev 1627) +++ trunk/openutils-mgnlmedia/src/main/java/net/sourceforge/openutils/mgnlmedia/media/pages/MediaSearchPage.java 2010-01-09 17:38:55 UTC (rev 1628) @@ -3,23 +3,18 @@ * Magnolia SimpleMedia Module (http://www.openmindlab.com/lab/products/media.html) * Copyright (C)2008 - 2010, Openmind S.r.l. http://www.openmindonline.it * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 2.1 of the License, or (at your option) any later version. - * You may obtain a copy of the License at + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. * - * http://www.gnu.org/licenses/lgpl-2.1.html - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with this library; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + * You should have received a copy of the GNU General Public License + * along with this program. If not, see <http://www.gnu.org/licenses/>. */ package net.sourceforge.openutils.mgnlmedia.media.pages; Modified: trunk/openutils-mgnlmedia/src/main/java/net/sourceforge/openutils/mgnlmedia/media/pages/MessagesTemplatedMVCHandler.java =================================================================== --- trunk/openutils-mgnlmedia/src/main/java/net/sourceforge/openutils/mgnlmedia/media/pages/MessagesTemplatedMVCHandler.java 2010-01-09 17:32:04 UTC (rev 1627) +++ trunk/openutils-mgnlmedia/src/main/java/net/sourceforge/openutils/mgnlmedia/media/pages/MessagesTemplatedMVCHandler.java 2010-01-09 17:38:55 UTC (rev 1628) @@ -3,23 +3,18 @@ * Magnolia SimpleMedia Module (http://www.openmindlab.com/lab/products/media.html) * Copyright (C)2008 - 2010, Openmind S.r.l. http://www.openmindonline.it * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 2.1 of the License, or (at your option) any later version. - * You may obtain a copy of the License at + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. * - * http://www.gnu.org/licenses/lgpl-2.1.html - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with this library; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + * You should have received a copy of the GNU General Public License + * along with this program. If not, see <http://www.gnu.org/licenses/>. */ package net.sourceforge.openutils.mgnlmedia.media.pages; Modified: trunk/openutils-mgnlmedia/src/main/java/net/sourceforge/openutils/mgnlmedia/media/processors/BaseImageResolutionProcessor.java =================================================================== --- trunk/openutils-mgnlmedia/src/main/java/net/sourceforge/openutils/mgnlmedia/media/processors/BaseImageResolutionProcessor.java 2010-01-09 17:32:04 UTC (rev 1627) +++ trunk/openutils-mgnlmedia/src/main/java/net/sourceforge/openutils/mgnlmedia/media/processors/BaseImageResolutionProcessor.java 2010-01-09 17:38:55 UTC (rev 1628) @@ -3,23 +3,18 @@ * Magnolia SimpleMedia Module (http://www.openmindlab.com/lab/products/media.html) * Copyright (C)2008 - 2010, Openmind S.r.l. http://www.openmindonline.it * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 2.1 of the License, or (at your option) any later version. - * You may obtain a copy of the License at + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. * - * http://www.gnu.org/licenses/lgpl-2.1.html - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with this library; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + * You should have received a copy of the GNU General Public License + * along with this program. If not, see <http://www.gnu.org/licenses/>. */ package net.sourceforge.openutils.mgnlmedia.media.processors; Modified: trunk/openutils-mgnlmedia/src/main/java/net/sourceforge/openutils/mgnlmedia/media/processors/BlackAndWhitePostProcessor.java =================================================================== --- trunk/openutils-mgnlmedia/src/main/java/net/sourceforge/openutils/mgnlmedia/media/processors/BlackAndWhitePostProcessor.java 2010-01-09 17:32:04 UTC (rev 1627) +++ trunk/openutils-mgnlmedia/src/main/java/net/sourceforge/openutils/mgnlmedia/media/processors/BlackAndWhitePostProcessor.java 2010-01-09 17:38:55 UTC (rev 1628) @@ -3,23 +3,18 @@ * Magnolia SimpleMedia Module (http://www.openmindlab.com/lab/products/media.html) * Copyright (C)2008 - 2010, Openmind S.r.l. http://www.openmindonline.it * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 2.1 of the License, or (at your option) any later version. - * You may obtain a copy of the License at + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. * - * http://www.gnu.org/licenses/lgpl-2.1.html - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with this library; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + * You should have received a copy of the GNU General Public License + * along with this program. If not, see <http://www.gnu.org/licenses/>. */ package net.sourceforge.openutils.mgnlmedia.media.processors; Modified: trunk/openutils-mgnlmedia/src/main/java/net/sourceforge/openutils/mgnlmedia/media/processors/FitInAndFillWithBandsImageResolutionProcessor.java =================================================================== --- trunk/openutils-mgnlmedia/src/main/java/net/sourceforge/openutils/mgnlmedia/media/processors/FitInAndFillWithBandsImageResolutionProcessor.java 2010-01-09 17:32:04 UTC (rev 1627) +++ trunk/openutils-mgnlmedia/src/main/java/net/sourceforge/openutils/mgnlmedia/media/processors/FitInAndFillWithBandsImageResolutionProcessor.java 2010-01-09 17:38:55 UTC (rev 1628) @@ -3,23 +3,18 @@ * Magnolia SimpleMedia Module (http://www.openmindlab.com/lab/products/media.html) * Copyright (C)2008 - 2010, Openmind S.r.l. http://www.openmindonline.it * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the Li... [truncated message content] |
From: <fg...@us...> - 2010-06-07 15:59:37
|
Revision: 2629 http://openutils.svn.sourceforge.net/openutils/?rev=2629&view=rev Author: fgiust Date: 2010-06-07 15:59:31 +0000 (Mon, 07 Jun 2010) Log Message: ----------- MEDIA-72 some images have inverted colors when they are resized Modified Paths: -------------- 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/JpegUtils.java trunk/openutils-mgnlmedia/src/test/java/net/sourceforge/openutils/mgnlmedia/media/utils/FileNodeData.java trunk/openutils-mgnlmedia/src/test/java/net/sourceforge/openutils/mgnlmedia/media/utils/ImageUtilsTest.java Added Paths: ----------- trunk/openutils-mgnlmedia/src/test/resources/images/sample_invalid_colors.jpg 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 2010-06-07 15:09:41 UTC (rev 2628) +++ trunk/openutils-mgnlmedia/src/main/java/net/sourceforge/openutils/mgnlmedia/media/utils/ImageUtils.java 2010-06-07 15:59:31 UTC (rev 2629) @@ -96,7 +96,7 @@ */ public static String RESOLUTION_PROPERTY = "resolution"; - private static final String[] extensions = new String[]{"jpg", "gif", "png" }; + private static final String[] extensions = new String[]{"jpg", "jpeg", "gif", "png" }; static { @@ -943,22 +943,32 @@ InputStream is = image.getStream(); try { - return ImageIO.read(is); - } - catch (IOException e) - { - // CMYK jpeg can't be read be ImageIO - // Caused by: javax.imageio.IIOException: Unsupported Image Type - BufferedImage result = JpegUtils.processNonStandardImage(image); - if (result == null) + String ext = image.getAttribute("extension"); + + if (StringUtils.equalsIgnoreCase(ext, "jpg") || StringUtils.equalsIgnoreCase(ext, "jpeg")) { - // throw the original exception back - throw new BadImageFormatException("Unable to handle " + image.getHandle(), e); + try + { + return JpegUtils.processNonStandardImage(image); + } + catch (Throwable e) + { + // sun classes may not be available or other errors occurred, try with the standard ImageIO + log + .debug( + "Unable to process image " + image.getHandle() + " using JpegUtils: " + e.getMessage(), + e); + } } - return result; + return ImageIO.read(is); } + catch (IOException e) + { + // throw the original exception back + throw new BadImageFormatException("Unable to handle " + image.getHandle(), e); + } finally { IOUtils.closeQuietly(is); Modified: trunk/openutils-mgnlmedia/src/main/java/net/sourceforge/openutils/mgnlmedia/media/utils/JpegUtils.java =================================================================== --- trunk/openutils-mgnlmedia/src/main/java/net/sourceforge/openutils/mgnlmedia/media/utils/JpegUtils.java 2010-06-07 15:09:41 UTC (rev 2628) +++ trunk/openutils-mgnlmedia/src/main/java/net/sourceforge/openutils/mgnlmedia/media/utils/JpegUtils.java 2010-06-07 15:59:31 UTC (rev 2629) @@ -167,7 +167,7 @@ Raster raster = reader.readRaster(0, reader.getDefaultReadParam()); boolean ycckProfile = false; - // yes, we need to read it once again to extract metadatas + // yes, we need to read it once again to extract metadata InputStream is3 = image.getStream(); try { @@ -175,18 +175,21 @@ JpegSegmentReader segmentReader = new JpegSegmentReader(is3); byte[] exifSegment = segmentReader.readSegment(JpegSegmentReader.SEGMENT_APPE); - switch (exifSegment[11]) + if (exifSegment != null) // see MEDIA-72, rgb images have a null exif segment here { - case 2 : - ycckProfile = true; - break; - case 1 : - // "YCbCr" - break; - case 0 : - default : - // Unknown (RGB or CMYK) - break; + switch (exifSegment[11]) + { + case 2 : + ycckProfile = true; + break; + case 1 : + // "YCbCr" + break; + case 0 : + default : + // Unknown (RGB or CMYK) + break; + } } } catch (JpegProcessingException e1) @@ -204,7 +207,24 @@ } reader.dispose(); - return createJPEG4(raster, ycckProfile); + if (ycckProfile) + { + return createJPEG4(raster, ycckProfile); + } + else + { + InputStream is4 = image.getStream(); + try + { + // see MEDIA-72, we need the sun codec to make this work properly + return com.sun.image.codec.jpeg.JPEGCodec.createJPEGDecoder(is4).decodeAsBufferedImage(); + } + finally + { + IOUtils.closeQuietly(is4); + } + } + } throw new BadImageFormatException("No ImageReaders found for " + image.getHandle()); Modified: trunk/openutils-mgnlmedia/src/test/java/net/sourceforge/openutils/mgnlmedia/media/utils/FileNodeData.java =================================================================== --- trunk/openutils-mgnlmedia/src/test/java/net/sourceforge/openutils/mgnlmedia/media/utils/FileNodeData.java 2010-06-07 15:09:41 UTC (rev 2628) +++ trunk/openutils-mgnlmedia/src/test/java/net/sourceforge/openutils/mgnlmedia/media/utils/FileNodeData.java 2010-06-07 15:59:31 UTC (rev 2629) @@ -37,6 +37,7 @@ import javax.jcr.Value; import org.apache.commons.io.IOUtils; +import org.apache.commons.lang.StringUtils; /** @@ -48,6 +49,8 @@ private byte[] content; + private String extension; + /** * @param classpathLocation * @throws IOException @@ -55,12 +58,15 @@ public FileNodeData(String classpathLocation) throws IOException { InputStream is = getClass().getResourceAsStream(classpathLocation); + if (is == null) { throw new IllegalArgumentException("Classpath resource " + classpathLocation + " cannot be found"); } try { + extension = StringUtils.substringAfterLast(classpathLocation, "."); + content = IOUtils.toByteArray(is); } finally @@ -81,8 +87,12 @@ /** * {@inheritDoc} */ - public String getAttribute(String arg0) + public String getAttribute(String key) { + if (StringUtils.equals(key, "extension")) + { + return this.extension; + } // TODO Auto-generated method stub return null; } Modified: trunk/openutils-mgnlmedia/src/test/java/net/sourceforge/openutils/mgnlmedia/media/utils/ImageUtilsTest.java =================================================================== --- trunk/openutils-mgnlmedia/src/test/java/net/sourceforge/openutils/mgnlmedia/media/utils/ImageUtilsTest.java 2010-06-07 15:09:41 UTC (rev 2628) +++ trunk/openutils-mgnlmedia/src/test/java/net/sourceforge/openutils/mgnlmedia/media/utils/ImageUtilsTest.java 2010-06-07 15:59:31 UTC (rev 2629) @@ -89,9 +89,36 @@ } /** + * Test for MEDIA-72 * @throws Exception */ @Test + public void testInvalidJpeg() throws Exception + { + + NodeData cmyk = new FileNodeData("/images/sample_invalid_colors.jpg"); + BufferedImage bufferedImage = ImageUtils.createBufferedImage(cmyk); + Assert.assertNotNull(bufferedImage); + + bufferedImage = ImageUtils.resizeImage(bufferedImage, 100, 100); + + InputStream is = ImageUtils.getStream(bufferedImage, "jpg", 1.0F, false); + + File tempFile = File.createTempFile("image", ".jpg"); + OutputStream os = new BufferedOutputStream(new FileOutputStream(tempFile)); + IOUtils.copy(is, os); + + IOUtils.closeQuietly(is); + IOUtils.closeQuietly(os); + + tempFile.delete(); + + } + + /** + * @throws Exception + */ + @Test public void testBorders() throws Exception { Added: trunk/openutils-mgnlmedia/src/test/resources/images/sample_invalid_colors.jpg =================================================================== (Binary files differ) Property changes on: trunk/openutils-mgnlmedia/src/test/resources/images/sample_invalid_colors.jpg ___________________________________________________________________ Added: svn:mime-type + image/jpeg This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <fg...@us...> - 2010-09-10 08:42:00
|
Revision: 3017 http://openutils.svn.sourceforge.net/openutils/?rev=3017&view=rev Author: fgiust Date: 2010-09-10 08:41:52 +0000 (Fri, 10 Sep 2010) Log Message: ----------- formatting/cleanup Modified Paths: -------------- trunk/openutils-mgnlmedia/src/main/java/net/sourceforge/openutils/mgnlmedia/freemarker/SktSimpleMediaParagraphRenderer.java trunk/openutils-mgnlmedia/src/main/java/net/sourceforge/openutils/mgnlmedia/freemarker/SktSimpleMediaTemplateRenderer.java trunk/openutils-mgnlmedia/src/main/java/net/sourceforge/openutils/mgnlmedia/grid/MediaGridColumnType.java trunk/openutils-mgnlmedia/src/main/java/net/sourceforge/openutils/mgnlmedia/media/advancedsearch/SearchFilterBeetweenCreationDate.java trunk/openutils-mgnlmedia/src/main/java/net/sourceforge/openutils/mgnlmedia/media/advancedsearch/SearchFilterStatus.java trunk/openutils-mgnlmedia/src/main/java/net/sourceforge/openutils/mgnlmedia/media/advancedsearch/configuration/SearchMediaQueryConfiguration.java trunk/openutils-mgnlmedia/src/main/java/net/sourceforge/openutils/mgnlmedia/media/configuration/MediaUsedInManager.java trunk/openutils-mgnlmedia/src/main/java/net/sourceforge/openutils/mgnlmedia/media/dialog/DialogFileAudio.java trunk/openutils-mgnlmedia/src/main/java/net/sourceforge/openutils/mgnlmedia/media/dialog/DialogFileVideo.java trunk/openutils-mgnlmedia/src/main/java/net/sourceforge/openutils/mgnlmedia/media/dialog/LayerDialogMVC.java trunk/openutils-mgnlmedia/src/main/java/net/sourceforge/openutils/mgnlmedia/media/pages/MediaBrowserPage.java 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/MediaSearchPage.java trunk/openutils-mgnlmedia/src/main/java/net/sourceforge/openutils/mgnlmedia/media/processors/BaseImageResolutionProcessor.java trunk/openutils-mgnlmedia/src/main/java/net/sourceforge/openutils/mgnlmedia/media/processors/RoundedCornersProcessor.java trunk/openutils-mgnlmedia/src/main/java/net/sourceforge/openutils/mgnlmedia/media/setup/RenameThumbToImageTask.java trunk/openutils-mgnlmedia/src/main/java/net/sourceforge/openutils/mgnlmedia/media/tags/el/MediaEl.java trunk/openutils-mgnlmedia/src/main/java/net/sourceforge/openutils/mgnlmedia/media/types/impl/DocumentTypeHandler.java trunk/openutils-mgnlmedia/src/main/java/net/sourceforge/openutils/mgnlmedia/media/types/impl/VideoTypeHandler.java trunk/openutils-mgnlmedia/src/main/java/net/sourceforge/openutils/mgnlmedia/media/utils/FLVMedataUtils.java 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/RtmpMedatadaFetcher.java trunk/openutils-mgnlmedia/src/main/java/net/sourceforge/openutils/mgnlmedia/playlist/pages/PlaylistView.java trunk/openutils-mgnlmedia/src/test/java/net/sourceforge/openutils/mgnlmedia/media/utils/ImageProcessorsManagerMock.java Modified: trunk/openutils-mgnlmedia/src/main/java/net/sourceforge/openutils/mgnlmedia/freemarker/SktSimpleMediaParagraphRenderer.java =================================================================== --- trunk/openutils-mgnlmedia/src/main/java/net/sourceforge/openutils/mgnlmedia/freemarker/SktSimpleMediaParagraphRenderer.java 2010-09-09 21:27:36 UTC (rev 3016) +++ trunk/openutils-mgnlmedia/src/main/java/net/sourceforge/openutils/mgnlmedia/freemarker/SktSimpleMediaParagraphRenderer.java 2010-09-10 08:41:52 UTC (rev 3017) @@ -52,8 +52,12 @@ try { - ctx.put("media", BeansWrapper.getDefaultInstance().getStaticModels().get( - net.sourceforge.openutils.mgnlmedia.media.tags.el.MediaEl.class.getName())); + ctx.put( + "media", + BeansWrapper + .getDefaultInstance() + .getStaticModels() + .get(net.sourceforge.openutils.mgnlmedia.media.tags.el.MediaEl.class.getName())); } catch (TemplateModelException e) { Modified: trunk/openutils-mgnlmedia/src/main/java/net/sourceforge/openutils/mgnlmedia/freemarker/SktSimpleMediaTemplateRenderer.java =================================================================== --- trunk/openutils-mgnlmedia/src/main/java/net/sourceforge/openutils/mgnlmedia/freemarker/SktSimpleMediaTemplateRenderer.java 2010-09-09 21:27:36 UTC (rev 3016) +++ trunk/openutils-mgnlmedia/src/main/java/net/sourceforge/openutils/mgnlmedia/freemarker/SktSimpleMediaTemplateRenderer.java 2010-09-10 08:41:52 UTC (rev 3017) @@ -55,8 +55,12 @@ try { - ctx.put("media", BeansWrapper.getDefaultInstance().getStaticModels().get( - net.sourceforge.openutils.mgnlmedia.media.tags.el.MediaEl.class.getName())); + ctx.put( + "media", + BeansWrapper + .getDefaultInstance() + .getStaticModels() + .get(net.sourceforge.openutils.mgnlmedia.media.tags.el.MediaEl.class.getName())); } catch (TemplateModelException e) { Modified: trunk/openutils-mgnlmedia/src/main/java/net/sourceforge/openutils/mgnlmedia/grid/MediaGridColumnType.java =================================================================== --- trunk/openutils-mgnlmedia/src/main/java/net/sourceforge/openutils/mgnlmedia/grid/MediaGridColumnType.java 2010-09-09 21:27:36 UTC (rev 3016) +++ trunk/openutils-mgnlmedia/src/main/java/net/sourceforge/openutils/mgnlmedia/grid/MediaGridColumnType.java 2010-09-10 08:41:52 UTC (rev 3017) @@ -69,9 +69,11 @@ Messages msgs) { column.put("editor", "new Ed(new MediaField({}))"); - column.put("renderer", "function(v, p, record){ return v ? '<img border=\"0\" alt=\"\" src=\"" - + MgnlContext.getContextPath() - + "/mediathumbnail/' + v + '\" />' : v; }"); + column.put( + "renderer", + "function(v, p, record){ return v ? '<img border=\"0\" alt=\"\" src=\"" + + MgnlContext.getContextPath() + + "/mediathumbnail/' + v + '\" />' : v; }"); } /** Modified: trunk/openutils-mgnlmedia/src/main/java/net/sourceforge/openutils/mgnlmedia/media/advancedsearch/SearchFilterBeetweenCreationDate.java =================================================================== --- trunk/openutils-mgnlmedia/src/main/java/net/sourceforge/openutils/mgnlmedia/media/advancedsearch/SearchFilterBeetweenCreationDate.java 2010-09-09 21:27:36 UTC (rev 3016) +++ trunk/openutils-mgnlmedia/src/main/java/net/sourceforge/openutils/mgnlmedia/media/advancedsearch/SearchFilterBeetweenCreationDate.java 2010-09-10 08:41:52 UTC (rev 3017) @@ -89,8 +89,10 @@ { if (dateMatcher.find()) { - cal.set(Integer.parseInt(dateMatcher.group(1)), Integer.parseInt(dateMatcher.group(2)), Integer - .parseInt(dateMatcher.group(3))); + cal.set( + Integer.parseInt(dateMatcher.group(1)), + Integer.parseInt(dateMatcher.group(2)), + Integer.parseInt(dateMatcher.group(3))); } } catch (Exception e) Modified: trunk/openutils-mgnlmedia/src/main/java/net/sourceforge/openutils/mgnlmedia/media/advancedsearch/SearchFilterStatus.java =================================================================== --- trunk/openutils-mgnlmedia/src/main/java/net/sourceforge/openutils/mgnlmedia/media/advancedsearch/SearchFilterStatus.java 2010-09-09 21:27:36 UTC (rev 3016) +++ trunk/openutils-mgnlmedia/src/main/java/net/sourceforge/openutils/mgnlmedia/media/advancedsearch/SearchFilterStatus.java 2010-09-10 08:41:52 UTC (rev 3017) @@ -54,7 +54,7 @@ criterionList.add(Restrictions.eq(META_DATA_MGNL_ACTIVATED, "true")); } - if(!values[0].equals("ALL") && "NOTPUB".equals(values[0])) + if (!values[0].equals("ALL") && "NOTPUB".equals(values[0])) { criterionList.add(Restrictions.eq(META_DATA_MGNL_ACTIVATED, false)); } Modified: trunk/openutils-mgnlmedia/src/main/java/net/sourceforge/openutils/mgnlmedia/media/advancedsearch/configuration/SearchMediaQueryConfiguration.java =================================================================== --- trunk/openutils-mgnlmedia/src/main/java/net/sourceforge/openutils/mgnlmedia/media/advancedsearch/configuration/SearchMediaQueryConfiguration.java 2010-09-09 21:27:36 UTC (rev 3016) +++ trunk/openutils-mgnlmedia/src/main/java/net/sourceforge/openutils/mgnlmedia/media/advancedsearch/configuration/SearchMediaQueryConfiguration.java 2010-09-10 08:41:52 UTC (rev 3017) @@ -105,8 +105,10 @@ public AdvancedResult search(HttpServletRequest request, String mediaType, String path, boolean descendants, String sorting, int itemsPerPage, int pageNumberStartingFromOne) { - Criteria c = JCRCriteriaFactory.createCriteria().setWorkspace(MediaModule.REPO).add( - Restrictions.eq("@jcr:primaryType", MediaConfigurationManager.MEDIA.getSystemName())); + Criteria c = JCRCriteriaFactory + .createCriteria() + .setWorkspace(MediaModule.REPO) + .add(Restrictions.eq("@jcr:primaryType", MediaConfigurationManager.MEDIA.getSystemName())); // base path String searchPath = StringUtils.removeEnd(StringUtils.defaultString(path, defaultBasePath), "/") Modified: trunk/openutils-mgnlmedia/src/main/java/net/sourceforge/openutils/mgnlmedia/media/configuration/MediaUsedInManager.java =================================================================== --- trunk/openutils-mgnlmedia/src/main/java/net/sourceforge/openutils/mgnlmedia/media/configuration/MediaUsedInManager.java 2010-09-09 21:27:36 UTC (rev 3016) +++ trunk/openutils-mgnlmedia/src/main/java/net/sourceforge/openutils/mgnlmedia/media/configuration/MediaUsedInManager.java 2010-09-10 08:41:52 UTC (rev 3017) @@ -150,14 +150,16 @@ Set<String> handles = new HashSet<String>(); QueryManager qm = MgnlContext.getQueryManager(uiw.getWorkspaceName()); - Query q = qm.createQuery("select * from nt:base where jcr:path like '" - + uiw.getBasePath() - + (StringUtils.endsWith(uiw.getBasePath(), "/") ? StringUtils.EMPTY : "/") - + "%' and contains(" - + uiw.getPropertyName() - + ", '" - + mediaUUID - + "')", Query.SQL); + Query q = qm.createQuery( + "select * from nt:base where jcr:path like '" + + uiw.getBasePath() + + (StringUtils.endsWith(uiw.getBasePath(), "/") ? StringUtils.EMPTY : "/") + + "%' and contains(" + + uiw.getPropertyName() + + ", '" + + mediaUUID + + "')", + Query.SQL); QueryResult qr = q.execute(); Collection<Content> qrNodes = qr.getContent(uiw.getNodeType()); if (qrNodes != null) Modified: trunk/openutils-mgnlmedia/src/main/java/net/sourceforge/openutils/mgnlmedia/media/dialog/DialogFileAudio.java =================================================================== --- trunk/openutils-mgnlmedia/src/main/java/net/sourceforge/openutils/mgnlmedia/media/dialog/DialogFileAudio.java 2010-09-09 21:27:36 UTC (rev 3016) +++ trunk/openutils-mgnlmedia/src/main/java/net/sourceforge/openutils/mgnlmedia/media/dialog/DialogFileAudio.java 2010-09-10 08:41:52 UTC (rev 3017) @@ -179,7 +179,7 @@ out.write("</div>\n"); //$NON-NLS-1$ out.write("<div style=\"position:absolute;top:-500px;left:-500px;visibility:hidden;\">\n<textarea id=\""); //$NON-NLS-1$ out.write(this.getName()); - out.write("_contentEmpty\">");//$NON-NLS-1$ + out.write("_contentEmpty\">"); out.write(htmlContentEmpty); // @todo should be escaped, but we need to test it Modified: trunk/openutils-mgnlmedia/src/main/java/net/sourceforge/openutils/mgnlmedia/media/dialog/DialogFileVideo.java =================================================================== --- trunk/openutils-mgnlmedia/src/main/java/net/sourceforge/openutils/mgnlmedia/media/dialog/DialogFileVideo.java 2010-09-09 21:27:36 UTC (rev 3016) +++ trunk/openutils-mgnlmedia/src/main/java/net/sourceforge/openutils/mgnlmedia/media/dialog/DialogFileVideo.java 2010-09-10 08:41:52 UTC (rev 3017) @@ -198,7 +198,7 @@ out.write("</div>\n"); //$NON-NLS-1$ out.write("<div style=\"position:absolute;top:-500px;left:-500px;visibility:hidden;\">\n<textarea id=\""); //$NON-NLS-1$ out.write(this.getName()); - out.write("_contentEmpty\">");//$NON-NLS-1$ + out.write("_contentEmpty\">"); out.write(htmlContentEmpty); // @todo should be escaped, but we need to test it Modified: trunk/openutils-mgnlmedia/src/main/java/net/sourceforge/openutils/mgnlmedia/media/dialog/LayerDialogMVC.java =================================================================== --- trunk/openutils-mgnlmedia/src/main/java/net/sourceforge/openutils/mgnlmedia/media/dialog/LayerDialogMVC.java 2010-09-09 21:27:36 UTC (rev 3016) +++ trunk/openutils-mgnlmedia/src/main/java/net/sourceforge/openutils/mgnlmedia/media/dialog/LayerDialogMVC.java 2010-09-10 08:41:52 UTC (rev 3017) @@ -46,7 +46,6 @@ /** * With {@link LayerDialog} allows to have a dialog in an Ext js layer. - * * @author molaschi * @version $Id$ */ @@ -174,12 +173,14 @@ log.error("error getting {}", control.getPath(), e); return false; } - control.setNodeName(Path.getUniqueLabel(c, Path.getValidatedLabel(MediaConfigurationManager - .getInstance() - .getTypes() - .get(type) - .getHandler() - .getNewNodeName(form, request)))); + control.setNodeName(Path.getUniqueLabel( + c, + Path.getValidatedLabel(MediaConfigurationManager + .getInstance() + .getTypes() + .get(type) + .getHandler() + .getNewNodeName(form, request)))); } return super.onPreSave(control); Modified: trunk/openutils-mgnlmedia/src/main/java/net/sourceforge/openutils/mgnlmedia/media/pages/MediaBrowserPage.java =================================================================== --- trunk/openutils-mgnlmedia/src/main/java/net/sourceforge/openutils/mgnlmedia/media/pages/MediaBrowserPage.java 2010-09-09 21:27:36 UTC (rev 3016) +++ trunk/openutils-mgnlmedia/src/main/java/net/sourceforge/openutils/mgnlmedia/media/pages/MediaBrowserPage.java 2010-09-10 08:41:52 UTC (rev 3017) @@ -323,7 +323,7 @@ { this.zipFile = file; } - + /** * {@inheritDoc} */ @@ -335,9 +335,7 @@ public String getMessage(String key, String arg) { - return super.getMsgs().get(key, new String[]{ - arg - }); + return super.getMsgs().get(key, new String[]{arg }); } /** 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 2010-09-09 21:27:36 UTC (rev 3016) +++ trunk/openutils-mgnlmedia/src/main/java/net/sourceforge/openutils/mgnlmedia/media/pages/MediaFolderViewPage.java 2010-09-10 08:41:52 UTC (rev 3017) @@ -217,14 +217,10 @@ return 0; } // sorting must be specified for total-size to work (-1 otherwise) - AdvancedResult typeResult = MediaEl.module().getSearch().search( - request, - type.getName(), - path, - false, - getDefaultSorting(), - 0, - 1); + AdvancedResult typeResult = MediaEl + .module() + .getSearch() + .search(request, type.getName(), path, false, getDefaultSorting(), 0, 1); return typeResult.getTotalSize(); } @@ -245,14 +241,10 @@ } writable = folder.isGranted(Permission.WRITE); canPublish = writable && ActivationManagerFactory.getActivationManager().hasAnyActiveSubscriber(); - return MediaEl.module().getSearch().search( - request, - type, - path, - false, - sorting, - MediaEl.module().getFolderViewItemsPerPage(), - page); + return MediaEl + .module() + .getSearch() + .search(request, type, path, false, sorting, MediaEl.module().getFolderViewItemsPerPage(), page); } /** @@ -836,9 +828,7 @@ public String getMessage(String key, String param) { - return getMsgs().get(key, new String[]{ - param - }); + return getMsgs().get(key, new String[]{param }); } /** @@ -851,9 +841,7 @@ String s = request.getQueryString(); s = StringUtils.isEmpty(s) ? StringUtils.EMPTY : "&" + s; int p1; - while ((p1 = StringUtils.indexOfAny(s, new String[]{ - "&type=", "&command=" - })) != -1) + while ((p1 = StringUtils.indexOfAny(s, new String[]{"&type=", "&command=" })) != -1) { int p2 = s.indexOf('&', p1 + 1); s = s.substring(0, p1) + (p2 != -1 ? s.substring(p2) : StringUtils.EMPTY); Modified: trunk/openutils-mgnlmedia/src/main/java/net/sourceforge/openutils/mgnlmedia/media/pages/MediaSearchPage.java =================================================================== --- trunk/openutils-mgnlmedia/src/main/java/net/sourceforge/openutils/mgnlmedia/media/pages/MediaSearchPage.java 2010-09-09 21:27:36 UTC (rev 3016) +++ trunk/openutils-mgnlmedia/src/main/java/net/sourceforge/openutils/mgnlmedia/media/pages/MediaSearchPage.java 2010-09-10 08:41:52 UTC (rev 3017) @@ -21,19 +21,12 @@ import info.magnolia.cms.core.Content; import info.magnolia.cms.core.HierarchyManager; -import info.magnolia.cms.core.search.Query; -import info.magnolia.cms.core.search.QueryResult; -import info.magnolia.cms.util.NodeDataUtil; import info.magnolia.context.MgnlContext; import java.util.ArrayList; -import java.util.Arrays; import java.util.Collection; -import java.util.HashMap; import java.util.List; import java.util.Map; -import java.util.Set; -import java.util.TreeSet; import javax.jcr.RepositoryException; import javax.servlet.http.HttpServletRequest; @@ -43,7 +36,6 @@ import net.sourceforge.openutils.mgnlmedia.media.configuration.MediaTypeConfiguration; import net.sourceforge.openutils.mgnlmedia.media.lifecycle.MediaModule; -import org.apache.commons.lang.StringUtils; import org.slf4j.Logger; import org.slf4j.LoggerFactory; @@ -63,19 +55,15 @@ */ private Logger log = LoggerFactory.getLogger(MediaSearchPage.class); - private static final String langs[] = new String[]{"it", "de", "fr", "en" }; - private List<MediaTypeConfiguration> mtc; private String type; private String filename; - private Map<String, Set<String>> tagsMap; - private String tags; - private String paths[]; + private String[] paths; private String attributes; @@ -120,37 +108,6 @@ log.error("Error retrieving root media node", ex); } - tagsMap = new HashMap<String, Set<String>>(); - try - { - Query q = mgr.getQueryManager().createQuery( - "select * from " + MediaConfigurationManager.MEDIA.getSystemName(), - Query.SQL); - QueryResult qr = q.execute(); - Collection<Content> medias = qr.getContent(MediaConfigurationManager.MEDIA.getSystemName()); - for (Content media : medias) - { - for (String lang : langs) - { - String tagsNd = NodeDataUtil.getString(media, "tags-" + lang); - if (!StringUtils.isEmpty(tagsNd)) - { - Set<String> tagsLang = tagsMap.get(lang); - if (tagsLang == null) - { - tagsLang = new TreeSet<String>(); - tagsMap.put(lang, tagsLang); - } - tagsLang.addAll(Arrays.asList(StringUtils.split(tagsNd, ","))); - } - } - } - } - catch (RepositoryException ex) - { - log.error("Error retrieving tags", ex); - } - return super.show(); } Modified: trunk/openutils-mgnlmedia/src/main/java/net/sourceforge/openutils/mgnlmedia/media/processors/BaseImageResolutionProcessor.java =================================================================== --- trunk/openutils-mgnlmedia/src/main/java/net/sourceforge/openutils/mgnlmedia/media/processors/BaseImageResolutionProcessor.java 2010-09-09 21:27:36 UTC (rev 3016) +++ trunk/openutils-mgnlmedia/src/main/java/net/sourceforge/openutils/mgnlmedia/media/processors/BaseImageResolutionProcessor.java 2010-09-10 08:41:52 UTC (rev 3017) @@ -136,7 +136,8 @@ BufferedImage filled = ImageUtils.resizeImage(original, newX, y); return cropCentered ? ImageUtils.cropImage(filled, (newX - x) / 2, 0, x, y) : filled; } - else // if (oDelta < delta) + else + // if (oDelta < delta) { int newY = (int) (x * oY / oX); BufferedImage filled = ImageUtils.resizeImage(original, x, newY); Modified: trunk/openutils-mgnlmedia/src/main/java/net/sourceforge/openutils/mgnlmedia/media/processors/RoundedCornersProcessor.java =================================================================== --- trunk/openutils-mgnlmedia/src/main/java/net/sourceforge/openutils/mgnlmedia/media/processors/RoundedCornersProcessor.java 2010-09-09 21:27:36 UTC (rev 3016) +++ trunk/openutils-mgnlmedia/src/main/java/net/sourceforge/openutils/mgnlmedia/media/processors/RoundedCornersProcessor.java 2010-09-10 08:41:52 UTC (rev 3017) @@ -39,7 +39,8 @@ * <li>int value: processor draws roundcorners with passed radius</li> * </ul> * If the "background" parameter is specified (hex color), it will be applied when rounding corners.<br/> - * If no "background" parameter is found, if the image format is png a transparent background is applied else a white background is applied. + * If no "background" parameter is found, if the image format is png a transparent background is applied else a white + * background is applied. * @author molaschi * @version $Id: $ */ Modified: trunk/openutils-mgnlmedia/src/main/java/net/sourceforge/openutils/mgnlmedia/media/setup/RenameThumbToImageTask.java =================================================================== --- trunk/openutils-mgnlmedia/src/main/java/net/sourceforge/openutils/mgnlmedia/media/setup/RenameThumbToImageTask.java 2010-09-09 21:27:36 UTC (rev 3016) +++ trunk/openutils-mgnlmedia/src/main/java/net/sourceforge/openutils/mgnlmedia/media/setup/RenameThumbToImageTask.java 2010-09-10 08:41:52 UTC (rev 3017) @@ -77,18 +77,24 @@ NodeData image = node.createNodeData("image", PropertyType.BINARY); image.setValue(thumbnail.getStream()); - image.setAttribute(FileProperties.PROPERTY_EXTENSION, thumbnail - .getAttribute(FileProperties.PROPERTY_EXTENSION)); - image.setAttribute(FileProperties.PROPERTY_FILENAME, thumbnail - .getAttribute(FileProperties.PROPERTY_FILENAME)); - image.setAttribute(FileProperties.PROPERTY_CONTENTTYPE, thumbnail - .getAttribute(FileProperties.PROPERTY_CONTENTTYPE)); - image.setAttribute(FileProperties.PROPERTY_LASTMODIFIED, thumbnail - .getAttribute(FileProperties.PROPERTY_LASTMODIFIED)); - image.setAttribute(FileProperties.PROPERTY_WIDTH, thumbnail - .getAttribute(FileProperties.PROPERTY_WIDTH)); - image.setAttribute(FileProperties.PROPERTY_HEIGHT, thumbnail - .getAttribute(FileProperties.PROPERTY_HEIGHT)); + image.setAttribute( + FileProperties.PROPERTY_EXTENSION, + thumbnail.getAttribute(FileProperties.PROPERTY_EXTENSION)); + image.setAttribute( + FileProperties.PROPERTY_FILENAME, + thumbnail.getAttribute(FileProperties.PROPERTY_FILENAME)); + image.setAttribute( + FileProperties.PROPERTY_CONTENTTYPE, + thumbnail.getAttribute(FileProperties.PROPERTY_CONTENTTYPE)); + image.setAttribute( + FileProperties.PROPERTY_LASTMODIFIED, + thumbnail.getAttribute(FileProperties.PROPERTY_LASTMODIFIED)); + image.setAttribute( + FileProperties.PROPERTY_WIDTH, + thumbnail.getAttribute(FileProperties.PROPERTY_WIDTH)); + image.setAttribute( + FileProperties.PROPERTY_HEIGHT, + thumbnail.getAttribute(FileProperties.PROPERTY_HEIGHT)); thumbnail.delete(); } Modified: trunk/openutils-mgnlmedia/src/main/java/net/sourceforge/openutils/mgnlmedia/media/tags/el/MediaEl.java =================================================================== --- trunk/openutils-mgnlmedia/src/main/java/net/sourceforge/openutils/mgnlmedia/media/tags/el/MediaEl.java 2010-09-09 21:27:36 UTC (rev 3016) +++ trunk/openutils-mgnlmedia/src/main/java/net/sourceforge/openutils/mgnlmedia/media/tags/el/MediaEl.java 2010-09-10 08:41:52 UTC (rev 3017) @@ -480,14 +480,11 @@ { return new int[]{ NumberUtils.toInt(res.getAttribute(FileProperties.PROPERTY_WIDTH)), - NumberUtils.toInt(res.getAttribute(FileProperties.PROPERTY_HEIGHT)) - }; + NumberUtils.toInt(res.getAttribute(FileProperties.PROPERTY_HEIGHT)) }; } } - return new int[]{ - -1, -1 - }; + return new int[]{-1, -1 }; } /** Modified: trunk/openutils-mgnlmedia/src/main/java/net/sourceforge/openutils/mgnlmedia/media/types/impl/DocumentTypeHandler.java =================================================================== --- trunk/openutils-mgnlmedia/src/main/java/net/sourceforge/openutils/mgnlmedia/media/types/impl/DocumentTypeHandler.java 2010-09-09 21:27:36 UTC (rev 3016) +++ trunk/openutils-mgnlmedia/src/main/java/net/sourceforge/openutils/mgnlmedia/media/types/impl/DocumentTypeHandler.java 2010-09-10 08:41:52 UTC (rev 3017) @@ -185,8 +185,9 @@ { if (e.getCause() instanceof ClassCastException) { - log.warn("Two conflicting versions of pdfbox are loaded, only one pdfbox jar version 1.x must be loaded in order to make thumbnail generation work. " - + "Not generating preview for pdf document"); + log + .warn("Two conflicting versions of pdfbox are loaded, only one pdfbox jar version 1.x must be loaded in order to make thumbnail generation work. " + + "Not generating preview for pdf document"); } else { Modified: trunk/openutils-mgnlmedia/src/main/java/net/sourceforge/openutils/mgnlmedia/media/types/impl/VideoTypeHandler.java =================================================================== --- trunk/openutils-mgnlmedia/src/main/java/net/sourceforge/openutils/mgnlmedia/media/types/impl/VideoTypeHandler.java 2010-09-09 21:27:36 UTC (rev 3016) +++ trunk/openutils-mgnlmedia/src/main/java/net/sourceforge/openutils/mgnlmedia/media/types/impl/VideoTypeHandler.java 2010-09-10 08:41:52 UTC (rev 3017) @@ -50,7 +50,8 @@ protected FLVMetaData parseFLVMetaData(Content media) throws Exception { InputStream stream = getOriginalFileNodeData(media).getStream(); - try { + try + { return FLVMedataUtils.parseFLVfromStream(stream); } finally Modified: trunk/openutils-mgnlmedia/src/main/java/net/sourceforge/openutils/mgnlmedia/media/utils/FLVMedataUtils.java =================================================================== --- trunk/openutils-mgnlmedia/src/main/java/net/sourceforge/openutils/mgnlmedia/media/utils/FLVMedataUtils.java 2010-09-09 21:27:36 UTC (rev 3016) +++ trunk/openutils-mgnlmedia/src/main/java/net/sourceforge/openutils/mgnlmedia/media/utils/FLVMedataUtils.java 2010-09-10 08:41:52 UTC (rev 3017) @@ -302,7 +302,9 @@ if (source[i] != first) { while (++i <= max && source[i] != first) + { ; + } } /* Found first character, now look at the rest of v2 */ @@ -311,7 +313,9 @@ int j = i + 1; int end = j + target.length - 1; for (int k = 1; j < end && source[j] == target[k]; j++, k++) + { ; + } if (j == end) { 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 2010-09-09 21:27:36 UTC (rev 3016) +++ trunk/openutils-mgnlmedia/src/main/java/net/sourceforge/openutils/mgnlmedia/media/utils/ImageUtils.java 2010-09-10 08:41:52 UTC (rev 3017) @@ -428,8 +428,9 @@ nd.setAttribute(FileProperties.PROPERTY_EXTENSION, outputformat); nd.setAttribute(FileProperties.PROPERTY_FILENAME, saveTo.getName()); nd.setAttribute(FileProperties.PROPERTY_CONTENTTYPE, mimetype); - nd.setAttribute(FileProperties.PROPERTY_LASTMODIFIED, GregorianCalendar.getInstance(TimeZone - .getDefault())); + nd.setAttribute( + FileProperties.PROPERTY_LASTMODIFIED, + GregorianCalendar.getInstance(TimeZone.getDefault())); nd.setAttribute(FileProperties.PROPERTY_WIDTH, "" + image.getWidth()); nd.setAttribute(FileProperties.PROPERTY_HEIGHT, "" + image.getHeight()); @@ -895,11 +896,10 @@ if (ImageProcessorsManager.getInstance().isValidControlChar(controlChar)) { - img = ImageProcessorsManager.getInstance().getImageResolutionProcessor(controlChar).getImageForResolution( - original, - size.x, - size.y, - params); + img = ImageProcessorsManager + .getInstance() + .getImageResolutionProcessor(controlChar) + .getImageForResolution(original, size.x, size.y, params); } else if (controlChar < '0' || controlChar > '9') { @@ -907,11 +907,10 @@ } else { - img = ImageProcessorsManager.getInstance().getDefaultImageResolutionProcessor().getImageForResolution( - original, - size.x, - size.y, - params); + img = ImageProcessorsManager + .getInstance() + .getDefaultImageResolutionProcessor() + .getImageForResolution(original, size.x, size.y, params); } for (ImagePostProcessor ipp : ImageProcessorsManager.getInstance().getImagePostProcessorsList()) Modified: trunk/openutils-mgnlmedia/src/main/java/net/sourceforge/openutils/mgnlmedia/media/utils/RtmpMedatadaFetcher.java =================================================================== --- trunk/openutils-mgnlmedia/src/main/java/net/sourceforge/openutils/mgnlmedia/media/utils/RtmpMedatadaFetcher.java 2010-09-09 21:27:36 UTC (rev 3016) +++ trunk/openutils-mgnlmedia/src/main/java/net/sourceforge/openutils/mgnlmedia/media/utils/RtmpMedatadaFetcher.java 2010-09-10 08:41:52 UTC (rev 3017) @@ -45,7 +45,9 @@ /** - * <p>Utility class to fetch flv headers from a rtmp URL using flazr (http://flazr.com)</p> + * <p> + * Utility class to fetch flv headers from a rtmp URL using flazr (http://flazr.com) + * </p> * @author fgiust * @version $Id$ */ Modified: trunk/openutils-mgnlmedia/src/main/java/net/sourceforge/openutils/mgnlmedia/playlist/pages/PlaylistView.java =================================================================== --- trunk/openutils-mgnlmedia/src/main/java/net/sourceforge/openutils/mgnlmedia/playlist/pages/PlaylistView.java 2010-09-09 21:27:36 UTC (rev 3016) +++ trunk/openutils-mgnlmedia/src/main/java/net/sourceforge/openutils/mgnlmedia/playlist/pages/PlaylistView.java 2010-09-10 08:41:52 UTC (rev 3017) @@ -202,9 +202,10 @@ .getI18nSupport() .getNodeData(media, "title") .getString()); - entry.setDescription(I18nContentSupportFactory.getI18nSupport().getNodeData( - media, - "description").getString()); + entry.setDescription(I18nContentSupportFactory + .getI18nSupport() + .getNodeData(media, "description") + .getString()); entry .setTags(I18nContentSupportFactory.getI18nSupport().getNodeData(media, "tags").getString()); entries.add(entry); @@ -213,9 +214,7 @@ { log.warn( "Node {} referenced by entry {} of playlist {} does not exist in media repository", - new Object[]{ - mediaUUID, subNode.getName(), playlist.getHandle() - }); + new Object[]{mediaUUID, subNode.getName(), playlist.getHandle() }); } } playlist.setEntries(entries); Modified: trunk/openutils-mgnlmedia/src/test/java/net/sourceforge/openutils/mgnlmedia/media/utils/ImageProcessorsManagerMock.java =================================================================== --- trunk/openutils-mgnlmedia/src/test/java/net/sourceforge/openutils/mgnlmedia/media/utils/ImageProcessorsManagerMock.java 2010-09-09 21:27:36 UTC (rev 3016) +++ trunk/openutils-mgnlmedia/src/test/java/net/sourceforge/openutils/mgnlmedia/media/utils/ImageProcessorsManagerMock.java 2010-09-10 08:41:52 UTC (rev 3017) @@ -19,8 +19,6 @@ package net.sourceforge.openutils.mgnlmedia.media.utils; -import org.apache.commons.lang.ArrayUtils; - import net.sourceforge.openutils.mgnlmedia.media.configuration.ImageProcessorsManager; import net.sourceforge.openutils.mgnlmedia.media.processors.FitInAndFillWithBandsImageResolutionProcessor; import net.sourceforge.openutils.mgnlmedia.media.processors.FitInImageResolutionProcessor; @@ -28,7 +26,9 @@ import net.sourceforge.openutils.mgnlmedia.media.processors.ResizeCropCenteredImageResolutionProcessor; import net.sourceforge.openutils.mgnlmedia.media.processors.ResizeNoCropImageResolutionProcessor; +import org.apache.commons.lang.ArrayUtils; + /** * @author molaschi * @version $Id: $ @@ -36,7 +36,7 @@ public class ImageProcessorsManagerMock extends ImageProcessorsManager { - private final char controlChars[] = new char[]{'o', 'b', 'l', '<', 'x' }; + private final char[] controlChars = new char[]{'o', 'b', 'l', '<', 'x' }; /** * {@inheritDoc} This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <mol...@us...> - 2010-12-27 15:07:04
|
Revision: 3190 http://openutils.svn.sourceforge.net/openutils/?rev=3190&view=rev Author: molaschi Date: 2010-12-27 15:06:57 +0000 (Mon, 27 Dec 2010) Log Message: ----------- MEDIA-196 Modified Paths: -------------- trunk/openutils-mgnlmedia/src/main/java/net/sourceforge/openutils/mgnlmedia/media/utils/ImageUtils.java trunk/openutils-mgnlmedia/src/test/java/net/sourceforge/openutils/mgnlmedia/media/utils/ImageUtilsTest.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 2010-12-18 16:48:58 UTC (rev 3189) +++ trunk/openutils-mgnlmedia/src/main/java/net/sourceforge/openutils/mgnlmedia/media/utils/ImageUtils.java 2010-12-27 15:06:57 UTC (rev 3190) @@ -377,18 +377,14 @@ public static void saveResolution(BufferedImage image, Content saveTo, String name, String outputformat, float quality, boolean forceProgressive) throws RepositoryException, IOException { + final File tempFile = getTempFile(image, outputformat, quality, forceProgressive); InputStream stream = null; try { - stream = getStream(image, outputformat, quality, forceProgressive); + stream = new BufferedInputStream(new FileInputStream(tempFile)); - if (stream == null) - { - throw new IllegalArgumentException("Stream is null"); - } - Content resolutions = getResolutionsNode(saveTo); if (resolutions == null) { @@ -428,17 +424,17 @@ nd.setAttribute(FileProperties.PROPERTY_EXTENSION, outputformat); nd.setAttribute(FileProperties.PROPERTY_FILENAME, saveTo.getName()); nd.setAttribute(FileProperties.PROPERTY_CONTENTTYPE, mimetype); - nd.setAttribute( - FileProperties.PROPERTY_LASTMODIFIED, - GregorianCalendar.getInstance(TimeZone.getDefault())); + nd.setAttribute(FileProperties.PROPERTY_LASTMODIFIED, GregorianCalendar.getInstance(TimeZone + .getDefault())); nd.setAttribute(FileProperties.PROPERTY_WIDTH, "" + image.getWidth()); nd.setAttribute(FileProperties.PROPERTY_HEIGHT, "" + image.getHeight()); - + nd.setAttribute(FileProperties.PROPERTY_SIZE, "" + tempFile.length()); } } finally { IOUtils.closeQuietly(stream); + tempFile.delete(); } } @@ -459,15 +455,15 @@ } /** - * Get an inputstream for an image and the target file extension + * Get a temporary file for an image and the target file extension * @param image image to get the inputstream from * @param extension target file extension * @param quality image quality * @param forceProgressive true if image has to be saved as progressive mode - * @return inputstream + * @return temporary file * @throws IOException */ - public static InputStream getStream(BufferedImage image, String extension, float quality, boolean forceProgressive) + public static File getTempFile(BufferedImage image, String extension, float quality, boolean forceProgressive) throws IOException { @@ -580,20 +576,7 @@ out.flush(); IOUtils.closeQuietly(out); - return new BufferedInputStream(new FileInputStream(tempFile) - { - - /** - * {@inheritDoc} - */ - @Override - public void close() throws IOException - { - tempFile.delete(); - super.close(); - } - - }); + return tempFile; } /** @@ -896,10 +879,11 @@ if (ImageProcessorsManager.getInstance().isValidControlChar(controlChar)) { - img = ImageProcessorsManager - .getInstance() - .getImageResolutionProcessor(controlChar) - .getImageForResolution(original, size.x, size.y, params); + img = ImageProcessorsManager.getInstance().getImageResolutionProcessor(controlChar).getImageForResolution( + original, + size.x, + size.y, + params); } else if (controlChar < '0' || controlChar > '9') { @@ -907,10 +891,11 @@ } else { - img = ImageProcessorsManager - .getInstance() - .getDefaultImageResolutionProcessor() - .getImageForResolution(original, size.x, size.y, params); + img = ImageProcessorsManager.getInstance().getDefaultImageResolutionProcessor().getImageForResolution( + original, + size.x, + size.y, + params); } for (ImagePostProcessor ipp : ImageProcessorsManager.getInstance().getImagePostProcessorsList()) Modified: trunk/openutils-mgnlmedia/src/test/java/net/sourceforge/openutils/mgnlmedia/media/utils/ImageUtilsTest.java =================================================================== --- trunk/openutils-mgnlmedia/src/test/java/net/sourceforge/openutils/mgnlmedia/media/utils/ImageUtilsTest.java 2010-12-18 16:48:58 UTC (rev 3189) +++ trunk/openutils-mgnlmedia/src/test/java/net/sourceforge/openutils/mgnlmedia/media/utils/ImageUtilsTest.java 2010-12-27 15:06:57 UTC (rev 3190) @@ -23,17 +23,13 @@ import info.magnolia.cms.util.FactoryUtil; import java.awt.image.BufferedImage; -import java.io.BufferedOutputStream; import java.io.File; -import java.io.FileOutputStream; -import java.io.InputStream; -import java.io.OutputStream; import java.util.HashMap; import java.util.Map; import net.sourceforge.openutils.mgnlmedia.media.configuration.ImageProcessorsManager; -import org.apache.commons.io.IOUtils; +import org.apache.commons.io.FileUtils; import org.testng.Assert; import org.testng.annotations.BeforeMethod; import org.testng.annotations.Test; @@ -75,16 +71,13 @@ bufferedImage = ImageUtils.resizeImage(bufferedImage, 100, 100); - InputStream is = ImageUtils.getStream(bufferedImage, "jpg", 1.0F, false); + File originalTempFile = ImageUtils.getTempFile(bufferedImage, "jpg", 1.0F, false); - File tempFile = File.createTempFile("image", ".jpg"); - OutputStream os = new BufferedOutputStream(new FileOutputStream(tempFile)); - IOUtils.copy(is, os); + File tempFile = File.createTempFile("image", ".gif"); + FileUtils.copyFile(originalTempFile, tempFile); - IOUtils.closeQuietly(is); - IOUtils.closeQuietly(os); - tempFile.delete(); + originalTempFile.delete(); } @@ -102,16 +95,13 @@ bufferedImage = ImageUtils.resizeImage(bufferedImage, 100, 100); - InputStream is = ImageUtils.getStream(bufferedImage, "jpg", 1.0F, false); + File originalTempFile = ImageUtils.getTempFile(bufferedImage, "jpg", 1.0F, false); - File tempFile = File.createTempFile("image", ".jpg"); - OutputStream os = new BufferedOutputStream(new FileOutputStream(tempFile)); - IOUtils.copy(is, os); + File tempFile = File.createTempFile("image", ".gif"); + FileUtils.copyFile(originalTempFile, tempFile); - IOUtils.closeQuietly(is); - IOUtils.closeQuietly(os); - tempFile.delete(); + originalTempFile.delete(); } @@ -130,16 +120,13 @@ parameters.put("background", "FF0096"); bufferedImage = ImageUtils.getImageForResolution(bufferedImage, "O300x300;background=FF0096", parameters); - InputStream is = ImageUtils.getStream(bufferedImage, "png", 1.0F, false); + File originalTempFile = ImageUtils.getTempFile(bufferedImage, "png", 1.0F, false); - File tempFile = File.createTempFile("image", ".png"); - OutputStream os = new BufferedOutputStream(new FileOutputStream(tempFile)); - IOUtils.copy(is, os); + File tempFile = File.createTempFile("image", ".gif"); + FileUtils.copyFile(originalTempFile, tempFile); - IOUtils.closeQuietly(is); - IOUtils.closeQuietly(os); - tempFile.delete(); + originalTempFile.delete(); } @@ -193,16 +180,13 @@ bufferedImage = ImageUtils.resizeImage(bufferedImage, 1, 1); - InputStream is = ImageUtils.getStream(bufferedImage, "gif", 0.8F, false); + File originalTempFile = ImageUtils.getTempFile(bufferedImage, "gif", 0.8F, false); File tempFile = File.createTempFile("image", ".gif"); - OutputStream os = new BufferedOutputStream(new FileOutputStream(tempFile)); - IOUtils.copy(is, os); + FileUtils.copyFile(originalTempFile, tempFile); - IOUtils.closeQuietly(is); - IOUtils.closeQuietly(os); - tempFile.delete(); + originalTempFile.delete(); } /** @@ -220,15 +204,12 @@ bufferedImage = ImageUtils.resizeImage(bufferedImage, 200, 200); - InputStream is = ImageUtils.getStream(bufferedImage, "gif", 0.8F, false); + File originalTempFile = ImageUtils.getTempFile(bufferedImage, "gif", 0.8F, false); File tempFile = File.createTempFile("image", ".gif"); - OutputStream os = new BufferedOutputStream(new FileOutputStream(tempFile)); - IOUtils.copy(is, os); + FileUtils.copyFile(originalTempFile, tempFile); - IOUtils.closeQuietly(is); - IOUtils.closeQuietly(os); - tempFile.delete(); + originalTempFile.delete(); } } This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <mol...@us...> - 2010-12-28 13:14:01
|
Revision: 3195 http://openutils.svn.sourceforge.net/openutils/?rev=3195&view=rev Author: molaschi Date: 2010-12-28 13:13:55 +0000 (Tue, 28 Dec 2010) Log Message: ----------- MEDIA-196 works with every temp file behaviour Modified Paths: -------------- trunk/openutils-mgnlmedia/src/main/java/net/sourceforge/openutils/mgnlmedia/media/utils/ImageUtils.java trunk/openutils-mgnlmedia/src/test/java/net/sourceforge/openutils/mgnlmedia/media/utils/ImageUtilsTest.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 2010-12-27 20:16:16 UTC (rev 3194) +++ trunk/openutils-mgnlmedia/src/main/java/net/sourceforge/openutils/mgnlmedia/media/utils/ImageUtils.java 2010-12-28 13:13:55 UTC (rev 3195) @@ -377,14 +377,18 @@ public static void saveResolution(BufferedImage image, Content saveTo, String name, String outputformat, float quality, boolean forceProgressive) throws RepositoryException, IOException { - final File tempFile = getTempFile(image, outputformat, quality, forceProgressive); - InputStream stream = null; + CountBytesBufferedInputStream stream = null; try { - stream = new BufferedInputStream(new FileInputStream(tempFile)); + stream = new CountBytesBufferedInputStream(getStream(image, outputformat, quality, forceProgressive)); + if (stream == null) + { + throw new IllegalArgumentException("Stream is null"); + } + Content resolutions = getResolutionsNode(saveTo); if (resolutions == null) { @@ -428,13 +432,12 @@ .getDefault())); nd.setAttribute(FileProperties.PROPERTY_WIDTH, "" + image.getWidth()); nd.setAttribute(FileProperties.PROPERTY_HEIGHT, "" + image.getHeight()); - nd.setAttribute(FileProperties.PROPERTY_SIZE, "" + tempFile.length()); + nd.setAttribute(FileProperties.PROPERTY_SIZE, "" + stream.getCount()); } } finally { IOUtils.closeQuietly(stream); - tempFile.delete(); } } @@ -455,15 +458,15 @@ } /** - * Get a temporary file for an image and the target file extension + * Get an inputstream for an image and the target file extension * @param image image to get the inputstream from * @param extension target file extension * @param quality image quality * @param forceProgressive true if image has to be saved as progressive mode - * @return temporary file + * @return inputstream * @throws IOException */ - public static File getTempFile(BufferedImage image, String extension, float quality, boolean forceProgressive) + public static InputStream getStream(BufferedImage image, String extension, float quality, boolean forceProgressive) throws IOException { @@ -576,7 +579,20 @@ out.flush(); IOUtils.closeQuietly(out); - return tempFile; + return new FileInputStream(tempFile) + { + + /** + * {@inheritDoc} + */ + @Override + public void close() throws IOException + { + tempFile.delete(); + super.close(); + } + + }; } /** @@ -1019,4 +1035,81 @@ } } + static class CountBytesBufferedInputStream extends BufferedInputStream + { + + private int count = 0; + + /** + * @param in + * @param size + */ + public CountBytesBufferedInputStream(InputStream in, int size) + { + super(in, size); + count = 0; + } + + /** + * @param in + */ + public CountBytesBufferedInputStream(InputStream in) + { + super(in); + count = 0; + } + + /** + * {@inheritDoc} + */ + @Override + public synchronized int read() throws IOException + { + count++; + return super.read(); + } + + /** + * {@inheritDoc} + */ + @Override + public synchronized void reset() throws IOException + { + count = 0; + super.reset(); + } + + /** + * {@inheritDoc} + */ + @Override + public int read(byte[] b) throws IOException + { + int read = super.read(b); + count += read; + return read; + } + + /** + * {@inheritDoc} + */ + @Override + public synchronized int read(byte[] b, int off, int len) throws IOException + { + int read = super.read(b, off, len); + count += read; + return read; + } + + /** + * Returns the count. + * @return the count + */ + public int getCount() + { + return count; + } + + } + } Modified: trunk/openutils-mgnlmedia/src/test/java/net/sourceforge/openutils/mgnlmedia/media/utils/ImageUtilsTest.java =================================================================== --- trunk/openutils-mgnlmedia/src/test/java/net/sourceforge/openutils/mgnlmedia/media/utils/ImageUtilsTest.java 2010-12-27 20:16:16 UTC (rev 3194) +++ trunk/openutils-mgnlmedia/src/test/java/net/sourceforge/openutils/mgnlmedia/media/utils/ImageUtilsTest.java 2010-12-28 13:13:55 UTC (rev 3195) @@ -23,13 +23,17 @@ import info.magnolia.cms.util.FactoryUtil; import java.awt.image.BufferedImage; +import java.io.BufferedOutputStream; import java.io.File; +import java.io.FileOutputStream; +import java.io.InputStream; +import java.io.OutputStream; import java.util.HashMap; import java.util.Map; import net.sourceforge.openutils.mgnlmedia.media.configuration.ImageProcessorsManager; -import org.apache.commons.io.FileUtils; +import org.apache.commons.io.IOUtils; import org.testng.Assert; import org.testng.annotations.BeforeMethod; import org.testng.annotations.Test; @@ -71,13 +75,16 @@ bufferedImage = ImageUtils.resizeImage(bufferedImage, 100, 100); - File originalTempFile = ImageUtils.getTempFile(bufferedImage, "jpg", 1.0F, false); + InputStream is = ImageUtils.getStream(bufferedImage, "jpg", 1.0F, false); - File tempFile = File.createTempFile("image", ".gif"); - FileUtils.copyFile(originalTempFile, tempFile); + File tempFile = File.createTempFile("image", ".jpg"); + OutputStream os = new BufferedOutputStream(new FileOutputStream(tempFile)); + IOUtils.copy(is, os); + IOUtils.closeQuietly(is); + IOUtils.closeQuietly(os); + tempFile.delete(); - originalTempFile.delete(); } @@ -95,13 +102,16 @@ bufferedImage = ImageUtils.resizeImage(bufferedImage, 100, 100); - File originalTempFile = ImageUtils.getTempFile(bufferedImage, "jpg", 1.0F, false); + InputStream is = ImageUtils.getStream(bufferedImage, "jpg", 1.0F, false); - File tempFile = File.createTempFile("image", ".gif"); - FileUtils.copyFile(originalTempFile, tempFile); + File tempFile = File.createTempFile("image", ".jpg"); + OutputStream os = new BufferedOutputStream(new FileOutputStream(tempFile)); + IOUtils.copy(is, os); + IOUtils.closeQuietly(is); + IOUtils.closeQuietly(os); + tempFile.delete(); - originalTempFile.delete(); } @@ -120,13 +130,16 @@ parameters.put("background", "FF0096"); bufferedImage = ImageUtils.getImageForResolution(bufferedImage, "O300x300;background=FF0096", parameters); - File originalTempFile = ImageUtils.getTempFile(bufferedImage, "png", 1.0F, false); + InputStream is = ImageUtils.getStream(bufferedImage, "png", 1.0F, false); - File tempFile = File.createTempFile("image", ".gif"); - FileUtils.copyFile(originalTempFile, tempFile); + File tempFile = File.createTempFile("image", ".png"); + OutputStream os = new BufferedOutputStream(new FileOutputStream(tempFile)); + IOUtils.copy(is, os); + IOUtils.closeQuietly(is); + IOUtils.closeQuietly(os); + tempFile.delete(); - originalTempFile.delete(); } @@ -180,13 +193,16 @@ bufferedImage = ImageUtils.resizeImage(bufferedImage, 1, 1); - File originalTempFile = ImageUtils.getTempFile(bufferedImage, "gif", 0.8F, false); + InputStream is = ImageUtils.getStream(bufferedImage, "gif", 0.8F, false); File tempFile = File.createTempFile("image", ".gif"); - FileUtils.copyFile(originalTempFile, tempFile); + OutputStream os = new BufferedOutputStream(new FileOutputStream(tempFile)); + IOUtils.copy(is, os); + IOUtils.closeQuietly(is); + IOUtils.closeQuietly(os); + tempFile.delete(); - originalTempFile.delete(); } /** @@ -204,12 +220,15 @@ bufferedImage = ImageUtils.resizeImage(bufferedImage, 200, 200); - File originalTempFile = ImageUtils.getTempFile(bufferedImage, "gif", 0.8F, false); + InputStream is = ImageUtils.getStream(bufferedImage, "gif", 0.8F, false); File tempFile = File.createTempFile("image", ".gif"); - FileUtils.copyFile(originalTempFile, tempFile); + OutputStream os = new BufferedOutputStream(new FileOutputStream(tempFile)); + IOUtils.copy(is, os); + IOUtils.closeQuietly(is); + IOUtils.closeQuietly(os); + tempFile.delete(); - originalTempFile.delete(); } } This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <fg...@us...> - 2011-07-01 15:08:00
|
Revision: 3566 http://openutils.svn.sourceforge.net/openutils/?rev=3566&view=rev Author: fgiust Date: 2011-07-01 15:07:53 +0000 (Fri, 01 Jul 2011) Log Message: ----------- update tests Modified Paths: -------------- trunk/openutils-mgnlmedia/src/main/java/net/sourceforge/openutils/mgnlmedia/media/utils/ImageUtils.java trunk/openutils-mgnlmedia/src/test/java/net/sourceforge/openutils/mgnlmedia/media/utils/ImageUtilsTest.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-06-30 12:28:09 UTC (rev 3565) +++ trunk/openutils-mgnlmedia/src/main/java/net/sourceforge/openutils/mgnlmedia/media/utils/ImageUtils.java 2011-07-01 15:07:53 UTC (rev 3566) @@ -34,6 +34,7 @@ import java.awt.Point; import java.awt.RenderingHints; import java.awt.Transparency; +import java.awt.color.CMMException; import java.awt.geom.AffineTransform; import java.awt.image.BufferedImage; import java.awt.image.ColorModel; @@ -583,11 +584,11 @@ * @param extension target file extension * @param quality image quality * @param forceProgressive true if image has to be saved as progressive mode - * @return inputstream + * @return byte count * @throws IOException */ public static long getStream(BufferedImage image, String extension, float quality, boolean forceProgressive, - PipedOutputStream outputstream) throws IOException + OutputStream outputstream) throws IOException { CountBytesBufferedOutputStream out = new CountBytesBufferedOutputStream(outputstream); @@ -1121,6 +1122,25 @@ return result; } + catch (CMMException e) + { + // CMMException is thrown for non-standard jpegs? + // Invalid image format + // java.awt.color.CMMException: Invalid image format + // at sun.awt.color.CMM.checkStatus(CMM.java:131) + // at sun.awt.color.ICC_Transform.<init>(ICC_Transform.java:89) + // at java.awt.image.ColorConvertOp.filter(ColorConvertOp.java:516) + // at com.sun.imageio.plugins.jpeg.JPEGImageReader.acceptPixels(JPEGImageReader.java:1169) + BufferedImage result = JpegUtils.processNonStandardImage(image); + + if (result == null) + { + // throw the original exception back + throw new BadImageFormatException("Unable to handle " + image.getHandle(), e); + } + return result; + + } finally { IOUtils.closeQuietly(is); Modified: trunk/openutils-mgnlmedia/src/test/java/net/sourceforge/openutils/mgnlmedia/media/utils/ImageUtilsTest.java =================================================================== --- trunk/openutils-mgnlmedia/src/test/java/net/sourceforge/openutils/mgnlmedia/media/utils/ImageUtilsTest.java 2011-06-30 12:28:09 UTC (rev 3565) +++ trunk/openutils-mgnlmedia/src/test/java/net/sourceforge/openutils/mgnlmedia/media/utils/ImageUtilsTest.java 2011-07-01 15:07:53 UTC (rev 3566) @@ -26,7 +26,6 @@ import java.io.BufferedOutputStream; import java.io.File; import java.io.FileOutputStream; -import java.io.InputStream; import java.io.OutputStream; import java.util.HashMap; import java.util.Map; @@ -75,13 +74,11 @@ bufferedImage = ImageUtils.resizeImage(bufferedImage, 100, 100); - InputStream is = ImageUtils.getStream(bufferedImage, "jpg", 1.0F, false); - File tempFile = File.createTempFile("image", ".jpg"); OutputStream os = new BufferedOutputStream(new FileOutputStream(tempFile)); - IOUtils.copy(is, os); - IOUtils.closeQuietly(is); + ImageUtils.getStream(bufferedImage, "jpg", 1.0F, false, os); + IOUtils.closeQuietly(os); tempFile.delete(); @@ -102,13 +99,11 @@ bufferedImage = ImageUtils.resizeImage(bufferedImage, 100, 100); - InputStream is = ImageUtils.getStream(bufferedImage, "jpg", 1.0F, false); - File tempFile = File.createTempFile("image", ".jpg"); OutputStream os = new BufferedOutputStream(new FileOutputStream(tempFile)); - IOUtils.copy(is, os); - IOUtils.closeQuietly(is); + ImageUtils.getStream(bufferedImage, "jpg", 1.0F, false, os); + IOUtils.closeQuietly(os); tempFile.delete(); @@ -130,13 +125,10 @@ parameters.put("background", "FF0096"); bufferedImage = ImageUtils.getImageForResolution(bufferedImage, "O300x300;background=FF0096", parameters); - InputStream is = ImageUtils.getStream(bufferedImage, "png", 1.0F, false); - File tempFile = File.createTempFile("image", ".png"); OutputStream os = new BufferedOutputStream(new FileOutputStream(tempFile)); - IOUtils.copy(is, os); + ImageUtils.getStream(bufferedImage, "png", 1.0F, false, os); - IOUtils.closeQuietly(is); IOUtils.closeQuietly(os); tempFile.delete(); @@ -191,13 +183,11 @@ bufferedImage = ImageUtils.resizeImage(bufferedImage, 1, 1); - InputStream is = ImageUtils.getStream(bufferedImage, "gif", 0.8F, false); - File tempFile = File.createTempFile("image", ".gif"); OutputStream os = new BufferedOutputStream(new FileOutputStream(tempFile)); - IOUtils.copy(is, os); - IOUtils.closeQuietly(is); + ImageUtils.getStream(bufferedImage, "gif", 0.8F, false, os); + IOUtils.closeQuietly(os); tempFile.delete(); @@ -218,13 +208,11 @@ bufferedImage = ImageUtils.resizeImage(bufferedImage, 200, 200); - InputStream is = ImageUtils.getStream(bufferedImage, "gif", 0.8F, false); - File tempFile = File.createTempFile("image", ".gif"); OutputStream os = new BufferedOutputStream(new FileOutputStream(tempFile)); - IOUtils.copy(is, os); - IOUtils.closeQuietly(is); + ImageUtils.getStream(bufferedImage, "gif", 0.8F, false, os); + IOUtils.closeQuietly(os); tempFile.delete(); This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |