Package org.dspace.app.util
Class SyndicationFeed
- java.lang.Object
-
- org.dspace.app.util.SyndicationFeed
-
public class SyndicationFeed extends Object
Invoke ROME library to assemble a generic model of a syndication for the given list of Items and scope. Consults configuration for the metadata bindings to feed elements. Uses ROME's output drivers to return any of the implemented formats, e.g. RSS 1.0, RSS 2.0, ATOM 1.0. The feed generator and OpenSearch call on this class so feed contents are uniform for both.- Author:
- Larry Stone
-
-
Field Summary
-
Constructor Summary
Constructors Constructor Description SyndicationFeed(String ui)Constructor.
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description voidaddModule(com.rometools.rome.feed.module.Module m)Add a ROME plugin module (e.g.protected static StringgetDefaultedConfiguration(String key, String dfl)static String[]getDescriptionSelectors()Returns list of metadata selectors used to compose the description elementprotected StringgetOneDC(Item item, String field)protected Stringlocalize(Map<String,String> labels, String s)voidoutput(Writer writer)send the output to designated WriterStringoutputString()DocumentoutputW3CDom()voidpopulate(javax.servlet.http.HttpServletRequest request, Context context, IndexableObject dso, List<IndexableObject> items, Map<String,String> labels)Fills in the feed and entry-level metadata from DSpace objects.protected StringresolveURL(javax.servlet.http.HttpServletRequest request, DSpaceObject dso)Return a url to the DSpace object, either use the official handle for the item or build a url based upon the current server.voidsetType(String feedType)Sets the feed type for XML delivery, e.g.protected StringurlOfBitstream(javax.servlet.http.HttpServletRequest request, Bitstream logo)
-
-
-
Field Detail
-
log
protected final org.apache.logging.log4j.Logger log
-
MSG_UNTITLED
public static final String MSG_UNTITLED
i18n key values- See Also:
- Constant Field Values
-
MSG_LOGO_TITLE
public static final String MSG_LOGO_TITLE
- See Also:
- Constant Field Values
-
MSG_FEED_TITLE
public static final String MSG_FEED_TITLE
- See Also:
- Constant Field Values
-
MSG_FEED_DESCRIPTION
public static final String MSG_FEED_DESCRIPTION
- See Also:
- Constant Field Values
-
MSG_METADATA
public static final String MSG_METADATA
- See Also:
- Constant Field Values
-
MSG_UITYPE
public static final String MSG_UITYPE
- See Also:
- Constant Field Values
-
UITYPE_XMLUI
public static final String UITYPE_XMLUI
- See Also:
- Constant Field Values
-
UITYPE_JSPUI
public static final String UITYPE_JSPUI
- See Also:
- Constant Field Values
-
defaultTitleField
protected String defaultTitleField
-
defaultDescriptionField
protected String defaultDescriptionField
-
defaultAuthorField
protected String defaultAuthorField
-
defaultDateField
protected String defaultDateField
-
defaultExternalMedia
protected String defaultExternalMedia
-
titleField
protected String titleField
-
dateField
protected String dateField
-
authorField
protected String authorField
-
externalSourceField
protected String externalSourceField
-
dcCreatorField
protected String dcCreatorField
-
dcDateField
protected String dcDateField
-
dcDescriptionField
protected String dcDescriptionField
-
podcastableMIMETypes
protected String[] podcastableMIMETypes
-
feed
protected com.rometools.rome.feed.synd.SyndFeed feed
-
uiType
protected String uiType
-
request
protected javax.servlet.http.HttpServletRequest request
-
collectionService
protected CollectionService collectionService
-
communityService
protected CommunityService communityService
-
itemService
protected ItemService itemService
-
baseURL
protected String baseURL
-
-
Constructor Detail
-
SyndicationFeed
public SyndicationFeed(String ui)
Constructor.- Parameters:
ui- either "xmlui" or "jspui"
-
-
Method Detail
-
getDescriptionSelectors
public static String[] getDescriptionSelectors()
Returns list of metadata selectors used to compose the description element- Returns:
- selector list - format 'schema.element[.qualifier]'
-
populate
public void populate(javax.servlet.http.HttpServletRequest request, Context context, IndexableObject dso, List<IndexableObject> items, Map<String,String> labels)Fills in the feed and entry-level metadata from DSpace objects.- Parameters:
request- requestcontext- contextdso- the scopeitems- array of objectslabels- label map
-
setType
public void setType(String feedType)
Sets the feed type for XML delivery, e.g. "rss_1.0", "atom_1.0" Must match one of ROME's configured generators, see rome.properties (currently rss_1.0, rss_2.0, atom_1.0, atom_0.3)- Parameters:
feedType- feed type
-
outputW3CDom
public Document outputW3CDom() throws com.rometools.rome.io.FeedException
- Returns:
- the feed we built as DOM Document
- Throws:
com.rometools.rome.io.FeedException- if feed error
-
outputString
public String outputString() throws com.rometools.rome.io.FeedException
- Returns:
- the feed we built as serialized XML string
- Throws:
com.rometools.rome.io.FeedException- if feed error
-
output
public void output(Writer writer) throws com.rometools.rome.io.FeedException, IOException
send the output to designated Writer- Parameters:
writer- Writer- Throws:
com.rometools.rome.io.FeedException- if feed errorIOException- if IO error
-
addModule
public void addModule(com.rometools.rome.feed.module.Module m)
Add a ROME plugin module (e.g. for OpenSearch) at the feed level.- Parameters:
m- module
-
getDefaultedConfiguration
protected static String getDefaultedConfiguration(String key, String dfl)
-
urlOfBitstream
protected String urlOfBitstream(javax.servlet.http.HttpServletRequest request, Bitstream logo)
-
resolveURL
protected String resolveURL(javax.servlet.http.HttpServletRequest request, DSpaceObject dso)
Return a url to the DSpace object, either use the official handle for the item or build a url based upon the current server. If the dspaceobject is null then a local url to the repository is generated.- Parameters:
request- current servlet requestdso- The object to reference, null if to the repository.- Returns:
- URL
-
-