From: <fg...@us...> - 2009-02-15 22:23:09
|
Revision: 1003 http://openutils.svn.sourceforge.net/openutils/?rev=1003&view=rev Author: fgiust Date: 2009-02-15 22:01:47 +0000 (Sun, 15 Feb 2009) Log Message: ----------- update scm url Modified Paths: -------------- branches/openutils-mgnlmedia-3.6.x/pom.xml Property Changed: ---------------- branches/openutils-mgnlmedia-3.6.x/ Property changes on: branches/openutils-mgnlmedia-3.6.x ___________________________________________________________________ Modified: svn:ignore - .settings .checkstyle .classpath .project target test-output temp-testng-customsuite.xml + .settings .checkstyle .classpath .project target test-output temp-testng-customsuite.xml svnmerge-commit-message.txt Modified: branches/openutils-mgnlmedia-3.6.x/pom.xml =================================================================== --- branches/openutils-mgnlmedia-3.6.x/pom.xml 2009-02-15 21:55:30 UTC (rev 1002) +++ branches/openutils-mgnlmedia-3.6.x/pom.xml 2009-02-15 22:01:47 UTC (rev 1003) @@ -17,6 +17,11 @@ <url>http://www.gnu.org/licenses/gpl-3.0.txt</url> </license> </licenses> + <scm> + <connection>scm:svn:https://openutils.svn.sourceforge.net/svnroot/openutils/branches/openutils-mgnlmedia-3.6.x/</connection> + <developerConnection>scm:svn:https://openutils.svn.sourceforge.net/svnroot/openutils/branches/openutils-mgnlmedia-3.6.x/</developerConnection> + <url>http://openutils.svn.sourceforge.net/viewcvs.cgi/openutils/branches/openutils-mgnlmedia-3.6.x/</url> + </scm> <build> <resources> <resource> This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <fg...@us...> - 2009-02-15 22:23:21
|
Revision: 1002 http://openutils.svn.sourceforge.net/openutils/?rev=1002&view=rev Author: fgiust Date: 2009-02-15 21:55:30 +0000 (Sun, 15 Feb 2009) Log Message: ----------- Merged revisions 999-1000 via svnmerge from https://openutils.svn.sourceforge.net/svnroot/openutils/trunk/openutils-mgnlmedia ........ r999 | fgiust | 2009-02-15 21:58:20 +0100 (Sun, 15 Feb 2009) | 1 line adding support for CMYK/YCCK jpegs ........ r1000 | fgiust | 2009-02-15 22:33:35 +0100 (Sun, 15 Feb 2009) | 1 line changelog ........ Modified Paths: -------------- branches/openutils-mgnlmedia-3.6.x/pom.xml branches/openutils-mgnlmedia-3.6.x/src/main/java/net/sourceforge/openutils/mgnlmedia/media/utils/ImageUtils.java branches/openutils-mgnlmedia-3.6.x/src/main/resources/net/sourceforge/openutils/mgnlmedia/media/pages/MediaBrowserPage.html branches/openutils-mgnlmedia-3.6.x/src/site/changes/changes.xml Added Paths: ----------- branches/openutils-mgnlmedia-3.6.x/src/main/java/net/sourceforge/openutils/mgnlmedia/media/utils/BadImageFormatException.java branches/openutils-mgnlmedia-3.6.x/src/main/java/net/sourceforge/openutils/mgnlmedia/media/utils/JpegUtils.java branches/openutils-mgnlmedia-3.6.x/src/test/java/net/ branches/openutils-mgnlmedia-3.6.x/src/test/java/net/sourceforge/ branches/openutils-mgnlmedia-3.6.x/src/test/java/net/sourceforge/openutils/ branches/openutils-mgnlmedia-3.6.x/src/test/java/net/sourceforge/openutils/mgnlmedia/ branches/openutils-mgnlmedia-3.6.x/src/test/java/net/sourceforge/openutils/mgnlmedia/media/ branches/openutils-mgnlmedia-3.6.x/src/test/java/net/sourceforge/openutils/mgnlmedia/media/utils/ branches/openutils-mgnlmedia-3.6.x/src/test/java/net/sourceforge/openutils/mgnlmedia/media/utils/FileNodeData.java branches/openutils-mgnlmedia-3.6.x/src/test/java/net/sourceforge/openutils/mgnlmedia/media/utils/ImageUtilsTest.java branches/openutils-mgnlmedia-3.6.x/src/test/resources/images/ branches/openutils-mgnlmedia-3.6.x/src/test/resources/images/badimage.jpg branches/openutils-mgnlmedia-3.6.x/src/test/resources/images/badimage.txt branches/openutils-mgnlmedia-3.6.x/src/test/resources/images/ycck.jpg Removed Paths: ------------- branches/openutils-mgnlmedia-3.6.x/src/test/java/net/sourceforge/ branches/openutils-mgnlmedia-3.6.x/src/test/java/net/sourceforge/openutils/ branches/openutils-mgnlmedia-3.6.x/src/test/java/net/sourceforge/openutils/mgnlmedia/ branches/openutils-mgnlmedia-3.6.x/src/test/java/net/sourceforge/openutils/mgnlmedia/media/ branches/openutils-mgnlmedia-3.6.x/src/test/java/net/sourceforge/openutils/mgnlmedia/media/utils/ branches/openutils-mgnlmedia-3.6.x/src/test/java/net/sourceforge/openutils/mgnlmedia/media/utils/FileNodeData.java branches/openutils-mgnlmedia-3.6.x/src/test/java/net/sourceforge/openutils/mgnlmedia/media/utils/ImageUtilsTest.java branches/openutils-mgnlmedia-3.6.x/src/test/resources/images/badimage.jpg branches/openutils-mgnlmedia-3.6.x/src/test/resources/images/badimage.txt branches/openutils-mgnlmedia-3.6.x/src/test/resources/images/ycck.jpg Property Changed: ---------------- branches/openutils-mgnlmedia-3.6.x/ branches/openutils-mgnlmedia-3.6.x/src/main/resources/net/sourceforge/openutils/mgnlmedia/media/lang/ Property changes on: branches/openutils-mgnlmedia-3.6.x ___________________________________________________________________ Modified: svn:ignore - .settings .checkstyle .classpath .project target + .settings .checkstyle .classpath .project target test-output temp-testng-customsuite.xml Modified: svnmerge-integrated - /trunk/openutils-mgnlmedia:1-960 + /trunk/openutils-mgnlmedia:1-960,999-1000 Added: svn:mergeinfo + /trunk/openutils-mgnlmedia:999-1000 Modified: branches/openutils-mgnlmedia-3.6.x/pom.xml =================================================================== --- branches/openutils-mgnlmedia-3.6.x/pom.xml 2009-02-15 21:42:05 UTC (rev 1001) +++ branches/openutils-mgnlmedia-3.6.x/pom.xml 2009-02-15 21:55:30 UTC (rev 1002) @@ -1,4 +1,5 @@ -<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd"> +<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" + xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd"> <parent> <groupId>net.sourceforge.openutils</groupId> <artifactId>openutils</artifactId> @@ -56,6 +57,11 @@ <version>2.1</version> </dependency> <dependency> + <groupId>com.drewnoakes</groupId> + <artifactId>metadata-extractor</artifactId> + <version>2.4.0-beta-1</version> + </dependency> + <dependency> <groupId>org.testng</groupId> <artifactId>testng</artifactId> <classifier>jdk15</classifier> Copied: branches/openutils-mgnlmedia-3.6.x/src/main/java/net/sourceforge/openutils/mgnlmedia/media/utils/BadImageFormatException.java (from rev 1000, trunk/openutils-mgnlmedia/src/main/java/net/sourceforge/openutils/mgnlmedia/media/utils/BadImageFormatException.java) =================================================================== --- branches/openutils-mgnlmedia-3.6.x/src/main/java/net/sourceforge/openutils/mgnlmedia/media/utils/BadImageFormatException.java (rev 0) +++ branches/openutils-mgnlmedia-3.6.x/src/main/java/net/sourceforge/openutils/mgnlmedia/media/utils/BadImageFormatException.java 2009-02-15 21:55:30 UTC (rev 1002) @@ -0,0 +1,32 @@ +package net.sourceforge.openutils.mgnlmedia.media.utils; + +/** + * @author fgiust + * @version $Id$ + */ +public class BadImageFormatException extends RuntimeException +{ + + /** + * Stable serialVersionUID. + */ + private static final long serialVersionUID = 42L; + + /** + * @param message + */ + public BadImageFormatException(String message) + { + super(message); + } + + /** + * @param message + * @param cause + */ + public BadImageFormatException(String message, Throwable cause) + { + super(message, cause); + } + +} Modified: branches/openutils-mgnlmedia-3.6.x/src/main/java/net/sourceforge/openutils/mgnlmedia/media/utils/ImageUtils.java =================================================================== --- branches/openutils-mgnlmedia-3.6.x/src/main/java/net/sourceforge/openutils/mgnlmedia/media/utils/ImageUtils.java 2009-02-15 21:42:05 UTC (rev 1001) +++ branches/openutils-mgnlmedia-3.6.x/src/main/java/net/sourceforge/openutils/mgnlmedia/media/utils/ImageUtils.java 2009-02-15 21:55:30 UTC (rev 1002) @@ -52,6 +52,7 @@ import net.sourceforge.openutils.mgnlmedia.media.configuration.MediaConfigurationManager; import net.sourceforge.openutils.mgnlmedia.media.lifecycle.MediaModuleLifecycle; +import org.apache.commons.io.IOUtils; import org.apache.commons.lang.ClassUtils; import org.apache.commons.lang.StringUtils; import org.apache.commons.lang.math.NumberUtils; @@ -365,7 +366,7 @@ } } - private static InputStream getStream(BufferedImage image, String extension) throws IOException + public static InputStream getStream(BufferedImage image, String extension) throws IOException { ByteArrayOutputStream bos = new ByteArrayOutputStream(); BufferedOutputStream out = new BufferedOutputStream(bos); @@ -499,16 +500,9 @@ } extension = "jpg"; } - BufferedImage original; - try - { - original = ImageIO.read(image.getStream()); - } - catch (IOException e) - { - throw new RuntimeException(e); - } + BufferedImage original = createBufferedImage(image); + String resolutionName = "res-" + resolution; BufferedImage img = ImageUtils.getImageForResolution(original, resolution); @@ -619,4 +613,36 @@ return "jpg"; } } + + /** + * @param image + * @return + */ + public static BufferedImage createBufferedImage(NodeData image) + { + 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) + { + // throw the original exception back + throw new BadImageFormatException("Unable to handle " + image.getHandle(), e); + } + return result; + + } + finally + { + IOUtils.closeQuietly(is); + } + } + } Copied: branches/openutils-mgnlmedia-3.6.x/src/main/java/net/sourceforge/openutils/mgnlmedia/media/utils/JpegUtils.java (from rev 1000, trunk/openutils-mgnlmedia/src/main/java/net/sourceforge/openutils/mgnlmedia/media/utils/JpegUtils.java) =================================================================== --- branches/openutils-mgnlmedia-3.6.x/src/main/java/net/sourceforge/openutils/mgnlmedia/media/utils/JpegUtils.java (rev 0) +++ branches/openutils-mgnlmedia-3.6.x/src/main/java/net/sourceforge/openutils/mgnlmedia/media/utils/JpegUtils.java 2009-02-15 21:55:30 UTC (rev 1002) @@ -0,0 +1,198 @@ +package net.sourceforge.openutils.mgnlmedia.media.utils; + +import info.magnolia.cms.core.NodeData; + +import java.awt.Transparency; +import java.awt.color.ColorSpace; +import java.awt.image.BufferedImage; +import java.awt.image.ColorModel; +import java.awt.image.ComponentColorModel; +import java.awt.image.DataBuffer; +import java.awt.image.DataBufferByte; +import java.awt.image.Raster; +import java.awt.image.WritableRaster; +import java.io.IOException; +import java.io.InputStream; +import java.util.Iterator; + +import javax.imageio.ImageIO; +import javax.imageio.ImageReader; +import javax.imageio.stream.ImageInputStream; + +import org.apache.commons.io.IOUtils; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + +import com.drew.imaging.jpeg.JpegProcessingException; +import com.drew.imaging.jpeg.JpegSegmentReader; + + +/** + * Utility class for handling of CMYK/YCCK jpegs. + * @author fgiust + * @version $Id$ + */ +public class JpegUtils +{ + + /** + * Logger. + */ + private static Logger log = LoggerFactory.getLogger(JpegUtils.class); + + /** + * Java's ImageIO can't process 4-component images and Java2D can't apply AffineTransformOp either, so convert + * 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 + */ + public static BufferedImage createJPEG4(Raster raster, boolean ycckProfile) + { + int w = raster.getWidth(); + int h = raster.getHeight(); + byte[] rgb = new byte[w * h * 3]; + + // if (Adobe_APP14 and transform==2) then YCCK else CMYK + if (ycckProfile) + { // YCCK -- Adobe + + float[] Y = raster.getSamples(0, 0, w, h, 0, (float[]) null); + float[] Cb = raster.getSamples(0, 0, w, h, 1, (float[]) null); + float[] Cr = raster.getSamples(0, 0, w, h, 2, (float[]) null); + float[] K = raster.getSamples(0, 0, w, h, 3, (float[]) null); + + for (int i = 0, imax = Y.length, base = 0; i < imax; i++, base += 3) + { + float k = 220 - K[i], y = 255 - Y[i], cb = 255 - Cb[i], cr = 255 - Cr[i]; + + double val = y + 1.402 * (cr - 128) - k; + val = (val - 128) * .65f + 128; + rgb[base] = val < 0.0 ? (byte) 0 : val > 255.0 ? (byte) 0xff : (byte) (val + 0.5); + + val = y - 0.34414 * (cb - 128) - 0.71414 * (cr - 128) - k; + val = (val - 128) * .65f + 128; + rgb[base + 1] = val < 0.0 ? (byte) 0 : val > 255.0 ? (byte) 0xff : (byte) (val + 0.5); + + val = y + 1.772 * (cb - 128) - k; + val = (val - 128) * .65f + 128; + rgb[base + 2] = val < 0.0 ? (byte) 0 : val > 255.0 ? (byte) 0xff : (byte) (val + 0.5); + } + + } + else + { + // assert xform==0: xform; // CMYK + + int[] C = raster.getSamples(0, 0, w, h, 0, (int[]) null); + int[] M = raster.getSamples(0, 0, w, h, 1, (int[]) null); + int[] Y = raster.getSamples(0, 0, w, h, 2, (int[]) null); + int[] K = raster.getSamples(0, 0, w, h, 3, (int[]) null); + + for (int i = 0, imax = C.length, base = 0; i < imax; i++, base += 3) + { + int c = 255 - C[i]; + int m = 255 - M[i]; + int y = 255 - Y[i]; + int k = 255 - K[i]; + float kk = k / 255f; + + rgb[base] = (byte) (255 - Math.min(255f, c * kk + k)); + rgb[base + 1] = (byte) (255 - Math.min(255f, m * kk + k)); + rgb[base + 2] = (byte) (255 - Math.min(255f, y * kk + k)); + } + } + + // from other image types we know InterleavedRaster's can be + // manipulated by AffineTransformOp, so create one of those. + raster = Raster.createInterleavedRaster( + new DataBufferByte(rgb, rgb.length), + w, + h, + w * 3, + 3, + new int[]{0, 1, 2 }, + null); + + ColorSpace cs = ColorSpace.getInstance(ColorSpace.CS_sRGB); + ColorModel cm = new ComponentColorModel(cs, false, true, Transparency.OPAQUE, DataBuffer.TYPE_BYTE); + return new BufferedImage(cm, (WritableRaster) raster, true, null); + } + + /** + * @param image + */ + public static BufferedImage processNonStandardImage(NodeData image) + { + InputStream is2 = image.getStream(); + try + { + // Get an ImageReader. + ImageInputStream input = ImageIO.createImageInputStream(is2); + Iterator readers = ImageIO.getImageReaders(input); + if (readers == null || !readers.hasNext()) + { + throw new RuntimeException("No ImageReaders found"); + } + + ImageReader reader = (ImageReader) readers.next(); + reader.setInput(input); + String format = reader.getFormatName(); + + if ("JPEG".equalsIgnoreCase(format) || "JPG".equalsIgnoreCase(format)) + { + Raster raster = reader.readRaster(0, reader.getDefaultReadParam()); + boolean ycckProfile = false; + + // yes, we need to read it once again to extract metadatas + InputStream is3 = image.getStream(); + try + { + + JpegSegmentReader segmentReader = new JpegSegmentReader(is3); + byte[] exifSegment = segmentReader.readSegment(JpegSegmentReader.SEGMENT_APPE); + + switch (exifSegment[11]) + { + case 2 : + ycckProfile = true; + break; + case 1 : + // "YCbCr" + break; + case 0 : + default : + // Unknown (RGB or CMYK) + break; + } + } + catch (JpegProcessingException e1) + { + log.warn("Unable to read color space"); + } + finally + { + IOUtils.closeQuietly(is3); + } + + if (input != null) + { + input.close(); + } + reader.dispose(); + + return createJPEG4(raster, ycckProfile); + } + throw new BadImageFormatException("No ImageReaders found for " + image.getHandle()); + + } + catch (IOException e1) + { + log.error("Unable to handle " + image.getHandle() + ": " + e1.getMessage(), e1); + throw new BadImageFormatException(image.getHandle(), e1); + } + finally + { + IOUtils.closeQuietly(is2); + } + } +} Property changes on: branches/openutils-mgnlmedia-3.6.x/src/main/resources/net/sourceforge/openutils/mgnlmedia/media/lang ___________________________________________________________________ Modified: svn:mergeinfo - + /trunk/openutils-mgnlmedia/src/main/resources/net/sourceforge/openutils/mgnlmedia/media/lang:999-1000 Modified: branches/openutils-mgnlmedia-3.6.x/src/main/resources/net/sourceforge/openutils/mgnlmedia/media/pages/MediaBrowserPage.html =================================================================== --- branches/openutils-mgnlmedia-3.6.x/src/main/resources/net/sourceforge/openutils/mgnlmedia/media/pages/MediaBrowserPage.html 2009-02-15 21:42:05 UTC (rev 1001) +++ branches/openutils-mgnlmedia-3.6.x/src/main/resources/net/sourceforge/openutils/mgnlmedia/media/pages/MediaBrowserPage.html 2009-02-15 21:55:30 UTC (rev 1002) @@ -9,16 +9,16 @@ <script type="text/javascript" src="${this.request.contextPath}/.resources/media/js/miframe.js"></script> <script type="text/javascript"> // <![CDATA[ -var viewport; -var nodeid = "${this.nodeid!''}"; -var selectMedia = ${this.selectMedia?string("true", "false")}; -var openPath = "${this.openPath!''}"; -var actMediaHandle = "${this.actMediaHandle!''}"; -var mediaType = "${this.mediaType!''}"; // get tree url -function getTreeUrl() { - var url = "${this.request.contextPath}/.magnolia/trees/media.html?mgnlCK=" + (new Date()).getTime(); +var viewport; +var nodeid = "${this.nodeid!''}"; +var selectMedia = ${this.selectMedia?string("true", "false")}; +var openPath = "${this.openPath!''}"; +var actMediaHandle = "${this.actMediaHandle!''}"; +var mediaType = "${this.mediaType!''}"; // get tree url +function getTreeUrl() { + var url = "${this.request.contextPath}/.magnolia/trees/media.html?mgnlCK=" + (new Date()).getTime(); if (selectMedia) - { + { url += "&selectMedia=true"; } url += "&pathOpen="+ openPath +"&pathCurrent=" + openPath +"&pathSelected=" + openPath; @@ -196,12 +196,12 @@ bodyBorder: false, buttons: [ { - text: "${this.msgs.get('buttons.ok')}", + text: "${this.msgs.get('buttons.ok')}", handler: function() { uploadDlg.hide(); var ch = uploadDlg.body.child(".formToSubmit"); ch.dom.submit(); - } + } }, {text: "${this.msgs.get('buttons.cancel')}", handler: function() {uploadDlg.hide();uploadDlg.destroy();} }], keys: [],//{key: 27, fn: function() {ulDialog.hide();ulDialog.destroy();}, scope: this}] stateful: false @@ -217,7 +217,7 @@ <iframe id="mediaFolderView" name="mediaFolderView" class="x-panel-body" src="" style="width:100%;height:100%;border:none; overflow:auto"></iframe> <div id="formDiv" style="display:none"> - <form class="formToSubmit" action="" enctype="multipart/form-data" method="POST"> + <form class="formToSubmit" action="" enctype="multipart/form-data" method="post"> <input type="hidden" name="command" value="saveZip" /> <input id="parentPath" type="hidden" name="parentPath" value="{parentPath}" /> <input type="file" name="zipFile" /> Modified: branches/openutils-mgnlmedia-3.6.x/src/site/changes/changes.xml =================================================================== --- branches/openutils-mgnlmedia-3.6.x/src/site/changes/changes.xml 2009-02-15 21:42:05 UTC (rev 1001) +++ branches/openutils-mgnlmedia-3.6.x/src/site/changes/changes.xml 2009-02-15 21:55:30 UTC (rev 1002) @@ -11,5 +11,9 @@ <release version="0.1" date="2008-12-04" description=""> <action type="add" dev="fgiust">first alpha release</action> </release> + <release version="3.6" date="2009-02-15" description=""> + <action type="add" dev="fgiust">Added support for reading CMYK/YCCK jpegs</action> + <action type="update" dev="fgiust">Stable release for Magnolia 3.6.x</action> + </release> </body> </document> \ No newline at end of file Deleted: branches/openutils-mgnlmedia-3.6.x/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-02-15 21:33:35 UTC (rev 1000) +++ branches/openutils-mgnlmedia-3.6.x/src/test/java/net/sourceforge/openutils/mgnlmedia/media/utils/FileNodeData.java 2009-02-15 21:55:30 UTC (rev 1002) @@ -1,384 +0,0 @@ -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.security.AccessDeniedException; - -import java.io.ByteArrayInputStream; -import java.io.IOException; -import java.io.InputStream; -import java.util.Calendar; -import java.util.Collection; - -import javax.jcr.ItemNotFoundException; -import javax.jcr.PathNotFoundException; -import javax.jcr.Property; -import javax.jcr.RepositoryException; -import javax.jcr.Value; - -import org.apache.commons.io.IOUtils; - - -/** - * @author fgiust - * @version $Id$ - */ -public class FileNodeData implements NodeData -{ - - private byte[] content; - - public FileNodeData(String classpathLocation) throws IOException - { - InputStream is = getClass().getResourceAsStream(classpathLocation); - if (is == null) - { - throw new IllegalArgumentException("Classpath resource " + classpathLocation + " cannot be found"); - } - try - { - content = IOUtils.toByteArray(is); - } - finally - { - IOUtils.closeQuietly(is); - } - } - - /** - * {@inheritDoc} - */ - public void delete() throws RepositoryException - { - // TODO Auto-generated method stub - - } - - /** - * {@inheritDoc} - */ - public String getAttribute(String arg0) - { - // TODO Auto-generated method stub - return null; - } - - /** - * {@inheritDoc} - */ - public Collection getAttributeNames() throws RepositoryException - { - // TODO Auto-generated method stub - return null; - } - - /** - * {@inheritDoc} - */ - public boolean getBoolean() - { - // TODO Auto-generated method stub - return false; - } - - /** - * {@inheritDoc} - */ - public long getContentLength() - { - // TODO Auto-generated method stub - return 0; - } - - /** - * {@inheritDoc} - */ - public Calendar getDate() - { - // TODO Auto-generated method stub - return null; - } - - /** - * {@inheritDoc} - */ - public double getDouble() - { - // TODO Auto-generated method stub - return 0; - } - - /** - * {@inheritDoc} - */ - public String getHandle() - { - // TODO Auto-generated method stub - return null; - } - - /** - * {@inheritDoc} - */ - public HierarchyManager getHierarchyManager() throws RepositoryException - { - // TODO Auto-generated method stub - return null; - } - - /** - * {@inheritDoc} - */ - public Property getJCRProperty() - { - // TODO Auto-generated method stub - return null; - } - - /** - * {@inheritDoc} - */ - public long getLong() - { - // TODO Auto-generated method stub - return 0; - } - - /** - * {@inheritDoc} - */ - public String getName() - { - // TODO Auto-generated method stub - return null; - } - - /** - * {@inheritDoc} - */ - public Content getParent() throws AccessDeniedException, ItemNotFoundException, javax.jcr.AccessDeniedException, - RepositoryException - { - // TODO Auto-generated method stub - return null; - } - - /** - * {@inheritDoc} - */ - public Content getReferencedContent() throws RepositoryException, PathNotFoundException, RepositoryException - { - // TODO Auto-generated method stub - return null; - } - - /** - * {@inheritDoc} - */ - public Content getReferencedContent(String arg0) throws PathNotFoundException, RepositoryException - { - // TODO Auto-generated method stub - return null; - } - - /** - * {@inheritDoc} - */ - public InputStream getStream() - { - return new ByteArrayInputStream(content); - } - - /** - * {@inheritDoc} - */ - public String getString() - { - // TODO Auto-generated method stub - return null; - } - - /** - * {@inheritDoc} - */ - public String getString(String arg0) - { - // TODO Auto-generated method stub - return null; - } - - /** - * {@inheritDoc} - */ - public int getType() - { - // TODO Auto-generated method stub - return 0; - } - - /** - * {@inheritDoc} - */ - public Value getValue() - { - // TODO Auto-generated method stub - return null; - } - - /** - * {@inheritDoc} - */ - public Value[] getValues() - { - // TODO Auto-generated method stub - return null; - } - - /** - * {@inheritDoc} - */ - public boolean isExist() - { - // TODO Auto-generated method stub - return false; - } - - /** - * {@inheritDoc} - */ - public boolean isGranted(long arg0) - { - // TODO Auto-generated method stub - return false; - } - - /** - * {@inheritDoc} - */ - public int isMultiValue() - { - // TODO Auto-generated method stub - return 0; - } - - /** - * {@inheritDoc} - */ - public void refresh(boolean arg0) throws RepositoryException - { - // TODO Auto-generated method stub - - } - - /** - * {@inheritDoc} - */ - public void save() throws RepositoryException - { - // TODO Auto-generated method stub - - } - - /** - * {@inheritDoc} - */ - public void setAttribute(String arg0, String arg1) throws RepositoryException, AccessDeniedException, - UnsupportedOperationException - { - // TODO Auto-generated method stub - - } - - /** - * {@inheritDoc} - */ - public void setAttribute(String arg0, Calendar arg1) throws RepositoryException, AccessDeniedException, - UnsupportedOperationException - { - // TODO Auto-generated method stub - - } - - /** - * {@inheritDoc} - */ - public void setValue(String arg0) throws RepositoryException, AccessDeniedException - { - // TODO Auto-generated method stub - - } - - /** - * {@inheritDoc} - */ - public void setValue(int arg0) throws RepositoryException, AccessDeniedException - { - // TODO Auto-generated method stub - - } - - /** - * {@inheritDoc} - */ - public void setValue(long arg0) throws RepositoryException, AccessDeniedException - { - // TODO Auto-generated method stub - - } - - /** - * {@inheritDoc} - */ - public void setValue(InputStream arg0) throws RepositoryException, AccessDeniedException - { - // TODO Auto-generated method stub - - } - - /** - * {@inheritDoc} - */ - public void setValue(double arg0) throws RepositoryException, AccessDeniedException - { - // TODO Auto-generated method stub - - } - - /** - * {@inheritDoc} - */ - public void setValue(boolean arg0) throws RepositoryException, AccessDeniedException - { - // TODO Auto-generated method stub - - } - - /** - * {@inheritDoc} - */ - public void setValue(Calendar arg0) throws RepositoryException, AccessDeniedException - { - // TODO Auto-generated method stub - - } - - /** - * {@inheritDoc} - */ - public void setValue(Value arg0) throws RepositoryException, AccessDeniedException - { - // TODO Auto-generated method stub - - } - - /** - * {@inheritDoc} - */ - public void setValue(Value[] arg0) throws RepositoryException, AccessDeniedException - { - // TODO Auto-generated method stub - - } - -} Copied: branches/openutils-mgnlmedia-3.6.x/src/test/java/net/sourceforge/openutils/mgnlmedia/media/utils/FileNodeData.java (from rev 1000, trunk/openutils-mgnlmedia/src/test/java/net/sourceforge/openutils/mgnlmedia/media/utils/FileNodeData.java) =================================================================== --- branches/openutils-mgnlmedia-3.6.x/src/test/java/net/sourceforge/openutils/mgnlmedia/media/utils/FileNodeData.java (rev 0) +++ branches/openutils-mgnlmedia-3.6.x/src/test/java/net/sourceforge/openutils/mgnlmedia/media/utils/FileNodeData.java 2009-02-15 21:55:30 UTC (rev 1002) @@ -0,0 +1,384 @@ +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.security.AccessDeniedException; + +import java.io.ByteArrayInputStream; +import java.io.IOException; +import java.io.InputStream; +import java.util.Calendar; +import java.util.Collection; + +import javax.jcr.ItemNotFoundException; +import javax.jcr.PathNotFoundException; +import javax.jcr.Property; +import javax.jcr.RepositoryException; +import javax.jcr.Value; + +import org.apache.commons.io.IOUtils; + + +/** + * @author fgiust + * @version $Id$ + */ +public class FileNodeData implements NodeData +{ + + private byte[] content; + + public FileNodeData(String classpathLocation) throws IOException + { + InputStream is = getClass().getResourceAsStream(classpathLocation); + if (is == null) + { + throw new IllegalArgumentException("Classpath resource " + classpathLocation + " cannot be found"); + } + try + { + content = IOUtils.toByteArray(is); + } + finally + { + IOUtils.closeQuietly(is); + } + } + + /** + * {@inheritDoc} + */ + public void delete() throws RepositoryException + { + // TODO Auto-generated method stub + + } + + /** + * {@inheritDoc} + */ + public String getAttribute(String arg0) + { + // TODO Auto-generated method stub + return null; + } + + /** + * {@inheritDoc} + */ + public Collection getAttributeNames() throws RepositoryException + { + // TODO Auto-generated method stub + return null; + } + + /** + * {@inheritDoc} + */ + public boolean getBoolean() + { + // TODO Auto-generated method stub + return false; + } + + /** + * {@inheritDoc} + */ + public long getContentLength() + { + // TODO Auto-generated method stub + return 0; + } + + /** + * {@inheritDoc} + */ + public Calendar getDate() + { + // TODO Auto-generated method stub + return null; + } + + /** + * {@inheritDoc} + */ + public double getDouble() + { + // TODO Auto-generated method stub + return 0; + } + + /** + * {@inheritDoc} + */ + public String getHandle() + { + // TODO Auto-generated method stub + return null; + } + + /** + * {@inheritDoc} + */ + public HierarchyManager getHierarchyManager() throws RepositoryException + { + // TODO Auto-generated method stub + return null; + } + + /** + * {@inheritDoc} + */ + public Property getJCRProperty() + { + // TODO Auto-generated method stub + return null; + } + + /** + * {@inheritDoc} + */ + public long getLong() + { + // TODO Auto-generated method stub + return 0; + } + + /** + * {@inheritDoc} + */ + public String getName() + { + // TODO Auto-generated method stub + return null; + } + + /** + * {@inheritDoc} + */ + public Content getParent() throws AccessDeniedException, ItemNotFoundException, javax.jcr.AccessDeniedException, + RepositoryException + { + // TODO Auto-generated method stub + return null; + } + + /** + * {@inheritDoc} + */ + public Content getReferencedContent() throws RepositoryException, PathNotFoundException, RepositoryException + { + // TODO Auto-generated method stub + return null; + } + + /** + * {@inheritDoc} + */ + public Content getReferencedContent(String arg0) throws PathNotFoundException, RepositoryException + { + // TODO Auto-generated method stub + return null; + } + + /** + * {@inheritDoc} + */ + public InputStream getStream() + { + return new ByteArrayInputStream(content); + } + + /** + * {@inheritDoc} + */ + public String getString() + { + // TODO Auto-generated method stub + return null; + } + + /** + * {@inheritDoc} + */ + public String getString(String arg0) + { + // TODO Auto-generated method stub + return null; + } + + /** + * {@inheritDoc} + */ + public int getType() + { + // TODO Auto-generated method stub + return 0; + } + + /** + * {@inheritDoc} + */ + public Value getValue() + { + // TODO Auto-generated method stub + return null; + } + + /** + * {@inheritDoc} + */ + public Value[] getValues() + { + // TODO Auto-generated method stub + return null; + } + + /** + * {@inheritDoc} + */ + public boolean isExist() + { + // TODO Auto-generated method stub + return false; + } + + /** + * {@inheritDoc} + */ + public boolean isGranted(long arg0) + { + // TODO Auto-generated method stub + return false; + } + + /** + * {@inheritDoc} + */ + public int isMultiValue() + { + // TODO Auto-generated method stub + return 0; + } + + /** + * {@inheritDoc} + */ + public void refresh(boolean arg0) throws RepositoryException + { + // TODO Auto-generated method stub + + } + + /** + * {@inheritDoc} + */ + public void save() throws RepositoryException + { + // TODO Auto-generated method stub + + } + + /** + * {@inheritDoc} + */ + public void setAttribute(String arg0, String arg1) throws RepositoryException, AccessDeniedException, + UnsupportedOperationException + { + // TODO Auto-generated method stub + + } + + /** + * {@inheritDoc} + */ + public void setAttribute(String arg0, Calendar arg1) throws RepositoryException, AccessDeniedException, + UnsupportedOperationException + { + // TODO Auto-generated method stub + + } + + /** + * {@inheritDoc} + */ + public void setValue(String arg0) throws RepositoryException, AccessDeniedException + { + // TODO Auto-generated method stub + + } + + /** + * {@inheritDoc} + */ + public void setValue(int arg0) throws RepositoryException, AccessDeniedException + { + // TODO Auto-generated method stub + + } + + /** + * {@inheritDoc} + */ + public void setValue(long arg0) throws RepositoryException, AccessDeniedException + { + // TODO Auto-generated method stub + + } + + /** + * {@inheritDoc} + */ + public void setValue(InputStream arg0) throws RepositoryException, AccessDeniedException + { + // TODO Auto-generated method stub + + } + + /** + * {@inheritDoc} + */ + public void setValue(double arg0) throws RepositoryException, AccessDeniedException + { + // TODO Auto-generated method stub + + } + + /** + * {@inheritDoc} + */ + public void setValue(boolean arg0) throws RepositoryException, AccessDeniedException + { + // TODO Auto-generated method stub + + } + + /** + * {@inheritDoc} + */ + public void setValue(Calendar arg0) throws RepositoryException, AccessDeniedException + { + // TODO Auto-generated method stub + + } + + /** + * {@inheritDoc} + */ + public void setValue(Value arg0) throws RepositoryException, AccessDeniedException + { + // TODO Auto-generated method stub + + } + + /** + * {@inheritDoc} + */ + public void setValue(Value[] arg0) throws RepositoryException, AccessDeniedException + { + // TODO Auto-generated method stub + + } + +} Deleted: branches/openutils-mgnlmedia-3.6.x/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-02-15 21:33:35 UTC (rev 1000) +++ branches/openutils-mgnlmedia-3.6.x/src/test/java/net/sourceforge/openutils/mgnlmedia/media/utils/ImageUtilsTest.java 2009-02-15 21:55:30 UTC (rev 1002) @@ -1,64 +0,0 @@ -package net.sourceforge.openutils.mgnlmedia.media.utils; - -import info.magnolia.cms.core.NodeData; - -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 org.apache.commons.io.IOUtils; -import org.testng.Assert; -import org.testng.annotations.Test; - - -/** - * @author fgiust - * @version $Id$ - */ -public class ImageUtilsTest -{ - - @Test - public void testYcck() throws Exception - { - - NodeData cmyk = new FileNodeData("/images/ycck.jpg"); - BufferedImage bufferedImage = ImageUtils.createBufferedImage(cmyk); - Assert.assertNotNull(bufferedImage); - - bufferedImage = ImageUtils.resizeNoCrop(bufferedImage, 100, 100); - - InputStream is = ImageUtils.getStream(bufferedImage, "jpg"); - - 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(); - - } - - @Test - public void testBadImageTxt() throws Exception - { - - NodeData cmyk = new FileNodeData("/images/badimage.txt"); - BufferedImage bufferedImage = ImageUtils.createBufferedImage(cmyk); - Assert.assertNull(bufferedImage); - } - - @Test - public void testBadImageJpg() throws Exception - { - - NodeData cmyk = new FileNodeData("/images/badimage.jpg"); - BufferedImage bufferedImage = ImageUtils.createBufferedImage(cmyk); - Assert.assertNull(bufferedImage); - } -} Copied: branches/openutils-mgnlmedia-3.6.x/src/test/java/net/sourceforge/openutils/mgnlmedia/media/utils/ImageUtilsTest.java (from rev 1000, trunk/openutils-mgnlmedia/src/test/java/net/sourceforge/openutils/mgnlmedia/media/utils/ImageUtilsTest.java) =================================================================== --- branches/openutils-mgnlmedia-3.6.x/src/test/java/net/sourceforge/openutils/mgnlmedia/media/utils/ImageUtilsTest.java (rev 0) +++ branches/openutils-mgnlmedia-3.6.x/src/test/java/net/sourceforge/openutils/mgnlmedia/media/utils/ImageUtilsTest.java 2009-02-15 21:55:30 UTC (rev 1002) @@ -0,0 +1,64 @@ +package net.sourceforge.openutils.mgnlmedia.media.utils; + +import info.magnolia.cms.core.NodeData; + +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 org.apache.commons.io.IOUtils; +import org.testng.Assert; +import org.testng.annotations.Test; + + +/** + * @author fgiust + * @version $Id$ + */ +public class ImageUtilsTest +{ + + @Test + public void testYcck() throws Exception + { + + NodeData cmyk = new FileNodeData("/images/ycck.jpg"); + BufferedImage bufferedImage = ImageUtils.createBufferedImage(cmyk); + Assert.assertNotNull(bufferedImage); + + bufferedImage = ImageUtils.resizeNoCrop(bufferedImage, 100, 100); + + InputStream is = ImageUtils.getStream(bufferedImage, "jpg"); + + 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(); + + } + + @Test + public void testBadImageTxt() throws Exception + { + + NodeData cmyk = new FileNodeData("/images/badimage.txt"); + BufferedImage bufferedImage = ImageUtils.createBufferedImage(cmyk); + Assert.assertNull(bufferedImage); + } + + @Test + public void testBadImageJpg() throws Exception + { + + NodeData cmyk = new FileNodeData("/images/badimage.jpg"); + BufferedImage bufferedImage = ImageUtils.createBufferedImage(cmyk); + Assert.assertNull(bufferedImage); + } +} Deleted: branches/openutils-mgnlmedia-3.6.x/src/test/resources/images/badimage.jpg =================================================================== (Binary files differ) Copied: branches/openutils-mgnlmedia-3.6.x/src/test/resources/images/badimage.jpg (from rev 1000, trunk/openutils-mgnlmedia/src/test/resources/images/badimage.jpg) =================================================================== (Binary files differ) Deleted: branches/openutils-mgnlmedia-3.6.x/src/test/resources/images/badimage.txt =================================================================== --- trunk/openutils-mgnlmedia/src/test/resources/images/badimage.txt 2009-02-15 21:33:35 UTC (rev 1000) +++ branches/openutils-mgnlmedia-3.6.x/src/test/resources/images/badimage.txt 2009-02-15 21:55:30 UTC (rev 1002) @@ -1 +0,0 @@ -just a sample bad image \ No newline at end of file Copied: branches/openutils-mgnlmedia-3.6.x/src/test/resources/images/badimage.txt (from rev 1000, trunk/openutils-mgnlmedia/src/test/resources/images/badimage.txt) =================================================================== --- branches/openutils-mgnlmedia-3.6.x/src/test/resources/images/badimage.txt (rev 0) +++ branches/openutils-mgnlmedia-3.6.x/src/test/resources/images/badimage.txt 2009-02-15 21:55:30 UTC (rev 1002) @@ -0,0 +1 @@ +just a sample bad image \ No newline at end of file Deleted: branches/openutils-mgnlmedia-3.6.x/src/test/resources/images/ycck.jpg =================================================================== (Binary files differ) Copied: branches/openutils-mgnlmedia-3.6.x/src/test/resources/images/ycck.jpg (from rev 1000, trunk/openutils-mgnlmedia/src/test/resources/images/ycck.jpg) =================================================================== (Binary files differ) This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <fg...@us...> - 2009-02-15 22:33:31
|
Revision: 1004 http://openutils.svn.sourceforge.net/openutils/?rev=1004&view=rev Author: fgiust Date: 2009-02-15 22:33:26 +0000 (Sun, 15 Feb 2009) Log Message: ----------- merging recent changes Modified Paths: -------------- branches/openutils-mgnlmedia-3.6.x/src/main/java/net/sourceforge/openutils/mgnlmedia/media/configuration/MediaConfigurationManager.java branches/openutils-mgnlmedia-3.6.x/src/main/java/net/sourceforge/openutils/mgnlmedia/media/dialog/DialogSelectMedia.java branches/openutils-mgnlmedia-3.6.x/src/main/java/net/sourceforge/openutils/mgnlmedia/media/lifecycle/MediaModuleLifecycle.java branches/openutils-mgnlmedia-3.6.x/src/main/java/net/sourceforge/openutils/mgnlmedia/media/pages/MediaFolderViewPage.java branches/openutils-mgnlmedia-3.6.x/src/main/java/net/sourceforge/openutils/mgnlmedia/media/save/MediaCustomSaveHandler.java branches/openutils-mgnlmedia-3.6.x/src/main/java/net/sourceforge/openutils/mgnlmedia/media/setup/RemoveResolutionsNodeTask.java branches/openutils-mgnlmedia-3.6.x/src/main/java/net/sourceforge/openutils/mgnlmedia/media/setup/RenameThumbToImageTask.java branches/openutils-mgnlmedia-3.6.x/src/main/java/net/sourceforge/openutils/mgnlmedia/media/tree/JcrBrowserWithNodeTypeTreeConfiguration.java branches/openutils-mgnlmedia-3.6.x/src/main/java/net/sourceforge/openutils/mgnlmedia/media/tree/MediaModuleTreeConfiguration.java branches/openutils-mgnlmedia-3.6.x/src/main/java/net/sourceforge/openutils/mgnlmedia/media/types/impl/AudioTypeHandler.java branches/openutils-mgnlmedia-3.6.x/src/main/java/net/sourceforge/openutils/mgnlmedia/media/types/impl/BaseTypeHandler.java branches/openutils-mgnlmedia-3.6.x/src/main/java/net/sourceforge/openutils/mgnlmedia/media/types/impl/ImageTypeHandler.java branches/openutils-mgnlmedia-3.6.x/src/main/java/net/sourceforge/openutils/mgnlmedia/media/types/impl/VideoTypeHandler.java branches/openutils-mgnlmedia-3.6.x/src/main/java/net/sourceforge/openutils/mgnlmedia/media/types/impl/YouTubeVideoTypeHandler.java branches/openutils-mgnlmedia-3.6.x/src/main/java/net/sourceforge/openutils/mgnlmedia/media/utils/ImageUtils.java branches/openutils-mgnlmedia-3.6.x/src/main/resources/META-INF/magnolia/media.xml branches/openutils-mgnlmedia-3.6.x/src/main/resources/info/magnolia/cms/gui/control/MediaTreeFooter.ftl branches/openutils-mgnlmedia-3.6.x/src/main/resources/mgnl-resources/media/js/mootips.js branches/openutils-mgnlmedia-3.6.x/src/main/resources/net/sourceforge/openutils/mgnlmedia/media/pages/MediaBrowserPage.html branches/openutils-mgnlmedia-3.6.x/src/main/resources/net/sourceforge/openutils/mgnlmedia/media/pages/MediaFolderViewPage.html Added Paths: ----------- branches/openutils-mgnlmedia-3.6.x/src/main/resources/info/magnolia/cms/gui/control/MediaTreeAddress.ftl Property Changed: ---------------- branches/openutils-mgnlmedia-3.6.x/ Property changes on: branches/openutils-mgnlmedia-3.6.x ___________________________________________________________________ Modified: svn:ignore - .settings .checkstyle .classpath .project target test-output temp-testng-customsuite.xml svnmerge-commit-message.txt + .settings .checkstyle .classpath .project target test-output temp-testng-customsuite.xml svnmerge-commit-message.txt release.properties pom.xml.releaseBackup Modified: branches/openutils-mgnlmedia-3.6.x/src/main/java/net/sourceforge/openutils/mgnlmedia/media/configuration/MediaConfigurationManager.java =================================================================== --- branches/openutils-mgnlmedia-3.6.x/src/main/java/net/sourceforge/openutils/mgnlmedia/media/configuration/MediaConfigurationManager.java 2009-02-15 22:01:47 UTC (rev 1003) +++ branches/openutils-mgnlmedia-3.6.x/src/main/java/net/sourceforge/openutils/mgnlmedia/media/configuration/MediaConfigurationManager.java 2009-02-15 22:33:26 UTC (rev 1004) @@ -50,6 +50,8 @@ import net.sourceforge.openutils.mgnlmedia.media.pages.MediaFolderViewPage; import net.sourceforge.openutils.mgnlmedia.media.types.MediaTypeHandler; +import org.apache.commons.collections.CollectionUtils; +import org.apache.commons.collections.Predicate; import org.apache.commons.lang.StringUtils; import org.slf4j.Logger; import org.slf4j.LoggerFactory; @@ -236,7 +238,6 @@ /** * {@inheritDoc} */ - @Override public boolean accept(Content content) { try @@ -260,7 +261,6 @@ /** * {@inheritDoc} */ - @Override public int compare(Content o1, Content o2) { if (sorting.equals(MediaFolderViewPage.SORT_BY_FILENAME)) @@ -337,6 +337,41 @@ return medias; } + @SuppressWarnings("unchecked") + public Collection<Content> search(String text, final String type) throws RepositoryException + { + QueryManager qm = MgnlContext.getQueryManager(MediaModuleLifecycle.REPO); + StringBuilder sb = new StringBuilder(); + sb.append("//*[jcr:contains(.,'"); + sb.append(StringUtils.replace(text, "'", "''")); + sb.append("')] order by @jcr:score descending"); + Query q = qm.createQuery(sb.toString(), Query.XPATH); + QueryResult qr = q.execute(); + Collection c = qr.getContent(MediaConfigurationManager.MGNL_MEDIA_TYPE); + + if (!StringUtils.isBlank(type)) + { + CollectionUtils.filter(c, new Predicate() + { + + /** + * {@inheritDoc} + */ + public boolean evaluate(Object object) + { + if (object instanceof Content) + { + return NodeDataUtil.getString((Content) object, "type").equals(type); + } + return false; + } + + }); + } + + return c; + } + /** * Get the type configuration for a media * @param media media Modified: branches/openutils-mgnlmedia-3.6.x/src/main/java/net/sourceforge/openutils/mgnlmedia/media/dialog/DialogSelectMedia.java =================================================================== --- branches/openutils-mgnlmedia-3.6.x/src/main/java/net/sourceforge/openutils/mgnlmedia/media/dialog/DialogSelectMedia.java 2009-02-15 22:01:47 UTC (rev 1003) +++ branches/openutils-mgnlmedia-3.6.x/src/main/java/net/sourceforge/openutils/mgnlmedia/media/dialog/DialogSelectMedia.java 2009-02-15 22:33:26 UTC (rev 1004) @@ -298,7 +298,6 @@ /** * {@inheritDoc} */ - @Override public Object exec(List arguments) throws TemplateModelException { if (arguments != null && arguments.size() == 3 && arguments.get(0) instanceof HttpServletRequest) @@ -325,7 +324,6 @@ /** * {@inheritDoc} */ - @Override public Object exec(List arguments) throws TemplateModelException { if (arguments != null && arguments.size() == 2 && arguments.get(0) instanceof HttpServletRequest) Modified: branches/openutils-mgnlmedia-3.6.x/src/main/java/net/sourceforge/openutils/mgnlmedia/media/lifecycle/MediaModuleLifecycle.java =================================================================== --- branches/openutils-mgnlmedia-3.6.x/src/main/java/net/sourceforge/openutils/mgnlmedia/media/lifecycle/MediaModuleLifecycle.java 2009-02-15 22:01:47 UTC (rev 1003) +++ branches/openutils-mgnlmedia-3.6.x/src/main/java/net/sourceforge/openutils/mgnlmedia/media/lifecycle/MediaModuleLifecycle.java 2009-02-15 22:33:26 UTC (rev 1004) @@ -41,7 +41,6 @@ /** * {@inheritDoc} */ - @Override public void start(ModuleLifecycleContext ctx) { log.info("Starting module media"); @@ -51,7 +50,6 @@ /** * {@inheritDoc} */ - @Override public void stop(ModuleLifecycleContext ctx) { log.info("Stopping module media"); Modified: branches/openutils-mgnlmedia-3.6.x/src/main/java/net/sourceforge/openutils/mgnlmedia/media/pages/MediaFolderViewPage.java =================================================================== --- branches/openutils-mgnlmedia-3.6.x/src/main/java/net/sourceforge/openutils/mgnlmedia/media/pages/MediaFolderViewPage.java 2009-02-15 22:01:47 UTC (rev 1003) +++ branches/openutils-mgnlmedia-3.6.x/src/main/java/net/sourceforge/openutils/mgnlmedia/media/pages/MediaFolderViewPage.java 2009-02-15 22:33:26 UTC (rev 1004) @@ -54,6 +54,7 @@ import org.apache.commons.chain.Command; import org.apache.commons.lang.StringUtils; +import org.apache.jackrabbit.util.ISO9075; import org.slf4j.Logger; import org.slf4j.LoggerFactory; @@ -113,6 +114,8 @@ private boolean develop; + private String search; + /** * @param name * @param request @@ -151,7 +154,10 @@ types = MediaConfigurationManager.getInstance().getTypes().values(); } - fillNumberOfMediaPerType(); + if (!StringUtils.isBlank(path)) + { + fillNumberOfMediaPerType(); + } if (sorting == null) { @@ -167,7 +173,9 @@ QueryManager qm = MgnlContext.getQueryManager(MediaModuleLifecycle.REPO); try { - Query q = qm.createQuery(path.substring(1) + "/*[type='" + mtc.getName() + "']", Query.XPATH); + Query q = qm.createQuery( + ISO9075.encodePath(path.substring(1)) + "/*[type='" + mtc.getName() + "']", + Query.XPATH); QueryResult qr = q.execute(); numberOfMedia.put(mtc.getName(), qr.getContent(MediaConfigurationManager.MEDIA.getSystemName()).size()); @@ -186,25 +194,48 @@ public String show() { HierarchyManager hm = MgnlContext.getInstance().getHierarchyManager(MediaModuleLifecycle.REPO); + MediaTypeConfiguration mtc = MediaConfigurationManager.getInstance().getTypes().get(type); - try + Collection<Content> mediasOfType = null; + medias = new ArrayList<MediaBean>(); + + develop = SystemProperty.getBooleanProperty("magnolia.develop"); + + if (!StringUtils.isBlank(path)) { - Content folder = hm.getContent(this.getPath()); + try + { + Content folder = hm.getContent(this.getPath()); - writable = folder.isGranted(Permission.WRITE); + writable = folder.isGranted(Permission.WRITE); + canPublish = writable && ActivationManagerFactory.getActivationManager().hasAnyActiveSubscriber(); - canPublish = writable && ActivationManagerFactory.getActivationManager().hasAnyActiveSubscriber(); + mediasOfType = MediaConfigurationManager.getInstance().getMediaNodes(folder, type, sorting); - develop = SystemProperty.getBooleanProperty("magnolia.develop"); + } + catch (RepositoryException ex) + { + log.error("Exception caught", ex); + } + } + else if (!StringUtils.isBlank(search)) + { + try + { + writable = false; + canPublish = false; - medias = new ArrayList<MediaBean>(); + mediasOfType = MediaConfigurationManager.getInstance().search(search, type); - MediaTypeConfiguration mtc = MediaConfigurationManager.getInstance().getTypes().get(type); - Collection<Content> mediasOfType = MediaConfigurationManager.getInstance().getMediaNodes( - folder, - type, - sorting); + } + catch (RepositoryException ex) + { + log.error("Exception caught", ex); + } + } + if (mediasOfType != null) + { for (Content media : mediasOfType) { MediaBean mb = new MediaBean(); @@ -218,17 +249,23 @@ mb.setDescription(mtc.getHandler().getDescription(media)); mb.setUuid(media.getUUID()); - mb.getUsedInWebPages().addAll( - MediaConfigurationManager.getInstance().getUsedInWebPages(media.getUUID())); + try + { + mb.setWritable(media.getParent().isGranted(Permission.WRITE)); + mb.setCanPublish(mb.isWritable() + && ActivationManagerFactory.getActivationManager().hasAnyActiveSubscriber()); + mb.getUsedInWebPages().addAll( + MediaConfigurationManager.getInstance().getUsedInWebPages(media.getUUID())); + } + catch (RepositoryException ex) + { + log.error("Exception caught", ex); + } medias.add(mb); } + } - } - catch (RepositoryException ex) - { - log.error("Exception caught", ex); - } return super.show(); } @@ -557,6 +594,10 @@ private List<String> usedInWebPages = new ArrayList<String>(); + private boolean canPublish; + + private boolean writable; + /** * Returns the metaData. * @return the metaData @@ -719,6 +760,42 @@ this.usedInWebPages = usedInWebPages; } + /** + * Returns the canPublish. + * @return the canPublish + */ + public boolean isCanPublish() + { + return canPublish; + } + + /** + * Sets the canPublish. + * @param canPublish the canPublish to set + */ + public void setCanPublish(boolean canPublish) + { + this.canPublish = canPublish; + } + + /** + * Returns the writable. + * @return the writable + */ + public boolean isWritable() + { + return writable; + } + + /** + * Sets the writable. + * @param writable the writable to set + */ + public void setWritable(boolean writable) + { + this.writable = writable; + } + } /** @@ -883,4 +960,22 @@ this.develop = develop; } + /** + * Returns the search. + * @return the search + */ + public String getSearch() + { + return search; + } + + /** + * Sets the search. + * @param search the search to set + */ + public void setSearch(String search) + { + this.search = search; + } + } Modified: branches/openutils-mgnlmedia-3.6.x/src/main/java/net/sourceforge/openutils/mgnlmedia/media/save/MediaCustomSaveHandler.java =================================================================== --- branches/openutils-mgnlmedia-3.6.x/src/main/java/net/sourceforge/openutils/mgnlmedia/media/save/MediaCustomSaveHandler.java 2009-02-15 22:01:47 UTC (rev 1003) +++ branches/openutils-mgnlmedia-3.6.x/src/main/java/net/sourceforge/openutils/mgnlmedia/media/save/MediaCustomSaveHandler.java 2009-02-15 22:33:26 UTC (rev 1004) @@ -43,7 +43,6 @@ /** * {@inheritDoc} */ - @Override public void save(Content parentNode, Content configNode, String name, MultipartForm form, int type, int valueType, int isRichEditValue, int encoding) throws RepositoryException, AccessDeniedException { Modified: branches/openutils-mgnlmedia-3.6.x/src/main/java/net/sourceforge/openutils/mgnlmedia/media/setup/RemoveResolutionsNodeTask.java =================================================================== --- branches/openutils-mgnlmedia-3.6.x/src/main/java/net/sourceforge/openutils/mgnlmedia/media/setup/RemoveResolutionsNodeTask.java 2009-02-15 22:01:47 UTC (rev 1003) +++ branches/openutils-mgnlmedia-3.6.x/src/main/java/net/sourceforge/openutils/mgnlmedia/media/setup/RemoveResolutionsNodeTask.java 2009-02-15 22:33:26 UTC (rev 1004) @@ -54,7 +54,6 @@ /** * {@inheritDoc} */ - @Override public void execute(InstallContext installContext) throws TaskExecutionException { HierarchyManager hm = installContext.getHierarchyManager(MediaModuleLifecycle.REPO); Modified: branches/openutils-mgnlmedia-3.6.x/src/main/java/net/sourceforge/openutils/mgnlmedia/media/setup/RenameThumbToImageTask.java =================================================================== --- branches/openutils-mgnlmedia-3.6.x/src/main/java/net/sourceforge/openutils/mgnlmedia/media/setup/RenameThumbToImageTask.java 2009-02-15 22:01:47 UTC (rev 1003) +++ branches/openutils-mgnlmedia-3.6.x/src/main/java/net/sourceforge/openutils/mgnlmedia/media/setup/RenameThumbToImageTask.java 2009-02-15 22:33:26 UTC (rev 1004) @@ -56,7 +56,6 @@ /** * {@inheritDoc} */ - @Override public void execute(InstallContext installContext) throws TaskExecutionException { HierarchyManager hm = installContext.getHierarchyManager(MediaModuleLifecycle.REPO); Modified: branches/openutils-mgnlmedia-3.6.x/src/main/java/net/sourceforge/openutils/mgnlmedia/media/tree/JcrBrowserWithNodeTypeTreeConfiguration.java =================================================================== --- branches/openutils-mgnlmedia-3.6.x/src/main/java/net/sourceforge/openutils/mgnlmedia/media/tree/JcrBrowserWithNodeTypeTreeConfiguration.java 2009-02-15 22:01:47 UTC (rev 1003) +++ branches/openutils-mgnlmedia-3.6.x/src/main/java/net/sourceforge/openutils/mgnlmedia/media/tree/JcrBrowserWithNodeTypeTreeConfiguration.java 2009-02-15 22:33:26 UTC (rev 1004) @@ -54,7 +54,6 @@ /** * {@inheritDoc} */ - @Override public String renderHtml(TreeColumn treeColumn, Content content) { try Modified: branches/openutils-mgnlmedia-3.6.x/src/main/java/net/sourceforge/openutils/mgnlmedia/media/tree/MediaModuleTreeConfiguration.java =================================================================== --- branches/openutils-mgnlmedia-3.6.x/src/main/java/net/sourceforge/openutils/mgnlmedia/media/tree/MediaModuleTreeConfiguration.java 2009-02-15 22:01:47 UTC (rev 1003) +++ branches/openutils-mgnlmedia-3.6.x/src/main/java/net/sourceforge/openutils/mgnlmedia/media/tree/MediaModuleTreeConfiguration.java 2009-02-15 22:33:26 UTC (rev 1004) @@ -49,7 +49,6 @@ /** * {@inheritDoc} */ - @Override public void prepareContextMenu(Tree tree, boolean browseMode, HttpServletRequest request) { final Messages msgs = getMessages(); @@ -209,7 +208,6 @@ /** * {@inheritDoc} */ - @Override public void prepareFunctionBar(Tree tree, boolean browseMode, HttpServletRequest request) { tree.addFunctionBarItem(FunctionBarItem.getRefreshFunctionBarItem(tree, getMessages(), request)); @@ -218,7 +216,6 @@ /** * {@inheritDoc} */ - @Override public void prepareTree(Tree tree, boolean browseMode, HttpServletRequest request) { final Messages msgs = getMessages(); Modified: branches/openutils-mgnlmedia-3.6.x/src/main/java/net/sourceforge/openutils/mgnlmedia/media/types/impl/AudioTypeHandler.java =================================================================== --- branches/openutils-mgnlmedia-3.6.x/src/main/java/net/sourceforge/openutils/mgnlmedia/media/types/impl/AudioTypeHandler.java 2009-02-15 22:01:47 UTC (rev 1003) +++ branches/openutils-mgnlmedia-3.6.x/src/main/java/net/sourceforge/openutils/mgnlmedia/media/types/impl/AudioTypeHandler.java 2009-02-15 22:33:26 UTC (rev 1004) @@ -44,7 +44,6 @@ /** * {@inheritDoc} */ - @Override public void init(Content typeDefinitionNode) { @@ -53,7 +52,6 @@ /** * {@inheritDoc} */ - @Override public String getUrl(Content media) { NodeData file = media.getNodeData("audio"); @@ -67,7 +65,6 @@ /** * {@inheritDoc} */ - @Override public String getUrl(Content media, Map<String, String> options) { return getUrl(media); @@ -76,7 +73,6 @@ /** * {@inheritDoc} */ - @Override public String getFilename(Content media) { NodeData file = media.getNodeData("audio"); @@ -86,7 +82,6 @@ /** * {@inheritDoc} */ - @Override public String getExtension(Content media) { NodeData file = media.getNodeData("audio"); @@ -96,7 +91,6 @@ /** * {@inheritDoc} */ - @Override public String getFullFilename(Content media) { return getFilename(media) + "." + getExtension(media); @@ -105,7 +99,6 @@ /** * {@inheritDoc} */ - @Override public String getThumbnailUrl(Content media) { return "/.resources/media/icons/audioThumb.jpg"; @@ -114,7 +107,6 @@ /** * {@inheritDoc} */ - @Override public String getPreviewUrl(Content media) { return getUrl(media); @@ -143,7 +135,6 @@ /** * {@inheritDoc} */ - @Override public String getNewNodeName(MultipartForm form) { return form.getParameter("audio_" + FileProperties.PROPERTY_FILENAME); @@ -152,7 +143,6 @@ /** * {@inheritDoc} */ - @Override public boolean onSavingPropertyMedia(Content media, Content parentNode, Content configNode, String name, MultipartForm form, int type, int valueType, int isRichEditValue, int encoding) throws RepositoryException, AccessDeniedException Modified: branches/openutils-mgnlmedia-3.6.x/src/main/java/net/sourceforge/openutils/mgnlmedia/media/types/impl/BaseTypeHandler.java =================================================================== --- branches/openutils-mgnlmedia-3.6.x/src/main/java/net/sourceforge/openutils/mgnlmedia/media/types/impl/BaseTypeHandler.java 2009-02-15 22:01:47 UTC (rev 1003) +++ branches/openutils-mgnlmedia-3.6.x/src/main/java/net/sourceforge/openutils/mgnlmedia/media/types/impl/BaseTypeHandler.java 2009-02-15 22:33:26 UTC (rev 1004) @@ -64,7 +64,6 @@ /** * {@inheritDoc} */ - @Override public String getTitle(Content media) { return getPropertyLocalized(media, "title"); @@ -73,7 +72,6 @@ /** * {@inheritDoc} */ - @Override public String getTags(Content media) { return getPropertyLocalized(media, "tags"); @@ -82,7 +80,6 @@ /** * {@inheritDoc} */ - @Override public String getDescription(Content media) { return getPropertyLocalized(media, "description"); @@ -91,7 +88,6 @@ /** * {@inheritDoc} */ - @Override public String getAbstract(Content media) { return getPropertyLocalized(media, "abstract"); @@ -101,7 +97,6 @@ * {@inheritDoc} */ @SuppressWarnings("unchecked") - @Override public boolean onPostSave(Content media) { try Modified: branches/openutils-mgnlmedia-3.6.x/src/main/java/net/sourceforge/openutils/mgnlmedia/media/types/impl/ImageTypeHandler.java =================================================================== --- branches/openutils-mgnlmedia-3.6.x/src/main/java/net/sourceforge/openutils/mgnlmedia/media/types/impl/ImageTypeHandler.java 2009-02-15 22:01:47 UTC (rev 1003) +++ branches/openutils-mgnlmedia-3.6.x/src/main/java/net/sourceforge/openutils/mgnlmedia/media/types/impl/ImageTypeHandler.java 2009-02-15 22:33:26 UTC (rev 1004) @@ -55,7 +55,6 @@ /** * {@inheritDoc} */ - @Override public void init(Content typeDefinitionNode) { @@ -64,7 +63,6 @@ /** * {@inheritDoc} */ - @Override public String getFilename(Content media) { NodeData file = media.getNodeData("image"); @@ -74,7 +72,6 @@ /** * {@inheritDoc} */ - @Override public String getExtension(Content media) { NodeData file = media.getNodeData("image"); @@ -84,7 +81,6 @@ /** * {@inheritDoc} */ - @Override public String getFullFilename(Content media) { return getFilename(media) + "." + getExtension(media); @@ -93,7 +89,6 @@ /** * {@inheritDoc} */ - @Override public String getUrl(Content media) { NodeData file = media.getNodeData("image"); @@ -107,7 +102,6 @@ /** * {@inheritDoc} */ - @Override public String getUrl(Content media, Map<String, String> options) { return getUrl(media); @@ -116,7 +110,6 @@ /** * {@inheritDoc} */ - @Override public String getThumbnailUrl(Content media) { if (!ImageUtils.checkOrCreateResolution(media, "thumbnail")) @@ -132,7 +125,6 @@ /** * {@inheritDoc} */ - @Override public String getPreviewUrl(Content media) { if (!ImageUtils.checkOrCreateResolution(media, "preview")) @@ -148,8 +140,8 @@ /** * {@inheritDoc} */ - @SuppressWarnings("unchecked") @Override + @SuppressWarnings("unchecked") public boolean onPostSave(Content media) { Collection<NodeData> nds = media.getNodeDataCollection("tags-*"); @@ -174,7 +166,6 @@ /** * {@inheritDoc} */ - @Override public void saveFromZipFile(Content media, File f, String cleanFileName, String extension) throws AccessDeniedException, RepositoryException { @@ -189,7 +180,6 @@ /** * {@inheritDoc} */ - @Override public String getNewNodeName(MultipartForm form) { return form.getParameter("image_" + FileProperties.PROPERTY_FILENAME); @@ -198,7 +188,6 @@ /** * {@inheritDoc} */ - @Override public boolean onSavingPropertyMedia(final Content media, final Content parentNode, final Content configNode, final String name, final MultipartForm form, final int type, final int valueType, final int isRichEditValue, final int encoding) throws RepositoryException, AccessDeniedException Modified: branches/openutils-mgnlmedia-3.6.x/src/main/java/net/sourceforge/openutils/mgnlmedia/media/types/impl/VideoTypeHandler.java =================================================================== --- branches/openutils-mgnlmedia-3.6.x/src/main/java/net/sourceforge/openutils/mgnlmedia/media/types/impl/VideoTypeHandler.java 2009-02-15 22:01:47 UTC (rev 1003) +++ branches/openutils-mgnlmedia-3.6.x/src/main/java/net/sourceforge/openutils/mgnlmedia/media/types/impl/VideoTypeHandler.java 2009-02-15 22:33:26 UTC (rev 1004) @@ -47,7 +47,6 @@ /** * {@inheritDoc} */ - @Override public void init(Content typeDefinitionNode) { @@ -56,7 +55,6 @@ /** * {@inheritDoc} */ - @Override public String getUrl(Content media) { NodeData file = media.getNodeData("video"); @@ -70,7 +68,6 @@ /** * {@inheritDoc} */ - @Override public String getUrl(Content media, Map<String, String> options) { return getUrl(media); @@ -79,7 +76,6 @@ /** * {@inheritDoc} */ - @Override public String getFilename(Content media) { NodeData file = media.getNodeData("video"); @@ -89,7 +85,6 @@ /** * {@inheritDoc} */ - @Override public String getExtension(Content media) { NodeData file = media.getNodeData("video"); @@ -99,7 +94,6 @@ /** * {@inheritDoc} */ - @Override public String getFullFilename(Content media) { return getFilename(media) + "." + getExtension(media); @@ -108,7 +102,6 @@ /** * {@inheritDoc} */ - @Override public String getThumbnailUrl(Content media) { if (!ImageUtils.checkOrCreateResolution(media, "thumbnail")) @@ -124,7 +117,6 @@ /** * {@inheritDoc} */ - @Override public String getPreviewUrl(Content media) { return getUrl(media); @@ -153,7 +145,6 @@ /** * {@inheritDoc} */ - @Override public String getNewNodeName(MultipartForm form) { return form.getParameter("video_" + FileProperties.PROPERTY_FILENAME); @@ -162,7 +153,6 @@ /** * {@inheritDoc} */ - @Override public boolean onSavingPropertyMedia(Content media, Content parentNode, Content configNode, String name, MultipartForm form, int type, int valueType, int isRichEditValue, int encoding) throws RepositoryException, AccessDeniedException Modified: branches/openutils-mgnlmedia-3.6.x/src/main/java/net/sourceforge/openutils/mgnlmedia/media/types/impl/YouTubeVideoTypeHandler.java =================================================================== --- branches/openutils-mgnlmedia-3.6.x/src/main/java/net/sourceforge/openutils/mgnlmedia/media/types/impl/YouTubeVideoTypeHandler.java 2009-02-15 22:01:47 UTC (rev 1003) +++ branches/openutils-mgnlmedia-3.6.x/src/main/java/net/sourceforge/openutils/mgnlmedia/media/types/impl/YouTubeVideoTypeHandler.java 2009-02-15 22:33:26 UTC (rev 1004) @@ -54,7 +54,6 @@ /** * {@inheritDoc} */ - @Override public void init(Content typeDefinitionNode) { @@ -63,7 +62,6 @@ /** * {@inheritDoc} */ - @Override public String getUrl(Content media) { return media.getNodeData("videoUrl").getString(); @@ -72,7 +70,6 @@ /** * {@inheritDoc} */ - @Override public String getUrl(Content media, Map<String, String> options) { return getUrl(media); @@ -81,7 +78,6 @@ /** * {@inheritDoc} */ - @Override public String getFilename(Content media) { return getUrl(media); @@ -90,7 +86,6 @@ /** * {@inheritDoc} */ - @Override public String getExtension(Content media) { return null; @@ -99,7 +94,6 @@ /** * {@inheritDoc} */ - @Override public String getFullFilename(Content media) { return null; @@ -108,7 +102,6 @@ /** * {@inheritDoc} */ - @Override public String getThumbnailUrl(Content media) { if (!ImageUtils.checkOrCreateResolution(media, "thumbnail")) @@ -124,7 +117,6 @@ /** * {@inheritDoc} */ - @Override public String getPreviewUrl(Content media) { return getUrl(media); @@ -148,7 +140,6 @@ /** * {@inheritDoc} */ - @Override public String getNewNodeName(MultipartForm form) { String videoUrl = form.getParameter("videoUrl"); @@ -176,7 +167,6 @@ /** * {@inheritDoc} */ - @Override public boolean onSavingPropertyMedia(Content media, Content parentNode, Content configNode, String name, MultipartForm form, int type, int valueType, int isRichEditValue, int encoding) throws RepositoryException, AccessDeniedException Modified: branches/openutils-mgnlmedia-3.6.x/src/main/java/net/sourceforge/openutils/mgnlmedia/media/utils/ImageUtils.java =================================================================== --- branches/openutils-mgnlmedia-3.6.x/src/main/java/net/sourceforge/openutils/mgnlmedia/media/utils/ImageUtils.java 2009-02-15 22:01:47 UTC (rev 1003) +++ branches/openutils-mgnlmedia-3.6.x/src/main/java/net/sourceforge/openutils/mgnlmedia/media/utils/ImageUtils.java 2009-02-15 22:33:26 UTC (rev 1004) @@ -450,7 +450,6 @@ /** * {@inheritDoc} */ - @Override public void exec() { HierarchyManager hm = MgnlContext.getHierarchyManager(MediaModuleLifecycle.REPO); Modified: branches/openutils-mgnlmedia-3.6.x/src/main/resources/META-INF/magnolia/media.xml =================================================================== --- branches/openutils-mgnlmedia-3.6.x/src/main/resources/META-INF/magnolia/media.xml 2009-02-15 22:01:47 UTC (rev 1003) +++ branches/openutils-mgnlmedia-3.6.x/src/main/resources/META-INF/magnolia/media.xml 2009-02-15 22:33:26 UTC (rev 1004) @@ -10,11 +10,11 @@ <dependencies> <dependency> <name>adminInterface</name> - <version>3.1/*</version> + <version>3.6/*</version> </dependency> <dependency> <name>cache</name> - <version>3.1/*</version> + <version>3.6/*</version> </dependency> </dependencies> <repositories> Added: branches/openutils-mgnlmedia-3.6.x/src/main/resources/info/magnolia/cms/gui/control/MediaTreeAddress.ftl =================================================================== --- branches/openutils-mgnlmedia-3.6.x/src/main/resources/info/magnolia/cms/gui/control/MediaTreeAddress.ftl (rev 0) +++ branches/openutils-mgnlmedia-3.6.x/src/main/resources/info/magnolia/cms/gui/control/MediaTreeAddress.ftl 2009-02-15 22:33:26 UTC (rev 1004) @@ -0,0 +1,2 @@ +<img src="${contextPath}/.resources/0.gif" height="3px"/> +<input id="${tree.javascriptTree}SearchBar" type="text" onkeydown="if (mgnlIsKeyEnter(event)) parent.search(this.value);" class="mgnlDialogControlEdit" style="width:100%;" value="" /> \ No newline at end of file Property changes on: branches/openutils-mgnlmedia-3.6.x/src/main/resources/info/magnolia/cms/gui/control/MediaTreeAddress.ftl ___________________________________________________________________ Added: svn:mime-type + text/plain Added: svn:eol-style + native Modified: branches/openutils-mgnlmedia-3.6.x/src/main/resources/info/magnolia/cms/gui/control/MediaTreeFooter.ftl =================================================================== --- branches/openutils-mgnlmedia-3.6.x/src/main/resources/info/magnolia/cms/gui/control/MediaTreeFooter.ftl 2009-02-15 22:01:47 UTC (rev 1003) +++ branches/openutils-mgnlmedia-3.6.x/src/main/resources/info/magnolia/cms/gui/control/MediaTreeFooter.ftl 2009-02-15 22:33:26 UTC (rev 1004) @@ -1,10 +1,10 @@ <!-- line for moving to the bottom --> <div id="${lineId}" class="mgnlTreeLineInter mgnlLineEnabled" onmouseover="${tree.javascriptTree}.moveNodeHighlightLine('${lineId}');" onmouseout="${tree.javascriptTree}.moveNodeResetLine('${lineId}');" onmousedown="${tree.javascriptTree}.pasteNode('${tree.path}',${PASTETYPE_SUB},${permissionWrite?string},'${lineId}');"></div> - + <!-- this is needed for IE else you can't scroll. Do not ask me why! --> <div style="position:absolute;" > </div> - + <!-- do we have write permission on the root? --> <input type="hidden" name="${tree.javascriptTree}_${tree.path}_PermissionWrite" id="${tree.javascriptTree}_${tree.path}_PermissionWrite" value="${permissionWrite?string}" /> @@ -21,7 +21,11 @@ ${menu.html} </#if> -<#if tree.browseMode && !selectMedia> +<#if tree.browseMode && selectMedia?exists && selectMedia> + <#include "MediaTreeAddress.ftl"/> +</#if> + +<#if tree.browseMode && (!selectMedia?exists || !selectMedia)> <#include "TreeAddressBar.ftl"/> </#if> Modified: branches/openutils-mgnlmedia-3.6.x/src/main/resources/mgnl-resources/media/js/mootips.js =================================================================== --- branches/openutils-mgnlmedia-3.6.x/src/main/resources/mgnl-resources/media/js/mootips.js 2009-02-15 22:01:47 UTC (rev 1003) +++ branches/openutils-mgnlmedia-3.6.x/src/main/resources/mgnl-resources/media/js/mootips.js 2009-02-15 22:33:26 UTC (rev 1004) @@ -1,22 +1,45 @@ var TipsEx = new Class( { - Extends :Tips, + Extends :Tips, - initialize : function(elements, options) { - this.parent(elements, options); - this.tip.addEvents( { - mouseenter :this.enterTip.bind(this), - mouseleave :this.leaveTip.bind(this) - }); - }, + initialize : function(elements, options) { + this.parent(elements, options); + this.tip.addEvents( { + mouseenter :this.enterTip.bind(this), + mouseleave :this.leaveTip.bind(this) + }); + }, - enterTip : function() { - this.timer = $clear(this.timer); - }, + enterTip : function() { + this.timer = $clear(this.timer); + }, - leaveTip : function() { - $clear(this.timer); - this.timer = this.hide.delay(this.options.hideDelay, this); - } + leaveTip : function() { + $clear(this.timer); + this.timer = this.hide.delay(this.options.hideDelay, this); + }, + position : function(event) { + var size = window.getSize(), scroll = window.getScroll(); + var tip = { + x :this.tip.offsetWidth, + y :this.tip.offsetHeight + }; + var props = { + x :'left', + y :'top' + }; + for ( var z in props) { + var pos = event.page[z] + this.options.offsets[z]; + if ((pos + tip[z] - scroll[z]) > size[z]) { + pos = pos - ((pos + tip[z] - scroll[z]) - size[z]); + if (pos < 0) + { + pos = 0; + } + } + this.tip.setStyle(props[z], pos); + } + } + }); \ No newline at end of file Modified: branches/openutils-mgnlmedia-3.6.x/src/main/resources/net/sourceforge/openutils/mgnlmedia/media/pages/MediaBrowserPage.html =================================================================== --- branches/openutils-mgnlmedia-3.6.x/src/main/resources/net/sourceforge/openutils/mgnlmedia/media/pages/MediaBrowserPage.html 2009-02-15 22:01:47 UTC (rev 1003) +++ branches/openutils-mgnlmedia-3.6.x/src/main/resources/net/sourceforge/openutils/mgnlmedia/media/pages/MediaBrowserPage.html 2009-02-15 22:33:26 UTC (rev 1004) @@ -29,6 +29,21 @@ return url; } +function search(textToSearch) { + viewport.getComponent('center-panel').setTitle("Search results for : "+ textToSearch); + + var url = "${this.request.contextPath}/.magnolia/pages/mediaFolderView.html?search="+ textToSearch + "&mgnlCK=" + (new Date()).getTime(); + if (selectMedia) + { + url += "&selectMedia=true&actMediaHandle="+ actMediaHandle; + } + if (mediaType != null && mediaType != 'null') + { + url += "&mediaType=" + mediaType; + } + frames['mediaFolderView'].location.href = url; +} + Ext.onReady(function(){ Ext.state.Manager.setProvider(new Ext.state.CookieProvider()); Modified: branches/openutils-mgnlmedia-3.6.x/src/main/resources/net/sourceforge/openutils/mgnlmedia/media/pages/MediaFolderViewPage.html =================================================================== --- branches/openutils-mgnlmedia-3.6.x/src/main/resources/net/sourceforge/openutils/mgnlmedia/media/pages/MediaFolderViewPage.html 2009-02-15 22:01:47 UTC (rev 1003) +++ branches/openutils-mgnlmedia-3.6.x/src/main/resources/net/sourceforge/openutils/mgnlmedia/media/pages/MediaFolderViewPage.html 2009-02-15 22:33:26 UTC (rev 1004) @@ -13,59 +13,59 @@ <script type="text/javascript" src="${this.request.contextPath}/.resources/media/js/multibox/multibox.js"></script> <script type="text/javascript" src="${this.request.contextPath}/.resources/media/js/multibox/overlay.js"></script> <script type="text/javascript"> <#list this.types as type> <#if type.name == this.type> <#assign currentType = type> </#if> </#list> - + function openDialog(path) { parent.openWindow(".magnolia/dialogs/${currentType.dialog}.html?mgnlPath=" + path + "&mgnlRepository=media"); } - + function openMediaTree(action, path) { parent.openWindow(".magnolia/pages/mediaFolderSelection.html?sourceNode="+ path +"&action="+ action +"&mgnlCK=" + (new Date()).getTime()); } - + function performAction(action, source, dest) { - if (action == "move" && dest == "${this.path}") + if (action == "move" && dest == "${this.path!""}") { alert("Non è possibile spostare all'interno dello stesso nodo."); return; - } + } $("actionCmd").value = action; $("actionNode").value = source; $("actionDest").value = dest; $("actionForm").submit(); } - + function deleteMedia(source) { if (confirm("Sei sicuro di voler eliminare l'immagine?")) { performAction("delete", source, ""); } } - + function selectMedia(uuid, thumb, file) { parent.setNewMedia(uuid, thumb, file); } - + var isTreeCollapsed = false; - + window.addEvent(Browser.Engine.name == 'trident' ? 'load' : 'domready', function(){ var multibox = new MultiBox('multibox', { path: '${this.request.contextPath}/.resources/media/players/', - useOverlay: true, + useOverlay: true, onOpen: function(){ isTreeCollapsed = parent.isTreeCollapsed(); if (!isTreeCollapsed) { parent.setTreeCollapsed(true); - } + } }, onClose: function(){ if (!isTreeCollapsed) { parent.setTreeCollapsed(false); - } + } } }); @@ -80,36 +80,37 @@ showDelay: 100, hideDelay: 200 }); - + }); - + </script> </head> <body> <form action="" style="display:none" id="actionForm"> <input type="hidden" id="actionCmd" name="command" value="delete" /> - <input type="hidden" id="actionPath" name="path" value="${this.path}" /> + <input type="hidden" id="actionPath" name="path" value="${this.path!""}" /> + <input type="hidden" id="actionSearch" name="search" value="${this.search!""}" /> <input type="hidden" id="actionNode" name="node" /> <input type="hidden" id="actionDest" name="dest" /> <input type="hidden" name="type" value="${this.type}" /> </form> <div id="navigation"> - <#list this.types as type> - <#if type.name == this.type> - <#assign actual = "actual"> - <#else> + <#list this.types as type> + <#if type.name == this.type> + <#assign actual = "actual"> + <#else> <#assign actual = ""> </#if> <div class="voice ${actual}"> - <#if this.request.parameterMap['selectMedia']?exists> - <a href="?type=${type.name}&path=${this.path}&selectMedia=true"> + <#if this.request.parameterMap['selectMedia']?exists> + <a href="?type=${type.name}&path=${this.path!""}&selectMedia=true&search=${this.search!""}"> <img src="${this.request.contextPath}${type.menuIcon}" border="0" align="absmiddle" /> - ${this.msgs.get('media.types.' + type.name)} (${this.numberOfMedia[type.name]!'0'}) + ${this.msgs.get('media.types.' + type.name)} <#if this.numberOfMedia?exists>(${this.numberOfMedia[type.name]!'0'})</#if> </a> <#else> - <a href="?type=${type.name}&path=${this.path}"> + <a href="?type=${type.name}&path=${this.path!""}&search=${this.search!""}"> <img src="${this.request.contextPath}${type.menuIcon}" border="0" align="absmiddle" /> - ${this.msgs.get('media.types.' + type.name)} (${this.numberOfMedia[type.name]!'0'}) + ${this.msgs.get('media.types.' + type.name)} <#if this.numberOfMedia?exists>(${this.numberOfMedia[type.name]!'0'})</#if> </a> </#if> </div> @@ -118,17 +119,17 @@ </div> <ul class="mediaList"> <#assign index = 0> - <#list this.medias as media> - <#if media.filename?length gt 18> + <#list this.medias as media> + <#if media.filename?length gt 18> <#assign name = media.filename?substring(0,15)> - <#assign name = name?right_pad(18, ".")> - <#else> - <#assign name = media.filename> + <#assign name = name?right_pad(18, ".")> + <#else> + <#assign name = media.filename> </#if> <#assign index = index + 1 > - <#assign mediaStatusClass = ""> + <#assign mediaStatusClass = ""> <#if this.selectMedia && !this.develop> - <#assign mediaStatusClass = "mediaStatus${media.metaData.activationStatus}"> + <#assign mediaStatusClass = "mediaStatus${media.metaData.activationStatus}"> </#if> <li class="media ${mediaStatusClass}" style="text-align:center"> <div class="imageBorder"> @@ -150,7 +151,7 @@ ${this.msgs.get('media.select')} </a> <#else> - <#if this.canPublish && media.metaData.activationStatus < 2> + <#if media.canPublish && media.metaData.activationStatus < 2> <a href="javascript:$empty()" onclick="performAction('activate', '${media.handle}','')" title="pubblica"> <img src="${this.request.contextPath}/.resources/icons/16/arrow_right_green.gif" border="0" align="middle" /> </a> @@ -159,7 +160,7 @@ </#if> </#if> <#else> - <#if this.writable> + <#if media.writable> <a href="javascript:$empty()" onclick="openDialog('${media.handle}')" title="${this.msgs.get('media.edit')}"> <img src="${this.request.contextPath}/.resources/media/icons/edit.gif" border="0" align="middle" /> </a> @@ -185,8 +186,8 @@ <a> <img src="${this.request.contextPath}/.resources/icons/16/copy_inactive.gif" border="0" align="middle" /> </a> - </#if> - <#if this.canPublish> + </#if> + <#if media.canPublish> <a href="javascript:$empty()" onclick="performAction('activate', '${media.handle}','')" title="${this.msgs.get('media.activate')}"> <img src="${this.request.contextPath}/.resources/icons/16/arrow_right_green.gif" border="0" align="middle" /> </a> @@ -196,7 +197,7 @@ align="middle" /> </a> </#if> - <#if this.canPublish && media.metaData.activationStatus = 2> + <#if media.canPublish && media.metaData.activationStatus = 2> <a href="javascript:$empty()" onclick="performAction('deactivate', '${media.handle}','')" title="${this.msgs.get('media.deactivate')}"> <img src="${this.request.contextPath}/.resources/icons/16/arrow_left_red.gif" border="0" align="middle" /> </a> @@ -208,13 +209,13 @@ </#if> </#if> </div> - <div class="used"> + <div class="used"> <#if media.usedInWebPages?size = 0> <span>${this.msgs.get('media.nopages')}</span> - <#else> + <#else> <#assign pages = ""> <#list media.usedInWebPages as page> - <#assign pages = pages + "<a href='${this.request.contextPath}" + page +".html' target='_blank'>"+ page +"</a><br/>"> + <#assign pages = pages + "<a href='${this.request.contextPath}" + page +".html' target='_blank'>"+ page +"</a><br/>"> </#list> <span class="tips" rel="${pages}">${this.msgs.get('media.pages')} (${media.usedInWebPages?size})</span> </#if> This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |