abdera-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From James M Snell <jasn...@gmail.com>
Subject Re: problems setting entry content
Date Mon, 02 Apr 2007 16:35:06 GMT
The method variation..

  public Content setContent(
    Element element,
    String mediaType)
      throws MimeTypeParseException {

Set's the passed in element as the child of the atom:content element.

Well... that's what it's supposed to be doing.  Of course, looking at
the code right now I just spotted a bug.  I'm fixing it now...

    Abdera abdera = new Abdera();
    Entry entry = abdera.newEntry();

    Document<Element> foodoc =
        new ByteArrayInputStream(
    Element foo = foodoc.getRoot();

    entry.setContent(foo, "application/foo+xml");


Should produce something like:

  <entry xmlns="http://www.w3.org/2005/Atom">
    <content type="application/foo+xml">
      <a xmlns=""><b><c></c></b></a>

- James

Garrett Rooney wrote:
> On 3/31/07, Brian Moseley <bcm@osafoundation.org> wrote:
>> On 3/31/07, Adam Constabaris <adam@clownsinmycoffee.net> wrote:
>> > If you are going to use an XML content type, then the content has to be
>> > a well-formed fragment; so change that to
>> > entry.setContent("<foo>foo</foo>", "application/eim+xml") and you
>> should
>> > see results.  What's happening is that your content is passed
>> through an
>> > XML parser when you call setContent, and the code in 0.2.2 and trunk
>> > silently swallows (most? all?) parsing exceptions.
>> ah, it wasn't immediately clear that my string was being parsed as
>> xml. my string actually is an xml document, which i believe is well
>> formed, so i'm not sure what specifically could be going wrong with
>> the parsing. i guess i'll need to step through with a debugger to see.
>> here's something interesting: i'm now trying to set a json string
>> value with the media type "application/eim+json", and it's also
>> failing in exactly the same way.
>> i finally found something that works. instead of calling
>> setContent(Content, String), i'm calling setContent(String, String).
>> this has exactly the effect i want. i guess my original problem was in
>> misusing the abdera Content class.
> Hmm.  So I guess that means you were calling:
> Content setContent(Element element, String mediaType) throws
> MimeTypeParseException;
> Right?  Perhaps the docs on that could be improved to better describe
> its intended use case, so people don't stumble down that path again?
> Or, if it should have worked (I'm not really sure, James?) there may
> just be a bug there.
> -garrett

View raw message