From 367b0394a23451ba78e385d21c223f9df9a77664 Mon Sep 17 00:00:00 2001 From: Juergen Hoeller Date: Wed, 2 Jul 2014 15:04:41 +0200 Subject: [PATCH] Spring's ROME support requires ROME 1.5 (com.rometools.rome) now Issue: SPR-11893 --- build.gradle | 6 ++--- .../AbstractWireFeedHttpMessageConverter.java | 23 +++++++++++------- .../feed/AtomFeedHttpMessageConverter.java | 20 +++++++++------- .../feed/RssChannelHttpMessageConverter.java | 19 ++++++++------- .../http/converter/feed/package-info.java | 17 +------------ .../web/client/RestTemplate.java | 3 +-- .../AtomFeedHttpMessageConverterTests.java | 17 ++++++------- .../RssChannelHttpMessageConverterTests.java | 19 ++++++++------- .../AnnotationDrivenBeanDefinitionParser.java | 2 +- .../WebMvcConfigurationSupport.java | 2 +- .../view/feed/AbstractAtomFeedView.java | 24 +++++++++---------- .../servlet/view/feed/AbstractFeedView.java | 13 ++++++---- .../view/feed/AbstractRssFeedView.java | 22 ++++++++--------- .../web/servlet/view/feed/package-info.java | 4 ++-- .../servlet/view/feed/AtomFeedViewTests.java | 10 ++++---- .../servlet/view/feed/RssFeedViewTests.java | 18 +++++++------- 16 files changed, 110 insertions(+), 109 deletions(-) diff --git a/build.gradle b/build.gradle index f5646bc1da..2dc2ee8641 100644 --- a/build.gradle +++ b/build.gradle @@ -626,7 +626,7 @@ project("spring-web") { optional("org.apache.httpcomponents:httpasyncclient:4.0.1") optional("com.fasterxml.jackson.core:jackson-databind:${jackson2Version}") optional("com.google.code.gson:gson:${gsonVersion}") - optional("rome:rome:1.0") + optional("com.rometools:rome:1.5.0") optional("org.eclipse.jetty:jetty-servlet:${jettyVersion}") { exclude group: "javax.servlet", module: "javax.servlet-api" } @@ -780,7 +780,7 @@ project("spring-webmvc") { exclude group: "xml-apis", module: "xml-apis" } optional("com.fasterxml.jackson.core:jackson-databind:${jackson2Version}") - optional("rome:rome:1.0") + optional("com.rometools:rome:1.5.0") optional("org.apache.tiles:tiles-api:${tiles2Version}") optional("org.apache.tiles:tiles-core:${tiles2Version}") { exclude group: "org.slf4j", module: "jcl-over-slf4j" @@ -918,7 +918,7 @@ project("spring-test") { testCompile("org.hibernate:hibernate-validator:${hibVal5Version}") testCompile("com.thoughtworks.xstream:xstream:${xstreamVersion}") testCompile("com.fasterxml.jackson.core:jackson-databind:${jackson2Version}") - testCompile("rome:rome:1.0") + testCompile("com.rometools:rome:1.5.0") testCompile("org.apache.tiles:tiles-api:${tiles3Version}") testCompile("org.apache.tiles:tiles-core:${tiles3Version}") { exclude group: "org.slf4j", module: "jcl-over-slf4j" diff --git a/spring-web/src/main/java/org/springframework/http/converter/feed/AbstractWireFeedHttpMessageConverter.java b/spring-web/src/main/java/org/springframework/http/converter/feed/AbstractWireFeedHttpMessageConverter.java index afd98288ad..fb42623183 100644 --- a/spring-web/src/main/java/org/springframework/http/converter/feed/AbstractWireFeedHttpMessageConverter.java +++ b/spring-web/src/main/java/org/springframework/http/converter/feed/AbstractWireFeedHttpMessageConverter.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2012 the original author or authors. + * Copyright 2002-2014 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -23,10 +23,10 @@ import java.io.Reader; import java.io.Writer; import java.nio.charset.Charset; -import com.sun.syndication.feed.WireFeed; -import com.sun.syndication.io.FeedException; -import com.sun.syndication.io.WireFeedInput; -import com.sun.syndication.io.WireFeedOutput; +import com.rometools.rome.feed.WireFeed; +import com.rometools.rome.io.FeedException; +import com.rometools.rome.io.WireFeedInput; +import com.rometools.rome.io.WireFeedOutput; import org.springframework.http.HttpInputMessage; import org.springframework.http.HttpOutputMessage; @@ -38,7 +38,10 @@ import org.springframework.util.StringUtils; /** * Abstract base class for Atom and RSS Feed message converters, using the - * ROME tools project. + * ROME tools project. + * + *

