From: <fg...@us...> - 2010-04-26 17:04:58
|
Revision: 2311 http://openutils.svn.sourceforge.net/openutils/?rev=2311&view=rev Author: fgiust Date: 2010-04-26 17:04:52 +0000 (Mon, 26 Apr 2010) Log Message: ----------- MEDIA-128 remove deprecated method calls and be careful when using getContent() on wrapped nodes (ContentWrapper is buggy, it also wrap nulls!) 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/main/resources/mgnl-files/templates/samples-media/paragraph-mediatag.jsp 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-04-26 16:43:55 UTC (rev 2310) +++ trunk/openutils-mgnlmedia/src/main/java/net/sourceforge/openutils/mgnlmedia/media/tags/el/MediaEl.java 2010-04-26 17:04:52 UTC (rev 2311) @@ -193,7 +193,7 @@ public static String titleLoc(Content media, Locale locale) { log.warn("\"titleLoc()\" has been deprecated, please check javadocs"); - + if (media == null) { return null; @@ -224,7 +224,7 @@ public static String[] tagsLoc(Content media, Locale locale) { log.warn("\"tagsLoc()\" has been deprecated, please check javadocs"); - + if (media == null) { return null; @@ -257,7 +257,7 @@ public static String desc(Content media) { log.warn("\"desc()\" has been deprecated, please check javadocs"); - + return descLoc(media, null); } @@ -271,7 +271,7 @@ public static String title(Content media) { log.warn("\"title()\" has been deprecated, please check javadocs"); - + return titleLoc(media, null); } @@ -285,7 +285,7 @@ public static String[] tags(Content media) { log.warn("\"tags()\" has been deprecated, please check javadocs"); - + return tagsLoc(media, null); } @@ -362,7 +362,7 @@ List<String> res = new ArrayList<String>(); - Content resolutions = media.getChildByName("resolutions"); + Content resolutions = getResolutionsNode(media); Collection<NodeData> nodeDataCollection = resolutions.getNodeDataCollection(); @@ -417,7 +417,7 @@ return null; } - Content resolutions = media.getChildByName("resolutions"); + Content resolutions = getResolutionsNode(media); try { @@ -455,7 +455,7 @@ } else { - Content resolutions = media.getChildByName("resolutions"); + Content resolutions = getResolutionsNode(media); if (resolutions != null) { try @@ -758,4 +758,27 @@ return usedInWebPages(media); } + /** + * Returns the "resolutions" node, checking for existence + * @param media + * @return + */ + protected static Content getResolutionsNode(final Content media) + { + Content resolutions = null; + + try + { + if (media.hasContent("resolutions")) + { + resolutions = media.getContent("resolutions"); + } + } + catch (RepositoryException e) + { + // ignore, try to create it + } + return resolutions; + } + } 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-04-26 16:43:55 UTC (rev 2310) +++ trunk/openutils-mgnlmedia/src/main/java/net/sourceforge/openutils/mgnlmedia/media/utils/ImageUtils.java 2010-04-26 17:04:52 UTC (rev 2311) @@ -389,7 +389,7 @@ throw new IllegalArgumentException("Stream is null"); } - Content resolutions = saveTo.getChildByName("resolutions"); + Content resolutions = getResolutionsNode(saveTo); if (resolutions == null) { resolutions = saveTo.createContent("resolutions", MediaConfigurationManager.RESOLUTIONS); @@ -413,6 +413,7 @@ nd.delete(); } + // don't remove deprecated method call, needed for magnolia 4.0 compatibility NodeData nd = resolutions.createNodeData(resolution, PropertyType.BINARY); log.info("setting value to {}", nd.getHandle()); @@ -610,7 +611,7 @@ String nodeDataName) { - Content resolutions = media.getChildByName("resolutions"); + Content resolutions = getResolutionsNode(media); String resolution = resolutionTarget; @@ -805,6 +806,29 @@ return true; } + /** + * Returns the "resolutions" node, checking for existence + * @param media + * @return + */ + protected static Content getResolutionsNode(final Content media) + { + Content resolutions = null; + + try + { + if (media.hasContent("resolutions")) + { + resolutions = media.getContent("resolutions"); + } + } + catch (RepositoryException e) + { + // ignore, try to create it + } + return resolutions; + } + private static Map<String, String> parseParameters(String resolution) { Modified: trunk/openutils-mgnlmedia/src/main/resources/mgnl-files/templates/samples-media/paragraph-mediatag.jsp =================================================================== --- trunk/openutils-mgnlmedia/src/main/resources/mgnl-files/templates/samples-media/paragraph-mediatag.jsp 2010-04-26 16:43:55 UTC (rev 2310) +++ trunk/openutils-mgnlmedia/src/main/resources/mgnl-files/templates/samples-media/paragraph-mediatag.jsp 2010-04-26 17:04:52 UTC (rev 2311) @@ -5,7 +5,7 @@ <div class="textImage"> <c:set var="mediaNode" value="${media:node(content.media)}" /> <div> - <h3>${media:desc(mediaNode) }</h3> + <h3>${mediaNode.description}</h3> <div> <pre>&lt;media:media item="${content.media}" width="50" height="30" videoImagePreview="true" /></pre> <media:media item="${content.media}" width="50" height="30" videoImagePreview="true" /> This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |