From: <die...@us...> - 2010-02-26 09:01:49
|
Revision: 2062 http://openutils.svn.sourceforge.net/openutils/?rev=2062&view=rev Author: diego_schivo Date: 2010-02-26 09:01:42 +0000 (Fri, 26 Feb 2010) Log Message: ----------- MEDIA-105 warn logs fixing NPE exceptions Modified Paths: -------------- trunk/openutils-mgnlmedia/src/main/java/net/sourceforge/openutils/mgnlmedia/playlist/pages/PlaylistView.java 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-02-24 22:43:45 UTC (rev 2061) +++ trunk/openutils-mgnlmedia/src/main/java/net/sourceforge/openutils/mgnlmedia/playlist/pages/PlaylistView.java 2010-02-26 09:01:42 UTC (rev 2062) @@ -31,11 +31,14 @@ import javax.servlet.http.HttpServletResponse; import net.sourceforge.openutils.mgnlmedia.media.lifecycle.MediaModule; +import net.sourceforge.openutils.mgnlmedia.media.pages.MediaFolderViewPage; import net.sourceforge.openutils.mgnlmedia.media.pages.MessagesTemplatedMVCHandler; import net.sourceforge.openutils.mgnlmedia.media.tags.el.MediaEl; import net.sourceforge.openutils.mgnlmedia.playlist.PlaylistConstants; import org.apache.commons.lang.StringUtils; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; /** @@ -44,6 +47,11 @@ public class PlaylistView extends MessagesTemplatedMVCHandler { + /** + * Logger. + */ + private Logger log = LoggerFactory.getLogger(PlaylistView.class); + private String path; private PlaylistBean playlist; @@ -105,26 +113,44 @@ if (StringUtils.isNotBlank(path)) { Content node = ContentUtil.getContent(PlaylistConstants.REPO, path); - playlist = new PlaylistBean(); - playlist.setHandle(node.getHandle()); - playlist.setTitle(NodeDataUtil.getString(node, "title")); - playlist.setDescription(NodeDataUtil.getString(node, "description")); - List<PlaylistEntryBean> entries = new ArrayList<PlaylistEntryBean>(); - for (Content subNode : node.getChildren(PlaylistConstants.PLAYLIST_ENTRY)) + if (node != null) { - String mediaUUID = NodeDataUtil.getString(subNode, "media"); - Content media = ContentUtil.getContentByUUID(MediaModule.REPO, mediaUUID); - PlaylistEntryBean entry = new PlaylistEntryBean(); - entry.setHandle(subNode.getHandle()); - entry.setMedia(media.getUUID()); - entry.setThumbnail(MediaEl.thumbnail(media)); - entry.setType(NodeDataUtil.getString(media, "type")); - entry.setTitle(MediaEl.title(media)); - entry.setDescription(MediaEl.desc(media)); - entry.setTags(StringUtils.join(MediaEl.tags(media), ", ")); - entries.add(entry); + playlist = new PlaylistBean(); + playlist.setHandle(node.getHandle()); + playlist.setTitle(NodeDataUtil.getString(node, "title")); + playlist.setDescription(NodeDataUtil.getString(node, "description")); + List<PlaylistEntryBean> entries = new ArrayList<PlaylistEntryBean>(); + for (Content subNode : node.getChildren(PlaylistConstants.PLAYLIST_ENTRY)) + { + String mediaUUID = NodeDataUtil.getString(subNode, "media"); + Content media = ContentUtil.getContentByUUID(MediaModule.REPO, mediaUUID); + if (media != null) + { + PlaylistEntryBean entry = new PlaylistEntryBean(); + entry.setHandle(subNode.getHandle()); + entry.setMedia(media.getUUID()); + entry.setThumbnail(MediaEl.thumbnail(media)); + entry.setType(NodeDataUtil.getString(media, "type")); + entry.setTitle(MediaEl.title(media)); + entry.setDescription(MediaEl.desc(media)); + entry.setTags(StringUtils.join(MediaEl.tags(media), ", ")); + entries.add(entry); + } + else + { + log.warn( + "Node {} referenced by entry {} of playlist {} does not exist in media repository", + new Object[]{ + mediaUUID, subNode.getName(), playlist.getHandle() + }); + } + } + playlist.setEntries(entries); } - playlist.setEntries(entries); + else + { + log.warn("Node {} does not exist in playlist repository", path); + } } return super.show(); } This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <fg...@us...> - 2010-03-19 23:15:53
|
Revision: 2181 http://openutils.svn.sourceforge.net/openutils/?rev=2181&view=rev Author: fgiust Date: 2010-03-19 23:15:47 +0000 (Fri, 19 Mar 2010) Log Message: ----------- cosmetic change Modified Paths: -------------- trunk/openutils-mgnlmedia/src/main/java/net/sourceforge/openutils/mgnlmedia/playlist/pages/PlaylistView.java 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-03-19 22:56:05 UTC (rev 2180) +++ trunk/openutils-mgnlmedia/src/main/java/net/sourceforge/openutils/mgnlmedia/playlist/pages/PlaylistView.java 2010-03-19 23:15:47 UTC (rev 2181) @@ -60,7 +60,7 @@ private String description; /** - * + * */ public PlaylistView(String name, HttpServletRequest request, HttpServletResponse response) { @@ -122,18 +122,19 @@ List<PlaylistEntryBean> entries = new ArrayList<PlaylistEntryBean>(); for (Content subNode : node.getChildren(PlaylistConstants.PLAYLIST_ENTRY)) { - PlaylistEntryBean entry = new PlaylistEntryBean(); - entry.setHandle(subNode.getHandle()); String mediaUUID = NodeDataUtil.getString(subNode, "media"); Content media = ContentUtil.getContentByUUID(MediaModule.REPO, mediaUUID); if (media != null) { + PlaylistEntryBean entry = new PlaylistEntryBean(); + entry.setHandle(subNode.getHandle()); entry.setMedia(media.getUUID()); entry.setThumbnail(MediaEl.thumbnail(media)); entry.setType(NodeDataUtil.getString(media, "type")); entry.setTitle(MediaEl.title(media)); entry.setDescription(MediaEl.desc(media)); entry.setTags(StringUtils.join(MediaEl.tags(media), ", ")); + entries.add(entry); } else { @@ -141,7 +142,6 @@ "Node {} referenced by entry {} of playlist {} does not exist in media repository", new Object[]{mediaUUID, subNode.getName(), playlist.getHandle() }); } - entries.add(entry); } playlist.setEntries(entries); } This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <fg...@us...> - 2010-04-25 16:50:40
|
Revision: 2299 http://openutils.svn.sourceforge.net/openutils/?rev=2299&view=rev Author: fgiust Date: 2010-04-25 16:50:33 +0000 (Sun, 25 Apr 2010) Log Message: ----------- magnolia 4.0 compatibility Modified Paths: -------------- trunk/openutils-mgnlmedia/src/main/java/net/sourceforge/openutils/mgnlmedia/playlist/pages/PlaylistView.java 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-04-23 15:35:36 UTC (rev 2298) +++ trunk/openutils-mgnlmedia/src/main/java/net/sourceforge/openutils/mgnlmedia/playlist/pages/PlaylistView.java 2010-04-25 16:50:33 UTC (rev 2299) @@ -24,6 +24,7 @@ import info.magnolia.cms.util.NodeDataUtil; import java.util.ArrayList; +import java.util.Collection; import java.util.List; import javax.jcr.RepositoryException; @@ -120,7 +121,9 @@ playlist.setTitle(NodeDataUtil.getString(node, "title")); playlist.setDescription(NodeDataUtil.getString(node, "description")); List<PlaylistEntryBean> entries = new ArrayList<PlaylistEntryBean>(); - for (Content subNode : node.getChildren(PlaylistConstants.PLAYLIST_ENTRY)) + + Collection<Content> children = node.getChildren(PlaylistConstants.PLAYLIST_ENTRY); + for (Content subNode : children) { String mediaUUID = NodeDataUtil.getString(subNode, "media"); Content media = ContentUtil.getContentByUUID(MediaModule.REPO, mediaUUID); This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <fg...@us...> - 2010-04-25 18:02:09
|
Revision: 2304 http://openutils.svn.sourceforge.net/openutils/?rev=2304&view=rev Author: fgiust Date: 2010-04-25 18:02:01 +0000 (Sun, 25 Apr 2010) Log Message: ----------- remove usage of deprecated methods Modified Paths: -------------- trunk/openutils-mgnlmedia/src/main/java/net/sourceforge/openutils/mgnlmedia/playlist/pages/PlaylistView.java 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-04-25 17:56:58 UTC (rev 2303) +++ trunk/openutils-mgnlmedia/src/main/java/net/sourceforge/openutils/mgnlmedia/playlist/pages/PlaylistView.java 2010-04-25 18:02:01 UTC (rev 2304) @@ -20,6 +20,7 @@ package net.sourceforge.openutils.mgnlmedia.playlist.pages; import info.magnolia.cms.core.Content; +import info.magnolia.cms.i18n.I18nContentSupportFactory; import info.magnolia.cms.util.ContentUtil; import info.magnolia.cms.util.NodeDataUtil; @@ -121,7 +122,7 @@ playlist.setTitle(NodeDataUtil.getString(node, "title")); playlist.setDescription(NodeDataUtil.getString(node, "description")); List<PlaylistEntryBean> entries = new ArrayList<PlaylistEntryBean>(); - + Collection<Content> children = node.getChildren(PlaylistConstants.PLAYLIST_ENTRY); for (Content subNode : children) { @@ -134,9 +135,15 @@ entry.setMedia(media.getUUID()); entry.setThumbnail(MediaEl.thumbnail(media)); entry.setType(NodeDataUtil.getString(media, "type")); - entry.setTitle(MediaEl.title(media)); - entry.setDescription(MediaEl.desc(media)); - entry.setTags(StringUtils.join(MediaEl.tags(media), ", ")); + entry.setTitle(I18nContentSupportFactory + .getI18nSupport() + .getNodeData(media, "title") + .getString()); + entry.setDescription(I18nContentSupportFactory.getI18nSupport().getNodeData( + media, + "description").getString()); + entry + .setTags(I18nContentSupportFactory.getI18nSupport().getNodeData(media, "tags").getString()); entries.add(entry); } else This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <die...@us...> - 2011-01-21 09:12:18
|
Revision: 3253 http://openutils.svn.sourceforge.net/openutils/?rev=3253&view=rev Author: diego_schivo Date: 2011-01-21 09:12:12 +0000 (Fri, 21 Jan 2011) Log Message: ----------- PIRMEDIA-201 playlist-view: i18n Modified Paths: -------------- trunk/openutils-mgnlmedia/src/main/java/net/sourceforge/openutils/mgnlmedia/playlist/pages/PlaylistView.java 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 2011-01-18 09:13:47 UTC (rev 3252) +++ trunk/openutils-mgnlmedia/src/main/java/net/sourceforge/openutils/mgnlmedia/playlist/pages/PlaylistView.java 2011-01-21 09:12:12 UTC (rev 3253) @@ -28,10 +28,12 @@ import java.io.IOException; import java.util.ArrayList; import java.util.Collection; +import java.util.HashMap; import java.util.LinkedHashMap; import java.util.List; import java.util.Locale; import java.util.Map; +import java.util.Map.Entry; import javax.jcr.RepositoryException; import javax.servlet.http.HttpServletRequest; @@ -171,11 +173,23 @@ Content node = ContentUtil.getContent(PlaylistConstants.REPO, path); if (node != null) { + Map<String, String> propNames = new HashMap<String, String>(); + propNames.put("title", "title"); + propNames.put("description", "description"); + propNames.put("tags", "tags"); + if (!StringUtils.isEmpty(locale)) + { + for (Entry<String, String> entry : propNames.entrySet()) + { + entry.setValue(entry.getValue() + "_" + locale); + } + } + playlist = new PlaylistBean(); playlist.setUuid(node.getUUID()); playlist.setHandle(node.getHandle()); - playlist.setTitle(NodeDataUtil.getString(node, "title")); - playlist.setDescription(NodeDataUtil.getString(node, "description")); + playlist.setTitle(NodeDataUtil.getString(node, propNames.get("title"))); + playlist.setDescription(NodeDataUtil.getString(node, propNames.get("description"))); List<PlaylistEntryBean> entries = new ArrayList<PlaylistEntryBean>(); Collection<Content> children = node.getChildren(PlaylistConstants.PLAYLIST_ENTRY); @@ -200,14 +214,14 @@ entry.setType(NodeDataUtil.getString(media, "type")); entry.setTitle(I18nContentSupportFactory .getI18nSupport() - .getNodeData(media, "title") + .getNodeData(media, propNames.get("title")) .getString()); entry.setDescription(I18nContentSupportFactory .getI18nSupport() - .getNodeData(media, "description") + .getNodeData(media, propNames.get("description")) .getString()); entry - .setTags(I18nContentSupportFactory.getI18nSupport().getNodeData(media, "tags").getString()); + .setTags(I18nContentSupportFactory.getI18nSupport().getNodeData(media, propNames.get("tags")).getString()); entries.add(entry); } else This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <die...@us...> - 2011-01-21 10:08:46
|
Revision: 3256 http://openutils.svn.sourceforge.net/openutils/?rev=3256&view=rev Author: diego_schivo Date: 2011-01-21 10:08:40 +0000 (Fri, 21 Jan 2011) Log Message: ----------- PIRMEDIA-201 fallback locale Modified Paths: -------------- trunk/openutils-mgnlmedia/src/main/java/net/sourceforge/openutils/mgnlmedia/playlist/pages/PlaylistView.java 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 2011-01-21 10:05:15 UTC (rev 3255) +++ trunk/openutils-mgnlmedia/src/main/java/net/sourceforge/openutils/mgnlmedia/playlist/pages/PlaylistView.java 2011-01-21 10:08:40 UTC (rev 3256) @@ -48,6 +48,7 @@ import net.sourceforge.openutils.mgnlmedia.media.tags.el.MediaEl; import net.sourceforge.openutils.mgnlmedia.playlist.PlaylistConstants; +import org.apache.commons.lang.LocaleUtils; import org.apache.commons.lang.StringUtils; import org.slf4j.Logger; import org.slf4j.LoggerFactory; @@ -179,9 +180,13 @@ propNames.put("tags", "tags"); if (!StringUtils.isEmpty(locale)) { - for (Entry<String, String> entry : propNames.entrySet()) + Locale l = LocaleUtils.toLocale(locale); + if (!I18nContentSupportFactory.getI18nSupport().getFallbackLocale().equals(l)) { - entry.setValue(entry.getValue() + "_" + locale); + for (Entry<String, String> entry : propNames.entrySet()) + { + entry.setValue(entry.getValue() + "_" + l); + } } } This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <die...@us...> - 2011-02-07 17:57:01
|
Revision: 3307 http://openutils.svn.sourceforge.net/openutils/?rev=3307&view=rev Author: diego_schivo Date: 2011-02-07 17:56:54 +0000 (Mon, 07 Feb 2011) Log Message: ----------- MEDIA-214 playlist view Modified Paths: -------------- trunk/openutils-mgnlmedia/src/main/java/net/sourceforge/openutils/mgnlmedia/playlist/pages/PlaylistView.java 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 2011-02-07 15:05:15 UTC (rev 3306) +++ trunk/openutils-mgnlmedia/src/main/java/net/sourceforge/openutils/mgnlmedia/playlist/pages/PlaylistView.java 2011-02-07 17:56:54 UTC (rev 3307) @@ -20,15 +20,20 @@ package net.sourceforge.openutils.mgnlmedia.playlist.pages; import info.magnolia.cms.core.Content; +import info.magnolia.cms.core.ItemType; import info.magnolia.cms.i18n.I18nContentSupportFactory; import info.magnolia.cms.util.ContentUtil; import info.magnolia.cms.util.NodeDataUtil; import info.magnolia.context.MgnlContext; import java.io.IOException; +import java.lang.reflect.Array; import java.util.ArrayList; import java.util.Collection; +import java.util.Collections; +import java.util.Enumeration; import java.util.HashMap; +import java.util.Iterator; import java.util.LinkedHashMap; import java.util.List; import java.util.Locale; @@ -36,15 +41,21 @@ import java.util.Map.Entry; import javax.jcr.RepositoryException; +import javax.jcr.Value; import javax.servlet.http.HttpServletRequest; +import javax.servlet.http.HttpServletRequestWrapper; import javax.servlet.http.HttpServletResponse; +import net.sourceforge.openutils.mgnlcriteria.jcr.query.AdvancedResult; +import net.sourceforge.openutils.mgnlcriteria.jcr.query.AdvancedResultItem; +import net.sourceforge.openutils.mgnlcriteria.jcr.query.ResultIterator; 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 net.sourceforge.openutils.mgnlmedia.media.pages.MediaBean; import net.sourceforge.openutils.mgnlmedia.media.pages.MediaBeanBuilder; import net.sourceforge.openutils.mgnlmedia.media.pages.MessagesTemplatedMVCHandler; +import net.sourceforge.openutils.mgnlmedia.media.pages.SortMode; import net.sourceforge.openutils.mgnlmedia.media.tags.el.MediaEl; import net.sourceforge.openutils.mgnlmedia.playlist.PlaylistConstants; @@ -204,29 +215,8 @@ Content media = ContentUtil.getContentByUUID(MediaModule.REPO, mediaUUID); if (media != null) { - PlaylistEntryBean entry = new PlaylistEntryBean(); + PlaylistEntryBean entry = playlistEntryBean(media, propNames); entry.setHandle(subNode.getHandle()); - entry.setMedia(media.getUUID()); - entry.setMediaHandle(media.getHandle()); - MediaTypeConfiguration typeConf = MediaConfigurationManager - .getInstance() - .getMediaTypeConfigurationFromMedia(media); - if (typeConf != null) - { - entry.setMediaDialog(typeConf.getDialog()); - } - entry.setThumbnail(MediaEl.thumbnail(media)); - entry.setType(NodeDataUtil.getString(media, "type")); - entry.setTitle(I18nContentSupportFactory - .getI18nSupport() - .getNodeData(media, propNames.get("title")) - .getString()); - entry.setDescription(I18nContentSupportFactory - .getI18nSupport() - .getNodeData(media, propNames.get("description")) - .getString()); - entry - .setTags(I18nContentSupportFactory.getI18nSupport().getNodeData(media, propNames.get("tags")).getString()); entries.add(entry); } else @@ -236,6 +226,51 @@ new Object[]{mediaUUID, subNode.getName(), playlist.getHandle() }); } } + + String requestNodeName = "request"; + try + { + if (node.hasContent(requestNodeName)) + { + Content requestNode = node.getContent(requestNodeName); + Collection<Content> paramNodes = requestNode.getChildren(ItemType.CONTENTNODE); + final Map<String, String[]> map = new HashMap<String, String[]>(); + for (Content paramNode : paramNodes) + { + String paramName = NodeDataUtil.getString(paramNode, "name"); + Value[] jcrValues = paramNode.getNodeData("value").getValues(); + String[] paramValues = new String[jcrValues.length]; + for (int i = 0; i < jcrValues.length; i++) + { + paramValues[i] = jcrValues[i].getString(); + } + map.put(paramName, paramValues); + } + AdvancedResult searchResult = MediaEl + .module() + .getSearch() + .search( + new CustomParamsRequest(request, map, false), + null, + null, + true, + SortMode.SCORE, + 0, + 1); + ResultIterator<AdvancedResultItem> items = searchResult.getItems(); + while (items.hasNext()) + { + AdvancedResultItem item = items.next(); + PlaylistEntryBean entry = playlistEntryBean(item, propNames); + entries.add(entry); + } + } + } + catch (RepositoryException e) + { + // TODO Auto-generated catch block + e.printStackTrace(); + } playlist.setEntries(entries); } else @@ -428,4 +463,139 @@ return metas; } + private PlaylistEntryBean playlistEntryBean(Content media, Map<String, String> propNames) + { + PlaylistEntryBean entry = new PlaylistEntryBean(); + entry.setMedia(media.getUUID()); + entry.setMediaHandle(media.getHandle()); + MediaTypeConfiguration typeConf = MediaConfigurationManager.getInstance().getMediaTypeConfigurationFromMedia( + media); + if (typeConf != null) + { + entry.setMediaDialog(typeConf.getDialog()); + } + entry.setThumbnail(MediaEl.thumbnail(media)); + entry.setType(NodeDataUtil.getString(media, "type")); + entry.setTitle(I18nContentSupportFactory + .getI18nSupport() + .getNodeData(media, propNames.get("title")) + .getString()); + entry.setDescription(I18nContentSupportFactory + .getI18nSupport() + .getNodeData(media, propNames.get("description")) + .getString()); + entry.setTags(I18nContentSupportFactory.getI18nSupport().getNodeData(media, propNames.get("tags")).getString()); + return entry; + + } + + // freemarker.ext.servlet.IncludePage.CustomParamsRequest + private static final class CustomParamsRequest extends HttpServletRequestWrapper + { + + private final HashMap paramsMap; + + private CustomParamsRequest(HttpServletRequest request, Map paramMap, boolean inheritParams) + { + super(request); + paramsMap = inheritParams ? new HashMap(request.getParameterMap()) : new HashMap(); + for (Iterator it = paramMap.entrySet().iterator(); it.hasNext();) + { + Map.Entry entry = (Map.Entry) it.next(); + String name = String.valueOf(entry.getKey()); + Object value = entry.getValue(); + final String[] valueArray; + if (value == null) + { + // Null values are explicitly added (so, among other + // things, we can hide inherited param values). + valueArray = new String[]{null }; + } + else if (value instanceof String[]) + { + // String[] arrays are just passed through + valueArray = (String[]) value; + } + else if (value instanceof Collection) + { + // Collections are converted to String[], with + // String.valueOf() used on elements + Collection col = (Collection) value; + valueArray = new String[col.size()]; + int i = 0; + for (Iterator it2 = col.iterator(); it2.hasNext();) + { + valueArray[i++] = String.valueOf(it2.next()); + } + } + else if (value.getClass().isArray()) + { + // Other array types are too converted to String[], with + // String.valueOf() used on elements + int len = Array.getLength(value); + valueArray = new String[len]; + for (int i = 0; i < len; ++i) + { + valueArray[i] = String.valueOf(Array.get(value, i)); + } + } + else + { + // All other values (including strings) are converted to a + // single-element String[], with String.valueOf applied to + // the value. + valueArray = new String[]{String.valueOf(value) }; + } + String[] existingParams = (String[]) paramsMap.get(name); + int el = existingParams == null ? 0 : existingParams.length; + if (el == 0) + { + // No original params, just put our array + paramsMap.put(name, valueArray); + } + else + { + int vl = valueArray.length; + if (vl > 0) + { + // Both original params and new params, prepend our + // params to original params + String[] newValueArray = new String[el + vl]; + System.arraycopy(valueArray, 0, newValueArray, 0, vl); + System.arraycopy(existingParams, 0, newValueArray, vl, el); + paramsMap.put(name, newValueArray); + } + } + } + } + + public String[] getParameterValues(String name) + { + String[] value = ((String[]) paramsMap.get(name)); + return value != null ? (String[]) value.clone() : null; + } + + public String getParameter(String name) + { + String[] values = (String[]) paramsMap.get(name); + return values != null && values.length > 0 ? values[0] : null; + } + + public Enumeration getParameterNames() + { + return Collections.enumeration(paramsMap.keySet()); + } + + public Map getParameterMap() + { + HashMap clone = (HashMap) paramsMap.clone(); + for (Iterator it = clone.entrySet().iterator(); it.hasNext();) + { + Map.Entry entry = (Map.Entry) it.next(); + entry.setValue(((String[]) entry.getValue()).clone()); + } + return Collections.unmodifiableMap(clone); + } + } + } This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <die...@us...> - 2011-02-08 14:38:43
|
Revision: 3321 http://openutils.svn.sourceforge.net/openutils/?rev=3321&view=rev Author: diego_schivo Date: 2011-02-08 14:38:37 +0000 (Tue, 08 Feb 2011) Log Message: ----------- MEDIA-214 playlist save Modified Paths: -------------- trunk/openutils-mgnlmedia/src/main/java/net/sourceforge/openutils/mgnlmedia/playlist/pages/PlaylistView.java 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 2011-02-08 14:28:30 UTC (rev 3320) +++ trunk/openutils-mgnlmedia/src/main/java/net/sourceforge/openutils/mgnlmedia/playlist/pages/PlaylistView.java 2011-02-08 14:38:37 UTC (rev 3321) @@ -262,7 +262,7 @@ "/", true, SortMode.SCORE, - 0, + (int) NodeDataUtil.getLong(node, "maxResults", 0), 1); ResultIterator<AdvancedResultItem> items = searchResult.getItems(); while (items.hasNext()) This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |