You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@wink.apache.org by el...@apache.org on 2009/08/25 19:29:38 UTC
svn commit: r807724 - in /incubator/wink/trunk:
wink-common/src/main/java/org/apache/wink/common/internal/i18n/
wink-common/src/main/java/org/apache/wink/common/utils/
wink-examples/apps/QADefect/src/main/java/org/apache/wink/example/qadefect/resources...
Author: elman
Date: Tue Aug 25 17:29:37 2009
New Revision: 807724
URL: http://svn.apache.org/viewvc?rev=807724&view=rev
Log:
Fixing ProviderUtils - as already discussed the IOException should propagate to container.
Removed:
incubator/wink/trunk/wink-common/src/main/java/org/apache/wink/common/internal/i18n/MessagesConstants.java
Modified:
incubator/wink/trunk/wink-common/src/main/java/org/apache/wink/common/internal/i18n/MessageBundle.java
incubator/wink/trunk/wink-common/src/main/java/org/apache/wink/common/internal/i18n/Messages.java
incubator/wink/trunk/wink-common/src/main/java/org/apache/wink/common/utils/ProviderUtils.java
incubator/wink/trunk/wink-examples/apps/QADefect/src/main/java/org/apache/wink/example/qadefect/resources/DefectAsset.java
incubator/wink/trunk/wink-examples/apps/QADefect/src/main/java/org/apache/wink/example/qadefect/resources/DefectsAsset.java
incubator/wink/trunk/wink-examples/apps/QADefect/src/main/java/org/apache/wink/example/qadefect/resources/TestAsset.java
incubator/wink/trunk/wink-examples/apps/QADefect/src/main/java/org/apache/wink/example/qadefect/resources/TestsAsset.java
incubator/wink/trunk/wink-examples/apps/SimpleDefects/src/main/java/org/apache/wink/example/simpledefects/resources/DefectAsset.java
incubator/wink/trunk/wink-examples/apps/SimpleDefects/src/main/java/org/apache/wink/example/simpledefects/resources/DefectsAsset.java
incubator/wink/trunk/wink-examples/ext/History/src/main/java/org/apache/wink/example/history/resources/DefectAsset.java
incubator/wink/trunk/wink-examples/ext/History/src/main/java/org/apache/wink/example/history/resources/DefectsAsset.java
incubator/wink/trunk/wink-examples/ext/WebDAV/src/main/java/org/apache/wink/example/webdav/WebDAVDefectsResource.java
Modified: incubator/wink/trunk/wink-common/src/main/java/org/apache/wink/common/internal/i18n/MessageBundle.java
URL: http://svn.apache.org/viewvc/incubator/wink/trunk/wink-common/src/main/java/org/apache/wink/common/internal/i18n/MessageBundle.java?rev=807724&r1=807723&r2=807724&view=diff
==============================================================================
--- incubator/wink/trunk/wink-common/src/main/java/org/apache/wink/common/internal/i18n/MessageBundle.java (original)
+++ incubator/wink/trunk/wink-common/src/main/java/org/apache/wink/common/internal/i18n/MessageBundle.java Tue Aug 25 17:29:37 2009
@@ -22,47 +22,20 @@
import java.util.MissingResourceException;
import java.util.ResourceBundle;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
/**
- * Accept parameters for ProjectResourceBundle, but defer object instantiation
- * (and therefore resource bundle loading) until required.
+ * Loads and holds a ResourceBundle according to the specified parameters.
*/
public class MessageBundle {
- private static final Logger logger = LoggerFactory.getLogger(MessageBundle.class);
-
- private boolean loaded = false;
-
- private ResourceBundle _resourceBundle = null;
-
- private final String packageName;
- private final String resourceName;
- private final Locale locale;
- private final ClassLoader classLoader;
- public final ResourceBundle getResourceBundle() {
- if (!loaded) {
- try {
- _resourceBundle =
- ResourceBundle.getBundle(packageName + "." + resourceName, locale, classLoader);
- } catch (MissingResourceException e) {
- logger.debug("loadBundle: Ignoring MissingResourceException: " + e.getMessage(), e);
- }
- loaded = true;
- }
- return _resourceBundle;
- }
+ private final ResourceBundle resourceBundle;
+ private final String className;
- /** Construct a new ExtendMessages */
public MessageBundle(String packageName,
String resourceName,
Locale locale,
ClassLoader classLoader) throws MissingResourceException {
- this.packageName = packageName;
- this.resourceName = resourceName;
- this.locale = locale;
- this.classLoader = classLoader;
+ className = packageName + '.' + resourceName;
+ resourceBundle = ResourceBundle.getBundle(className, locale, classLoader);
}
/**
@@ -72,20 +45,13 @@
* @return The message
*/
public String getMessage(String key) throws MissingResourceException {
- String msg = null;
- if (getResourceBundle() != null) {
- msg = getResourceBundle().getString(key);
- }
+ String msg = resourceBundle.getString(key);
if (msg == null) {
- String className = packageName + '.' + resourceName;
throw new MissingResourceException("Cannot find resource key \"" + key
+ "\" in base name "
- + packageName
- + '.'
- + resourceName, className, key);
+ + className, className, key);
}
-
return msg;
}
}
Modified: incubator/wink/trunk/wink-common/src/main/java/org/apache/wink/common/internal/i18n/Messages.java
URL: http://svn.apache.org/viewvc/incubator/wink/trunk/wink-common/src/main/java/org/apache/wink/common/internal/i18n/Messages.java?rev=807724&r1=807723&r2=807724&view=diff
==============================================================================
--- incubator/wink/trunk/wink-common/src/main/java/org/apache/wink/common/internal/i18n/Messages.java (original)
+++ incubator/wink/trunk/wink-common/src/main/java/org/apache/wink/common/internal/i18n/Messages.java Tue Aug 25 17:29:37 2009
@@ -18,48 +18,18 @@
*/
package org.apache.wink.common.internal.i18n;
-import java.util.HashMap;
import java.util.Locale;
-import java.util.Map;
import java.util.MissingResourceException;
public class Messages {
- private static final Class<?> thisClass = Messages.class;
- private static final String resourceName =
- MessagesConstants.resourceName;
- private static final Locale locale = MessagesConstants.locale;
-
- public static final String DEFAULT_MESSAGE_BUNDLE_KEY = "default";
- private static final String NO_MESSAGE_BUNDLE =
- "Message Bundle is not available";
-
- private static final String packageName =
- getPackage(thisClass
- .getName());
- private static final ClassLoader classLoader =
- thisClass
- .getClassLoader();
-
- private static Map<String, MessageBundle> messageBundleMap =
- new HashMap<String, MessageBundle>();
+ private static final String resourceName = "resource";
+ private static final MessageBundle messageBundle;
static {
- MessageBundle defaultMessageBundle =
- new MessageBundle(packageName, resourceName, locale, classLoader);
- addMessageBundle(DEFAULT_MESSAGE_BUNDLE_KEY, defaultMessageBundle);
- }
-
- /**
- * To add a new Message Bundle to the MessageBundle list. Must be called
- * before runtime starts.
- *
- * @param messageBundleKey The key which will be used to refer to this
- * message bundle later.
- * @param messageBundle The message bundle.
- */
- public static void addMessageBundle(String messageBundleKey, MessageBundle messageBundle) {
- messageBundleMap.put(messageBundleKey, messageBundle);
+ messageBundle =
+ new MessageBundle(Messages.class.getPackage().getName(), resourceName, Locale
+ .getDefault(), Messages.class.getClassLoader());
}
/**
@@ -70,33 +40,7 @@
* @return The formatted message
*/
public static String getMessage(String key) throws MissingResourceException {
- MessageBundle messageBundle = getMessageBundle(DEFAULT_MESSAGE_BUNDLE_KEY);
- return messageBundle.getMessage(key);
- }
-
- public static MessageBundle getMessageBundle(String messageBundleKey) {
- MessageBundle messageBundle = (MessageBundle)messageBundleMap.get(messageBundleKey);
- return messageBundle;
- }
-
- /**
- * Get a message from resource.properties from the package of the given
- * object.
- *
- * @param messageBundleKey The key for getting the correct message bundle.
- * @param key The resource key
- * @return The formatted message
- */
- public static String getMessageFromBundle(String messageBundleKey, String key)
- throws MissingResourceException, Exception {
- MessageBundle messageBundle = getMessageBundle(messageBundleKey);
- if (messageBundle == null)
- throw new Exception(NO_MESSAGE_BUNDLE);
-
return messageBundle.getMessage(key);
}
- private static String getPackage(String name) {
- return name.substring(0, name.lastIndexOf('.')).intern();
- }
}
Modified: incubator/wink/trunk/wink-common/src/main/java/org/apache/wink/common/utils/ProviderUtils.java
URL: http://svn.apache.org/viewvc/incubator/wink/trunk/wink-common/src/main/java/org/apache/wink/common/utils/ProviderUtils.java?rev=807724&r1=807723&r2=807724&view=diff
==============================================================================
--- incubator/wink/trunk/wink-common/src/main/java/org/apache/wink/common/utils/ProviderUtils.java (original)
+++ incubator/wink/trunk/wink-common/src/main/java/org/apache/wink/common/utils/ProviderUtils.java Tue Aug 25 17:29:37 2009
@@ -33,7 +33,6 @@
import java.lang.reflect.Type;
import java.nio.charset.Charset;
-import javax.ws.rs.WebApplicationException;
import javax.ws.rs.core.MediaType;
import javax.ws.rs.core.MultivaluedMap;
import javax.ws.rs.ext.MessageBodyReader;
@@ -89,14 +88,15 @@
}
}
- public static String writeToString(Providers providers, Object object, MediaType mediaType) {
+ public static String writeToString(Providers providers, Object object, MediaType mediaType)
+ throws IOException {
return writeToString(providers, object, object.getClass(), mediaType);
}
public static String writeToString(Providers providers,
Object object,
Class<?> type,
- MediaType mediaType) {
+ MediaType mediaType) throws IOException {
return writeToString(providers, object, type, type, mediaType);
}
@@ -104,7 +104,7 @@
Object object,
Class<?> type,
Type genericType,
- MediaType mediaType) {
+ MediaType mediaType) throws IOException {
return writeToString(providers,
object,
type,
@@ -119,29 +119,22 @@
Class<?> type,
Type genericType,
MultivaluedMap<String, Object> httpHeaders,
- MediaType mediaType) {
- try {
- ByteArrayOutputStream os = new ByteArrayOutputStream();
- MessageBodyWriter writer =
- providers.getMessageBodyWriter(type, genericType, null, mediaType);
- if (writer == null) {
- return null;
- }
- writer
- .writeTo(object, type, genericType, new Annotation[0], mediaType, httpHeaders, os);
- String contentString = os.toString(getCharset(mediaType));
- return contentString;
- } catch (WebApplicationException e) {
- throw e;
- } catch (IOException e) {
- throw new WebApplicationException(e);
+ MediaType mediaType) throws IOException {
+ ByteArrayOutputStream os = new ByteArrayOutputStream();
+ MessageBodyWriter writer =
+ providers.getMessageBodyWriter(type, genericType, null, mediaType);
+ if (writer == null) {
+ return null;
}
+ writer.writeTo(object, type, genericType, new Annotation[0], mediaType, httpHeaders, os);
+ String contentString = os.toString(getCharset(mediaType));
+ return contentString;
}
public static <T> T readFromString(Providers providers,
String input,
Class<T> type,
- MediaType mediaType) {
+ MediaType mediaType) throws IOException {
return readFromString(providers, input, type, type, mediaType);
}
@@ -149,7 +142,7 @@
String input,
Class<T> type,
Type genericType,
- MediaType mediaType) {
+ MediaType mediaType) throws IOException {
return readFromString(providers,
input,
type,
@@ -163,21 +156,13 @@
Class<T> type,
Type genericType,
MultivaluedMap<String, String> httpHeaders,
- MediaType mediaType) {
- try {
- ByteArrayInputStream is =
- new ByteArrayInputStream(input.getBytes(getCharset(mediaType)));
- MessageBodyReader<T> reader =
- providers.getMessageBodyReader(type, genericType, null, mediaType);
- if (reader == null) {
- return null;
- }
- return reader
- .readFrom(type, genericType, new Annotation[0], mediaType, httpHeaders, is);
- } catch (WebApplicationException e) {
- throw e;
- } catch (IOException e) {
- throw new WebApplicationException(e);
+ MediaType mediaType) throws IOException {
+ ByteArrayInputStream is = new ByteArrayInputStream(input.getBytes(getCharset(mediaType)));
+ MessageBodyReader<T> reader =
+ providers.getMessageBodyReader(type, genericType, null, mediaType);
+ if (reader == null) {
+ return null;
}
+ return reader.readFrom(type, genericType, new Annotation[0], mediaType, httpHeaders, is);
}
}
Modified: incubator/wink/trunk/wink-examples/apps/QADefect/src/main/java/org/apache/wink/example/qadefect/resources/DefectAsset.java
URL: http://svn.apache.org/viewvc/incubator/wink/trunk/wink-examples/apps/QADefect/src/main/java/org/apache/wink/example/qadefect/resources/DefectAsset.java?rev=807724&r1=807723&r2=807724&view=diff
==============================================================================
--- incubator/wink/trunk/wink-examples/apps/QADefect/src/main/java/org/apache/wink/example/qadefect/resources/DefectAsset.java (original)
+++ incubator/wink/trunk/wink-examples/apps/QADefect/src/main/java/org/apache/wink/example/qadefect/resources/DefectAsset.java Tue Aug 25 17:29:37 2009
@@ -20,6 +20,7 @@
package org.apache.wink.example.qadefect.resources;
+import java.io.IOException;
import java.util.Date;
import javax.ws.rs.Consumes;
@@ -81,7 +82,7 @@
@Produces( {MediaType.WILDCARD, MediaType.APPLICATION_JSON})
public SyndEntry getSyndEntry(@Context Providers providers,
@Context UriInfo uriInfo,
- @Context LinkBuilders linkProcessor) {
+ @Context LinkBuilders linkProcessor) throws IOException {
SyndEntry entry = new SyndEntry();
entry.setId("urn:com:hp:qadefects:defect:" + defect.getId());
entry.setTitle(new SyndText(defect.getName()));
@@ -133,7 +134,7 @@
}
@Consumes
- public void setSyndEntry(SyndEntry entry, @Context Providers providers) {
+ public void setSyndEntry(SyndEntry entry, @Context Providers providers) throws IOException {
defect = null;
SyndContent content = entry.getContent();
if (content == null) {
Modified: incubator/wink/trunk/wink-examples/apps/QADefect/src/main/java/org/apache/wink/example/qadefect/resources/DefectsAsset.java
URL: http://svn.apache.org/viewvc/incubator/wink/trunk/wink-examples/apps/QADefect/src/main/java/org/apache/wink/example/qadefect/resources/DefectsAsset.java?rev=807724&r1=807723&r2=807724&view=diff
==============================================================================
--- incubator/wink/trunk/wink-examples/apps/QADefect/src/main/java/org/apache/wink/example/qadefect/resources/DefectsAsset.java (original)
+++ incubator/wink/trunk/wink-examples/apps/QADefect/src/main/java/org/apache/wink/example/qadefect/resources/DefectsAsset.java Tue Aug 25 17:29:37 2009
@@ -20,6 +20,7 @@
package org.apache.wink.example.qadefect.resources;
+import java.io.IOException;
import java.util.Collection;
import java.util.Date;
import java.util.LinkedList;
@@ -74,7 +75,7 @@
@Produces
public SyndFeed getSyndFeed(@Context Providers providers,
@Context LinkBuilders linkProcessor,
- @Context UriInfo uriInfo) {
+ @Context UriInfo uriInfo) throws IOException {
SyndFeed synd = new SyndFeed();
synd.setId("urn:com:hp:qadefects:defects");
synd.setTitle(new SyndText("Defects"));
Modified: incubator/wink/trunk/wink-examples/apps/QADefect/src/main/java/org/apache/wink/example/qadefect/resources/TestAsset.java
URL: http://svn.apache.org/viewvc/incubator/wink/trunk/wink-examples/apps/QADefect/src/main/java/org/apache/wink/example/qadefect/resources/TestAsset.java?rev=807724&r1=807723&r2=807724&view=diff
==============================================================================
--- incubator/wink/trunk/wink-examples/apps/QADefect/src/main/java/org/apache/wink/example/qadefect/resources/TestAsset.java (original)
+++ incubator/wink/trunk/wink-examples/apps/QADefect/src/main/java/org/apache/wink/example/qadefect/resources/TestAsset.java Tue Aug 25 17:29:37 2009
@@ -20,6 +20,7 @@
package org.apache.wink.example.qadefect.resources;
+import java.io.IOException;
import java.util.Date;
import javax.ws.rs.Consumes;
@@ -81,7 +82,7 @@
@Produces( {MediaType.WILDCARD, MediaType.APPLICATION_JSON})
public SyndEntry getSyndEntry(@Context Providers providers,
@Context UriInfo uriInfo,
- @Context LinkBuilders linkProcessor) {
+ @Context LinkBuilders linkProcessor) throws IOException {
SyndEntry entry = new SyndEntry();
entry.setId("urn:com:hp:qadefects:test:" + test.getId());
entry.setTitle(new SyndText(test.getName()));
@@ -106,7 +107,7 @@
}
@Consumes
- public void setSyndEntry(SyndEntry entry, @Context Providers providers) {
+ public void setSyndEntry(SyndEntry entry, @Context Providers providers) throws IOException {
test = null;
SyndContent content = entry.getContent();
if (content == null) {
Modified: incubator/wink/trunk/wink-examples/apps/QADefect/src/main/java/org/apache/wink/example/qadefect/resources/TestsAsset.java
URL: http://svn.apache.org/viewvc/incubator/wink/trunk/wink-examples/apps/QADefect/src/main/java/org/apache/wink/example/qadefect/resources/TestsAsset.java?rev=807724&r1=807723&r2=807724&view=diff
==============================================================================
--- incubator/wink/trunk/wink-examples/apps/QADefect/src/main/java/org/apache/wink/example/qadefect/resources/TestsAsset.java (original)
+++ incubator/wink/trunk/wink-examples/apps/QADefect/src/main/java/org/apache/wink/example/qadefect/resources/TestsAsset.java Tue Aug 25 17:29:37 2009
@@ -20,6 +20,7 @@
package org.apache.wink.example.qadefect.resources;
+import java.io.IOException;
import java.util.Collection;
import java.util.Date;
import java.util.LinkedList;
@@ -72,7 +73,7 @@
@Produces
public SyndFeed getSyndFeed(@Context Providers providers,
@Context LinkBuilders linkProcessor,
- @Context UriInfo uriInfo) {
+ @Context UriInfo uriInfo) throws IOException {
SyndFeed synd = new SyndFeed();
synd.setId("urn:com:hp:qadefects:tests");
synd.setTitle(new SyndText("Tests"));
Modified: incubator/wink/trunk/wink-examples/apps/SimpleDefects/src/main/java/org/apache/wink/example/simpledefects/resources/DefectAsset.java
URL: http://svn.apache.org/viewvc/incubator/wink/trunk/wink-examples/apps/SimpleDefects/src/main/java/org/apache/wink/example/simpledefects/resources/DefectAsset.java?rev=807724&r1=807723&r2=807724&view=diff
==============================================================================
--- incubator/wink/trunk/wink-examples/apps/SimpleDefects/src/main/java/org/apache/wink/example/simpledefects/resources/DefectAsset.java (original)
+++ incubator/wink/trunk/wink-examples/apps/SimpleDefects/src/main/java/org/apache/wink/example/simpledefects/resources/DefectAsset.java Tue Aug 25 17:29:37 2009
@@ -20,6 +20,7 @@
package org.apache.wink.example.simpledefects.resources;
+import java.io.IOException;
import java.util.Date;
import javax.ws.rs.Consumes;
@@ -69,7 +70,7 @@
@Produces( {MediaType.WILDCARD, MediaType.APPLICATION_JSON})
public SyndEntry getSyndEntry(@Context Providers providers,
@Context UriInfo uriInfo,
- @Context LinkBuilders linkBuilders) {
+ @Context LinkBuilders linkBuilders) throws IOException {
SyndEntry entry = new SyndEntry();
entry.setId("urn:com:hp:qadefects:defect:" + defect.getId());
entry.setTitle(new SyndText(defect.getName()));
@@ -104,7 +105,7 @@
}
@Consumes
- public void setSyndEntry(SyndEntry entry, @Context Providers providers) {
+ public void setSyndEntry(SyndEntry entry, @Context Providers providers) throws IOException {
defect = null;
SyndContent content = entry.getContent();
if (content == null) {
Modified: incubator/wink/trunk/wink-examples/apps/SimpleDefects/src/main/java/org/apache/wink/example/simpledefects/resources/DefectsAsset.java
URL: http://svn.apache.org/viewvc/incubator/wink/trunk/wink-examples/apps/SimpleDefects/src/main/java/org/apache/wink/example/simpledefects/resources/DefectsAsset.java?rev=807724&r1=807723&r2=807724&view=diff
==============================================================================
--- incubator/wink/trunk/wink-examples/apps/SimpleDefects/src/main/java/org/apache/wink/example/simpledefects/resources/DefectsAsset.java (original)
+++ incubator/wink/trunk/wink-examples/apps/SimpleDefects/src/main/java/org/apache/wink/example/simpledefects/resources/DefectsAsset.java Tue Aug 25 17:29:37 2009
@@ -20,6 +20,7 @@
package org.apache.wink.example.simpledefects.resources;
+import java.io.IOException;
import java.util.Collection;
import java.util.Date;
import java.util.LinkedList;
@@ -72,7 +73,7 @@
@Produces
public SyndFeed getSyndFeed(@Context Providers providers,
@Context LinkBuilders linkBuilders,
- @Context UriInfo uriInfo) {
+ @Context UriInfo uriInfo) throws IOException {
SyndFeed synd = new SyndFeed();
synd.setId("urn:com:hp:qadefects:defects");
synd.setTitle(new SyndText("Defects"));
Modified: incubator/wink/trunk/wink-examples/ext/History/src/main/java/org/apache/wink/example/history/resources/DefectAsset.java
URL: http://svn.apache.org/viewvc/incubator/wink/trunk/wink-examples/ext/History/src/main/java/org/apache/wink/example/history/resources/DefectAsset.java?rev=807724&r1=807723&r2=807724&view=diff
==============================================================================
--- incubator/wink/trunk/wink-examples/ext/History/src/main/java/org/apache/wink/example/history/resources/DefectAsset.java (original)
+++ incubator/wink/trunk/wink-examples/ext/History/src/main/java/org/apache/wink/example/history/resources/DefectAsset.java Tue Aug 25 17:29:37 2009
@@ -20,6 +20,7 @@
package org.apache.wink.example.history.resources;
+import java.io.IOException;
import java.util.Date;
import javax.ws.rs.Consumes;
@@ -88,11 +89,13 @@
/**
* Called for producing the entity of a response that supports SyndEntry is
* made (such as application/atom+xml or application/json)
+ *
+ * @throws IOException
*/
@Produces( {MediaType.WILDCARD, MediaType.APPLICATION_JSON})
public SyndEntry getSyndEntry(@Context Providers providers,
@Context UriInfo uriInfo,
- @Context LinkBuilders linkBuilders) {
+ @Context LinkBuilders linkBuilders) throws IOException {
SyndEntry entry = new SyndEntry();
String id = defect.getId();
entry.setId("urn:com:hp:qadefects:defect:" + id);
@@ -158,9 +161,11 @@
/**
* Called for consuming the entity of a request that supports SyndEntry is
* made (such as application/atom+xml)
+ *
+ * @throws IOException
*/
@Consumes
- public void setSyndEntry(SyndEntry entry, @Context Providers providers) {
+ public void setSyndEntry(SyndEntry entry, @Context Providers providers) throws IOException {
defect = null;
SyndContent content = entry.getContent();
if (content == null) {
Modified: incubator/wink/trunk/wink-examples/ext/History/src/main/java/org/apache/wink/example/history/resources/DefectsAsset.java
URL: http://svn.apache.org/viewvc/incubator/wink/trunk/wink-examples/ext/History/src/main/java/org/apache/wink/example/history/resources/DefectsAsset.java?rev=807724&r1=807723&r2=807724&view=diff
==============================================================================
--- incubator/wink/trunk/wink-examples/ext/History/src/main/java/org/apache/wink/example/history/resources/DefectsAsset.java (original)
+++ incubator/wink/trunk/wink-examples/ext/History/src/main/java/org/apache/wink/example/history/resources/DefectsAsset.java Tue Aug 25 17:29:37 2009
@@ -20,6 +20,7 @@
package org.apache.wink.example.history.resources;
+import java.io.IOException;
import java.util.Collection;
import java.util.Date;
import java.util.LinkedList;
@@ -79,11 +80,12 @@
/**
* Called for producing the entity of a response that supports SyndFeed is
* made (such as application/atom+xml or application/json)
+ * @throws IOException
*/
@Produces
public SyndFeed getSyndFeed(@Context Providers providers,
@Context LinkBuilders linkBuilders,
- @Context UriInfo uriInfo) {
+ @Context UriInfo uriInfo) throws IOException {
SyndFeed feed = new SyndFeed();
feed.setId("urn:com:hp:qadefects:defects");
feed.setTitle(new SyndText("Defects"));
Modified: incubator/wink/trunk/wink-examples/ext/WebDAV/src/main/java/org/apache/wink/example/webdav/WebDAVDefectsResource.java
URL: http://svn.apache.org/viewvc/incubator/wink/trunk/wink-examples/ext/WebDAV/src/main/java/org/apache/wink/example/webdav/WebDAVDefectsResource.java?rev=807724&r1=807723&r2=807724&view=diff
==============================================================================
--- incubator/wink/trunk/wink-examples/ext/WebDAV/src/main/java/org/apache/wink/example/webdav/WebDAVDefectsResource.java (original)
+++ incubator/wink/trunk/wink-examples/ext/WebDAV/src/main/java/org/apache/wink/example/webdav/WebDAVDefectsResource.java Tue Aug 25 17:29:37 2009
@@ -204,13 +204,17 @@
// if the property being set is getcontentlength
if (property instanceof Getcontentlength) {
// serialize the synd to atom to get its length as atom
- String body =
- ProviderUtils.writeToString(providers,
- synd,
- MediaType.APPLICATION_ATOM_XML_TYPE);
- ((Getcontentlength)property).setValue(String.valueOf(body.length()));
- response.setPropertyOk(property);
- return;
+ try {
+ String body =
+ ProviderUtils.writeToString(providers,
+ synd,
+ MediaType.APPLICATION_ATOM_XML_TYPE);
+ ((Getcontentlength)property).setValue(String.valueOf(body.length()));
+ response.setPropertyOk(property);
+ return;
+ } catch (IOException e) {
+ throw new WebApplicationException(e);
+ }
}
// delegate to the parent for all other properties
super.setPropertyValue(builder, response, property, synd);