Thanks Michael. This worked great. Now I can get the XML from
the AtomContent using:
final AtomFeed feed =
restClient.resource(url).accept(MediaTypeUtils.ATOM_FEED_TYPE).queryParam("uses",
arg).get(AtomFeed.class);
List<AtomEntry> entries = feed.getEntries();
System.out.println("Found " + entries.size() + " versions");
for (AtomEntry atomEntry : entries) {
System.out.println("Title = " + atomEntry.getTitle().getValue());
final byte[] b = atomEntry.getContent().getValue(new
byte[0].getClass());
final String content = new String(b);
System.out.println("Content = '" + content + "'");
}
It seems like I should be able to just use
atomEntry.getContent().getValue() but that causes a NullPointerException:
Exception in thread "main" java.lang.NullPointerException
at
org.apache.wink.common.internal.model.ModelUtils.readValue(ModelUtils.java:258)
at
org.apache.wink.common.internal.model.ModelUtils.readValue(ModelUtils.java:241)
at
org.apache.wink.common.model.atom.AtomContent.getValue(AtomContent.java:366)
at
org.apache.wink.common.model.atom.AtomContent.getValue(AtomContent.java:340)
at
org.apache.wink.common.model.atom.AtomContent.getValue(AtomContent.java:325)
Is that a bug or am I just not calling it right? I stepped through the
code in the debugger in order to figure out I could get the content as a byte[].
craig
From: Michael Elman [mailto:[email protected]]
Sent: Wednesday, October 07, 2009 9:37 AM
To: [email protected]
Subject: Re: How do I turn off XML indentation formatting?
See unit tests of the Preconditions example. There is a
FormattingOptionsContextResolv
er that sets formatting options.
Pay attention that FormattingOptionsContextResolver is a provider, therefore
it should be registered.
Also pay attention that you can implement a FormattingOptions ContextResolver
with any granularity as you wish: the api getContext(Class<?> type) receives
type of the relevant object.
On Wed, Oct 7, 2009 at 4:23 PM, Bryant, Craig W (ARM - HP Software)
<[email protected]<mailto:[email protected]>> wrote:
0.2-incubating
________________________________
From: Michael Elman [mailto:[email protected]<mailto:[email protected]>]
Sent: Wednesday, October 07, 2009 12:01 AM
To: [email protected]<mailto:[email protected]>
Subject: Re: How do I turn off XML indentation formatting?
What version of Wink do you use?
On Wed, Oct 7, 2009 at 1:46 AM, Bryant, Craig W (ARM - HP Software)
<[email protected]<mailto:[email protected]>> wrote:
I changed my client code to retrieve the response as a String and looked at
the result. It looks like turning off indentation formatting for the asset
won't be enough. It looks like I need to turn it off for the entire Response.
How can I do that? Thanks.
craig
________________________________
From: Bryant, Craig W (ARM - HP Software)
Sent: Tuesday, October 06, 2009 5:32 PM
To: [email protected]<mailto:[email protected]>
Subject: How do I turn off XML indentation formatting?
In my asset, I am doing:
String contentString =
ProviderUtils.writeToString(providers, script,
MediaType.APPLICATION_ATOM_XML_TYPE);
Unfortunately, indent formatting is apparently turned on by
default so the contentString starts with spaces and a carriage return before
the XML. This is causing problems on the client side when I attempt to get the
content from an AtomEntry from the AtomFeed. AtomEntry.getContent().getValue()
is only returning the first spaces and carriage return and not the rest of the
XML.
craig