>NOTE: As of Spring 4.1, this is based on the {@code com.rometools} + * variant of ROME, version 1.5. Please upgrade your build dependency. * * @author Arjen Poutsma * @since 3.0.2 @@ -49,14 +52,17 @@ public abstract class AbstractWireFeedHttpMessageConverter e public static final Charset DEFAULT_CHARSET = Charset.forName("UTF-8"); + protected AbstractWireFeedHttpMessageConverter(MediaType supportedMediaType) { super(supportedMediaType); } + @Override @SuppressWarnings("unchecked") protected T readInternal(Class clazz, HttpInputMessage inputMessage) throws IOException, HttpMessageNotReadableException { + WireFeedInput feedInput = new WireFeedInput(); MediaType contentType = inputMessage.getHeaders().getContentType(); Charset charset; @@ -77,6 +83,7 @@ public abstract class AbstractWireFeedHttpMessageConverter e @Override protected void writeInternal(T wireFeed, HttpOutputMessage outputMessage) throws IOException, HttpMessageNotWritableException { + String wireFeedEncoding = wireFeed.getEncoding(); if (!StringUtils.hasLength(wireFeedEncoding)) { wireFeedEncoding = DEFAULT_CHARSET.name(); @@ -89,13 +96,13 @@ public abstract class AbstractWireFeedHttpMessageConverter e } WireFeedOutput feedOutput = new WireFeedOutput(); - try { Writer writer = new OutputStreamWriter(outputMessage.getBody(), wireFeedEncoding); feedOutput.output(wireFeed, writer); } catch (FeedException ex) { - throw new HttpMessageNotWritableException("Could not write WiredFeed: " + ex.getMessage(), ex); + throw new HttpMessageNotWritableException("Could not write WireFeed: " + ex.getMessage(), ex); } } + } diff --git a/spring-web/src/main/java/org/springframework/http/converter/feed/AtomFeedHttpMessageConverter.java b/spring-web/src/main/java/org/springframework/http/converter/feed/AtomFeedHttpMessageConverter.java index e8a4e43c7b..f0ae23b4fb 100644 --- a/spring-web/src/main/java/org/springframework/http/converter/feed/AtomFeedHttpMessageConverter.java +++ b/spring-web/src/main/java/org/springframework/http/converter/feed/AtomFeedHttpMessageConverter.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2010 the original author or authors. + * Copyright 2002-2014 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -16,21 +16,24 @@ package org.springframework.http.converter.feed; -import com.sun.syndication.feed.atom.Feed; +import com.rometools.rome.feed.atom.Feed; import org.springframework.http.MediaType; /** - * Implementation of {@link org.springframework.http.converter.HttpMessageConverter} that can read and write Atom feeds. - * Specifically, this converter can handle {@link Feed} objects, from the ROME - * project. + * Implementation of {@link org.springframework.http.converter.HttpMessageConverter} + * that can read and write Atom feeds. Specifically, this converter can handle {@link Feed} + * objects from the ROME project. * - *

By default, this converter reads and writes the media type ({@code application/atom+xml}). This can - * be overridden by setting the {@link #setSupportedMediaTypes(java.util.List) supportedMediaTypes} property. + *

>NOTE: As of Spring 4.1, this is based on the {@code com.rometools} + * variant of ROME, version 1.5. Please upgrade your build dependency. + * + *

By default, this converter reads and writes the media type ({@code application/atom+xml}). + * This can be overridden through the {@link #setSupportedMediaTypes supportedMediaTypes} property. * * @author Arjen Poutsma - * @see Feed * @since 3.0.2 + * @see Feed */ public class AtomFeedHttpMessageConverter extends AbstractWireFeedHttpMessageConverter { @@ -43,5 +46,4 @@ public class AtomFeedHttpMessageConverter extends AbstractWireFeedHttpMessageCon return Feed.class.isAssignableFrom(clazz); } - } diff --git a/spring-web/src/main/java/org/springframework/http/converter/feed/RssChannelHttpMessageConverter.java b/spring-web/src/main/java/org/springframework/http/converter/feed/RssChannelHttpMessageConverter.java index 08091984d9..9e7b897e6a 100644 --- a/spring-web/src/main/java/org/springframework/http/converter/feed/RssChannelHttpMessageConverter.java +++ b/spring-web/src/main/java/org/springframework/http/converter/feed/RssChannelHttpMessageConverter.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2010 the original author or authors. + * Copyright 2002-2014 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -16,21 +16,24 @@ package org.springframework.http.converter.feed; -import com.sun.syndication.feed.rss.Channel; +import com.rometools.rome.feed.rss.Channel; import org.springframework.http.MediaType; /** - * Implementation of {@link org.springframework.http.converter.HttpMessageConverter} that can read and write RSS feeds. - * Specifically, this converter can handle {@link Channel} objects, from the ROME - * project. + * Implementation of {@link org.springframework.http.converter.HttpMessageConverter} + * that can read and write RSS feeds. Specifically, this converter can handle {@link Channel} + * objects from the ROME project. * - *

By default, this converter reads and writes the media type ({@code application/rss+xml}). This can - * be overridden by setting the {@link #setSupportedMediaTypes(java.util.List) supportedMediaTypes} property. + *

>NOTE: As of Spring 4.1, this is based on the {@code com.rometools} + * variant of ROME, version 1.5. Please upgrade your build dependency. + * + *

By default, this converter reads and writes the media type ({@code application/rss+xml}). + * This can be overridden through the {@link #setSupportedMediaTypes supportedMediaTypes} property. * * @author Arjen Poutsma - * @see Channel * @since 3.0.2 + * @see Channel */ public class RssChannelHttpMessageConverter extends AbstractWireFeedHttpMessageConverter { diff --git a/spring-web/src/main/java/org/springframework/http/converter/feed/package-info.java b/spring-web/src/main/java/org/springframework/http/converter/feed/package-info.java index 919e6eaf1e..8a456b8fa0 100644 --- a/spring-web/src/main/java/org/springframework/http/converter/feed/package-info.java +++ b/spring-web/src/main/java/org/springframework/http/converter/feed/package-info.java @@ -1,23 +1,8 @@ -/* - * Copyright 2002-2010 the original author or authors. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ /** * * Provides HttpMessageConverter implementations for handling Atom and RSS feeds. + * Based on the ROME tools project. * */ package org.springframework.http.converter.feed; - diff --git a/spring-web/src/main/java/org/springframework/web/client/RestTemplate.java b/spring-web/src/main/java/org/springframework/web/client/RestTemplate.java index ea75dffc3e..b69b49cef0 100644 --- a/spring-web/src/main/java/org/springframework/web/client/RestTemplate.java +++ b/spring-web/src/main/java/org/springframework/web/client/RestTemplate.java @@ -23,7 +23,6 @@ import java.util.ArrayList; import java.util.List; import java.util.Map; import java.util.Set; - import javax.xml.transform.Source; import org.springframework.core.ParameterizedTypeReference; @@ -129,7 +128,7 @@ import org.springframework.web.util.UriTemplate; public class RestTemplate extends InterceptingHttpAccessor implements RestOperations { private static boolean romePresent = - ClassUtils.isPresent("com.sun.syndication.feed.WireFeed", RestTemplate.class.getClassLoader()); + ClassUtils.isPresent("com.rometools.rome.feed.WireFeed", RestTemplate.class.getClassLoader()); private static final boolean jaxb2Present = ClassUtils.isPresent("javax.xml.bind.Binder", RestTemplate.class.getClassLoader()); diff --git a/spring-web/src/test/java/org/springframework/http/converter/feed/AtomFeedHttpMessageConverterTests.java b/spring-web/src/test/java/org/springframework/http/converter/feed/AtomFeedHttpMessageConverterTests.java index 7f02d069a6..bcaa76b98c 100644 --- a/spring-web/src/test/java/org/springframework/http/converter/feed/AtomFeedHttpMessageConverterTests.java +++ b/spring-web/src/test/java/org/springframework/http/converter/feed/AtomFeedHttpMessageConverterTests.java @@ -22,12 +22,9 @@ import java.nio.charset.Charset; import java.util.ArrayList; import java.util.List; -import com.sun.syndication.feed.atom.Entry; -import com.sun.syndication.feed.atom.Feed; -import static org.custommonkey.xmlunit.XMLAssert.*; +import com.rometools.rome.feed.atom.Entry; +import com.rometools.rome.feed.atom.Feed; import org.custommonkey.xmlunit.XMLUnit; -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertTrue; import org.junit.Before; import org.junit.Test; import org.xml.sax.SAXException; @@ -36,7 +33,13 @@ import org.springframework.http.MediaType; import org.springframework.http.MockHttpInputMessage; import org.springframework.http.MockHttpOutputMessage; -/** @author Arjen Poutsma */ +import static org.custommonkey.xmlunit.XMLAssert.*; +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertTrue; + +/** + * @author Arjen Poutsma + */ public class AtomFeedHttpMessageConverterTests { private AtomFeedHttpMessageConverter converter; @@ -109,7 +112,6 @@ public class AtomFeedHttpMessageConverterTests { "id1title1" + "id2title2"; assertXMLEqual(expected, outputMessage.getBodyAsString(utf8)); - } @Test @@ -126,5 +128,4 @@ public class AtomFeedHttpMessageConverterTests { outputMessage.getHeaders().getContentType()); } - } diff --git a/spring-web/src/test/java/org/springframework/http/converter/feed/RssChannelHttpMessageConverterTests.java b/spring-web/src/test/java/org/springframework/http/converter/feed/RssChannelHttpMessageConverterTests.java index 073bbb88d1..16fcfc00f2 100644 --- a/spring-web/src/test/java/org/springframework/http/converter/feed/RssChannelHttpMessageConverterTests.java +++ b/spring-web/src/test/java/org/springframework/http/converter/feed/RssChannelHttpMessageConverterTests.java @@ -22,12 +22,9 @@ import java.nio.charset.Charset; import java.util.ArrayList; import java.util.List; -import com.sun.syndication.feed.rss.Channel; -import com.sun.syndication.feed.rss.Item; -import static org.custommonkey.xmlunit.XMLAssert.*; +import com.rometools.rome.feed.rss.Channel; +import com.rometools.rome.feed.rss.Item; import org.custommonkey.xmlunit.XMLUnit; -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertTrue; import org.junit.Before; import org.junit.Test; import org.xml.sax.SAXException; @@ -36,7 +33,13 @@ import org.springframework.http.MediaType; import org.springframework.http.MockHttpInputMessage; import org.springframework.http.MockHttpOutputMessage; -/** @author Arjen Poutsma */ +import static org.custommonkey.xmlunit.XMLAssert.*; +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertTrue; + +/** + * @author Arjen Poutsma + */ public class RssChannelHttpMessageConverterTests { private RssChannelHttpMessageConverter converter; @@ -111,7 +114,6 @@ public class RssChannelHttpMessageConverterTests { "title2" + ""; assertXMLEqual(expected, outputMessage.getBodyAsString(utf8)); - } @Test @@ -134,5 +136,4 @@ public class RssChannelHttpMessageConverterTests { outputMessage.getHeaders().getContentType()); } - -} \ No newline at end of file +} diff --git a/spring-webmvc/src/main/java/org/springframework/web/servlet/config/AnnotationDrivenBeanDefinitionParser.java b/spring-webmvc/src/main/java/org/springframework/web/servlet/config/AnnotationDrivenBeanDefinitionParser.java index cec5b1d60c..afdb148516 100644 --- a/spring-webmvc/src/main/java/org/springframework/web/servlet/config/AnnotationDrivenBeanDefinitionParser.java +++ b/spring-webmvc/src/main/java/org/springframework/web/servlet/config/AnnotationDrivenBeanDefinitionParser.java @@ -146,7 +146,7 @@ class AnnotationDrivenBeanDefinitionParser implements BeanDefinitionParser { "javax.validation.Validator", AnnotationDrivenBeanDefinitionParser.class.getClassLoader()); private static boolean romePresent = - ClassUtils.isPresent("com.sun.syndication.feed.WireFeed", AnnotationDrivenBeanDefinitionParser.class.getClassLoader()); + ClassUtils.isPresent("com.rometools.rome.feed.WireFeed", AnnotationDrivenBeanDefinitionParser.class.getClassLoader()); private static final boolean jaxb2Present = ClassUtils.isPresent("javax.xml.bind.Binder", AnnotationDrivenBeanDefinitionParser.class.getClassLoader()); diff --git a/spring-webmvc/src/main/java/org/springframework/web/servlet/config/annotation/WebMvcConfigurationSupport.java b/spring-webmvc/src/main/java/org/springframework/web/servlet/config/annotation/WebMvcConfigurationSupport.java index 99e0785fbe..cd706bcb2f 100644 --- a/spring-webmvc/src/main/java/org/springframework/web/servlet/config/annotation/WebMvcConfigurationSupport.java +++ b/spring-webmvc/src/main/java/org/springframework/web/servlet/config/annotation/WebMvcConfigurationSupport.java @@ -161,7 +161,7 @@ import org.springframework.web.util.UrlPathHelper; public class WebMvcConfigurationSupport implements ApplicationContextAware, ServletContextAware { private static boolean romePresent = - ClassUtils.isPresent("com.sun.syndication.feed.WireFeed", WebMvcConfigurationSupport.class.getClassLoader()); + ClassUtils.isPresent("com.rometools.rome.feed.WireFeed", WebMvcConfigurationSupport.class.getClassLoader()); private static final boolean jaxb2Present = ClassUtils.isPresent("javax.xml.bind.Binder", WebMvcConfigurationSupport.class.getClassLoader()); diff --git a/spring-webmvc/src/main/java/org/springframework/web/servlet/view/feed/AbstractAtomFeedView.java b/spring-webmvc/src/main/java/org/springframework/web/servlet/view/feed/AbstractAtomFeedView.java index 7e48d1b38d..555bb4cd4f 100644 --- a/spring-webmvc/src/main/java/org/springframework/web/servlet/view/feed/AbstractAtomFeedView.java +++ b/spring-webmvc/src/main/java/org/springframework/web/servlet/view/feed/AbstractAtomFeedView.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2008 the original author or authors. + * Copyright 2002-2014 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -21,27 +21,27 @@ import java.util.Map; import javax.servlet.http.HttpServletRequest; import javax.servlet.http.HttpServletResponse; -import com.sun.syndication.feed.WireFeed; -import com.sun.syndication.feed.atom.Entry; -import com.sun.syndication.feed.atom.Feed; +import com.rometools.rome.feed.atom.Entry; +import com.rometools.rome.feed.atom.Feed; /** - * Abstract superclass for Atom Feed views, using java.net's - * ROME package. + * Abstract superclass for Atom Feed views, using the + * ROME package. + * + *

>NOTE: As of Spring 4.1, this is based on the {@code com.rometools} + * variant of ROME, version 1.5. Please upgrade your build dependency. * *

Application-specific view classes will extend this class. * The view will be held in the subclass itself, not in a template. - * - *

Main entry points are the {@link #buildFeedMetadata(Map, WireFeed, HttpServletRequest)} and - * {@link #buildFeedEntries(Map, HttpServletRequest, HttpServletResponse)}. + * Main entry points are the {@link #buildFeedMetadata} and {@link #buildFeedEntries}. * *

Thanks to Jettro Coenradie and Sergio Bossa for the original feed view prototype! * * @author Arjen Poutsma * @author Juergen Hoeller * @since 3.0 - * @see #buildFeedMetadata(Map, WireFeed, HttpServletRequest) - * @see #buildFeedEntries(Map, HttpServletRequest, HttpServletResponse) + * @see #buildFeedMetadata + * @see #buildFeedEntries * @see Atom Syndication Format */ public abstract class AbstractAtomFeedView extends AbstractFeedView { @@ -56,7 +56,7 @@ public abstract class AbstractAtomFeedView extends AbstractFeedView { } /** - * Sets the Rome feed type to use. + * Set the Rome feed type to use. *

Defaults to Atom 1.0. * @see Feed#setFeedType(String) * @see #DEFAULT_FEED_TYPE diff --git a/spring-webmvc/src/main/java/org/springframework/web/servlet/view/feed/AbstractFeedView.java b/spring-webmvc/src/main/java/org/springframework/web/servlet/view/feed/AbstractFeedView.java index 097bf8adf0..a0a3784e47 100644 --- a/spring-webmvc/src/main/java/org/springframework/web/servlet/view/feed/AbstractFeedView.java +++ b/spring-webmvc/src/main/java/org/springframework/web/servlet/view/feed/AbstractFeedView.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2008 the original author or authors. + * Copyright 2002-2014 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -22,15 +22,18 @@ import javax.servlet.ServletOutputStream; import javax.servlet.http.HttpServletRequest; import javax.servlet.http.HttpServletResponse; -import com.sun.syndication.feed.WireFeed; -import com.sun.syndication.io.WireFeedOutput; +import com.rometools.rome.feed.WireFeed; +import com.rometools.rome.io.WireFeedOutput; import org.springframework.util.StringUtils; import org.springframework.web.servlet.view.AbstractView; /** - * Abstract base class for Atom and RSS Feed views, using java.net's - * ROME package. + * Abstract base class for Atom and RSS Feed views, using the + * ROME package. + * + *

>NOTE: As of Spring 4.1, this is based on the {@code com.rometools} + * variant of ROME, version 1.5. Please upgrade your build dependency. * *

Application-specific view classes will typically extend from either * {@link AbstractRssFeedView} or {@link AbstractAtomFeedView} instead of from this class. diff --git a/spring-webmvc/src/main/java/org/springframework/web/servlet/view/feed/AbstractRssFeedView.java b/spring-webmvc/src/main/java/org/springframework/web/servlet/view/feed/AbstractRssFeedView.java index 46d80376db..a390e087b3 100644 --- a/spring-webmvc/src/main/java/org/springframework/web/servlet/view/feed/AbstractRssFeedView.java +++ b/spring-webmvc/src/main/java/org/springframework/web/servlet/view/feed/AbstractRssFeedView.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2009 the original author or authors. + * Copyright 2002-2014 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -21,27 +21,27 @@ import java.util.Map; import javax.servlet.http.HttpServletRequest; import javax.servlet.http.HttpServletResponse; -import com.sun.syndication.feed.WireFeed; -import com.sun.syndication.feed.rss.Channel; -import com.sun.syndication.feed.rss.Item; +import com.rometools.rome.feed.rss.Channel; +import com.rometools.rome.feed.rss.Item; /** - * Abstract superclass for RSS Feed views, using java.net's - * ROME package. + * Abstract superclass for RSS Feed views, using the + * ROME package. + * + *

>NOTE: As of Spring 4.1, this is based on the {@code com.rometools} + * variant of ROME, version 1.5. Please upgrade your build dependency. * *

Application-specific view classes will extend this class. * The view will be held in the subclass itself, not in a template. - * - *

Main entry points are the {@link #buildFeedMetadata(Map, WireFeed , HttpServletRequest)} - * and {@link #buildFeedItems(Map, HttpServletRequest, HttpServletResponse)}. + * Main entry points are the {@link #buildFeedMetadata} and {@link #buildFeedItems}. * *

Thanks to Jettro Coenradie and Sergio Bossa for the original feed view prototype! * * @author Arjen Poutsma * @author Juergen Hoeller * @since 3.0 - * @see #buildFeedMetadata(Map, WireFeed , HttpServletRequest) - * @see #buildFeedItems(Map, HttpServletRequest, HttpServletResponse) + * @see #buildFeedMetadata + * @see #buildFeedItems */ public abstract class AbstractRssFeedView extends AbstractFeedView { diff --git a/spring-webmvc/src/main/java/org/springframework/web/servlet/view/feed/package-info.java b/spring-webmvc/src/main/java/org/springframework/web/servlet/view/feed/package-info.java index 099a6bbe9b..37990dc9b6 100644 --- a/spring-webmvc/src/main/java/org/springframework/web/servlet/view/feed/package-info.java +++ b/spring-webmvc/src/main/java/org/springframework/web/servlet/view/feed/package-info.java @@ -1,8 +1,8 @@ /** * - * Support classes for feed generation, providing View implementations for Atom and RSS + * Support classes for feed generation, providing View implementations for Atom and RSS. + * Based on the ROME tools project. * */ package org.springframework.web.servlet.view.feed; - diff --git a/spring-webmvc/src/test/java/org/springframework/web/servlet/view/feed/AtomFeedViewTests.java b/spring-webmvc/src/test/java/org/springframework/web/servlet/view/feed/AtomFeedViewTests.java index e2236eb281..861e7385e4 100644 --- a/spring-webmvc/src/test/java/org/springframework/web/servlet/view/feed/AtomFeedViewTests.java +++ b/spring-webmvc/src/test/java/org/springframework/web/servlet/view/feed/AtomFeedViewTests.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2013 the original author or authors. + * Copyright 2002-2014 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -24,9 +24,9 @@ import java.util.Map; import javax.servlet.http.HttpServletRequest; import javax.servlet.http.HttpServletResponse; -import com.sun.syndication.feed.atom.Content; -import com.sun.syndication.feed.atom.Entry; -import com.sun.syndication.feed.atom.Feed; +import com.rometools.rome.feed.atom.Content; +import com.rometools.rome.feed.atom.Entry; +import com.rometools.rome.feed.atom.Feed; import org.junit.Before; import org.junit.Test; @@ -67,6 +67,7 @@ public class AtomFeedViewTests { assertXMLEqual(expected, response.getContentAsString()); } + private static class MyAtomFeedView extends AbstractAtomFeedView { @Override @@ -90,4 +91,5 @@ public class AtomFeedViewTests { return entries; } } + } diff --git a/spring-webmvc/src/test/java/org/springframework/web/servlet/view/feed/RssFeedViewTests.java b/spring-webmvc/src/test/java/org/springframework/web/servlet/view/feed/RssFeedViewTests.java index 6569263f0a..728d934069 100644 --- a/spring-webmvc/src/test/java/org/springframework/web/servlet/view/feed/RssFeedViewTests.java +++ b/spring-webmvc/src/test/java/org/springframework/web/servlet/view/feed/RssFeedViewTests.java @@ -1,5 +1,5 @@ /* - * Copyright ${YEAR} the original author or authors. + * Copyright 2002-2014 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -17,16 +17,15 @@ package org.springframework.web.servlet.view.feed; import java.util.ArrayList; -import java.util.Iterator; import java.util.LinkedHashMap; import java.util.List; import java.util.Map; import javax.servlet.http.HttpServletRequest; import javax.servlet.http.HttpServletResponse; -import com.sun.syndication.feed.rss.Channel; -import com.sun.syndication.feed.rss.Description; -import com.sun.syndication.feed.rss.Item; +import com.rometools.rome.feed.rss.Channel; +import com.rometools.rome.feed.rss.Description; +import com.rometools.rome.feed.rss.Item; import org.junit.Before; import org.junit.Test; @@ -48,7 +47,6 @@ public class RssFeedViewTests { public void createView() throws Exception { view = new MyRssFeedView(); setIgnoreWhitespace(true); - } @Test @@ -69,6 +67,7 @@ public class RssFeedViewTests { assertXMLEqual(expected, response.getContentAsString()); } + private static class MyRssFeedView extends AbstractRssFeedView { @Override @@ -79,11 +78,9 @@ public class RssFeedViewTests { } @Override - protected List buildFeedItems(Map model, HttpServletRequest request, HttpServletResponse response) - throws Exception { + protected List buildFeedItems(Map model, HttpServletRequest request, HttpServletResponse response) throws Exception { List items = new ArrayList(); - for (Iterator iterator = model.keySet().iterator(); iterator.hasNext();) { - String name = (String) iterator.next(); + for (String name : model.keySet()) { Item item = new Item(); item.setTitle(name); Description description = new Description(); @@ -94,4 +91,5 @@ public class RssFeedViewTests { return items; } } + }