Spring's ROME support requires ROME 1.5 (com.rometools.rome) now

Issue: SPR-11893
This commit is contained in:
Juergen Hoeller
2014-07-02 15:04:41 +02:00
parent 32b87079cb
commit 367b0394a2
16 changed files with 110 additions and 109 deletions

View File

@@ -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
* <a href="http://rometools.org/">ROME tools</a> project.
* <a href="https://github.com/rometools/rome">ROME tools</a> project.
*
* <p>><b>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.</b>
*
* @author Arjen Poutsma
* @since 3.0.2
@@ -49,14 +52,17 @@ public abstract class AbstractWireFeedHttpMessageConverter<T extends WireFeed> e
public static final Charset DEFAULT_CHARSET = Charset.forName("UTF-8");
protected AbstractWireFeedHttpMessageConverter(MediaType supportedMediaType) {
super(supportedMediaType);
}
@Override
@SuppressWarnings("unchecked")
protected T readInternal(Class<? extends T> 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<T extends WireFeed> 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<T extends WireFeed> 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);
}
}
}

View File

@@ -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 <a href="https://rome.dev.java.net/">ROME</a>
* 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 <a href="https://github.com/rometools/rome">ROME</a> project.
*
* <p>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.
* <p>><b>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.</b>
*
* <p>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<Feed> {
@@ -43,5 +46,4 @@ public class AtomFeedHttpMessageConverter extends AbstractWireFeedHttpMessageCon
return Feed.class.isAssignableFrom(clazz);
}
}

View File

@@ -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 <a href="https://rome.dev.java.net/">ROME</a>
* 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 <a href="https://github.com/rometools/rome">ROME</a> project.
*
* <p>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.
* <p>><b>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.</b>
*
* <p>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<Channel> {

View File

@@ -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 <a href="https://github.com/rometools/rome">ROME tools</a> project.
*
*/
package org.springframework.http.converter.feed;

View File

@@ -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());