From f55454c8f71c1390671721d4441b476288cd682d Mon Sep 17 00:00:00 2001 From: Peter Dietz Date: Fri, 28 Oct 2011 23:30:14 +0000 Subject: [PATCH] [DS-528] Added configurable option to choose which mimetype can get podcasted. Changed configuration key for external sourceuri. git-svn-id: http://scm.dspace.org/svn/repo/dspace/trunk@6830 9c30dcfa-912a-0410-8fc2-9e0234be79fd --- .../java/org/dspace/app/util/SyndicationFeed.java | 15 +++++++-------- dspace/config/dspace.cfg | 8 ++++++-- 2 files changed, 13 insertions(+), 10 deletions(-) diff --git a/dspace-api/src/main/java/org/dspace/app/util/SyndicationFeed.java b/dspace-api/src/main/java/org/dspace/app/util/SyndicationFeed.java index 497ddc6ee1..bc7df891ee 100644 --- a/dspace-api/src/main/java/org/dspace/app/util/SyndicationFeed.java +++ b/dspace-api/src/main/java/org/dspace/app/util/SyndicationFeed.java @@ -9,10 +9,8 @@ package org.dspace.app.util; import java.io.IOException; import java.util.ArrayList; -import java.util.Arrays; import java.util.Date; import java.util.List; -import java.util.Locale; import java.util.Map; import javax.servlet.http.HttpServletRequest; @@ -28,7 +26,6 @@ import org.dspace.content.DCDate; import org.dspace.content.DCValue; import org.dspace.content.DSpaceObject; import org.dspace.content.Item; -import org.dspace.content.MetadataSchema; import org.dspace.core.ConfigurationManager; import org.dspace.core.Constants; import org.dspace.handle.HandleManager; @@ -106,8 +103,8 @@ public class SyndicationFeed private static String authorField = getDefaultedConfiguration("webui.feed.item.author", defaultAuthorField); - // metadata field for Item external media source url - private static String sourceField = getDefaultedConfiguration("webui.feed.item.sourceuri", defaultExternalMedia); + // metadata field for Podcast external media source url + private static String externalSourceField = getDefaultedConfiguration("webui.feed.podcast.sourceuri", defaultExternalMedia); // metadata field for Item dc:creator field in entry's DCModule (no default) private static String dcCreatorField = ConfigurationManager.getProperty("webui.feed.item.dc.creator"); @@ -118,6 +115,8 @@ public class SyndicationFeed // metadata field for Item dc:author field in entry's DCModule (no default) private static String dcDescriptionField = ConfigurationManager.getProperty("webui.feed.item.dc.description"); + // List of available mimetypes that we'll add to podcast feed. Multiple values separated by commas + private static String podcastableMIMETypes = getDefaultedConfiguration("webui.feed.podcast.mimetypes", "audio/x-mpeg"); // -------- Instance variables: @@ -369,7 +368,7 @@ public class SyndicationFeed Bitstream[] bits = bunds[0].getBitstreams(); for (int i = 0; (i < bits.length); i++) { String mime = bits[i].getFormat().getMIMEType(); - if(mime.contains("audio/x-mpeg")) { + if(podcastableMIMETypes.contains(mime)) { SyndEnclosure enc = new SyndEnclosureImpl(); enc.setType(bits[i].getFormat().getMIMEType()); enc.setLength(bits[i].getSize()); @@ -382,13 +381,13 @@ public class SyndicationFeed } //Also try to add an external value from dc.identifier.other // We are assuming that if this is set, then it is a media file - DCValue[] externalMedia = item.getMetadata(sourceField); + DCValue[] externalMedia = item.getMetadata(externalSourceField); if(externalMedia.length > 0) { for(int i = 0; i< externalMedia.length; i++) { SyndEnclosure enc = new SyndEnclosureImpl(); - enc.setType("audio/x-mpeg"); + enc.setType("audio/x-mpeg"); //We can't determine MIME of external file, so just picking one. enc.setLength(1); enc.setUrl(externalMedia[i].value); enclosures.add(enc); diff --git a/dspace/config/dspace.cfg b/dspace/config/dspace.cfg index 6c6b47078b..8365c30c81 100644 --- a/dspace/config/dspace.cfg +++ b/dspace/config/dspace.cfg @@ -1149,12 +1149,16 @@ webui.feed.item.author = dc.contributor.author # webui.feed.podcast.collections =123456789/2,123456789/3 # webui.feed.podcast.communities =123456789/1 -# For the iTunes Podcast Feed, if you would like to specify an external media file, +# Which MIMETypes of Bitstreams would you like to have podcastable in your item? +# Separate multiple entries with commas. +#webui.feed.podcast.mimetypes=audio/x-mpeg + +# For the iTunes Podcast Feed, if you would like to specify an external media file, # not on your DSpace server to be enclosed within the entry for each item, # specify which metadata field will hold the URI to the external media file. # This is useful if you store the metadata in DSpace, and a seperate streaming server to host the media. # Default: dc.source.uri -#webui.feed.item.sourceuri = dc.source.uri +#webui.feed.podcast.sourceuri = dc.source.uri #### OpenSearch Settings #### # NB: for result data formatting, OpenSearch uses Syndication Feed Settings