abdera-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Adam Constabaris <a...@clownsinmycoffee.net>
Subject Re: problems setting entry content
Date Sat, 31 Mar 2007 14:41:24 GMT
Garrett Rooney wrote:
> On 3/31/07, Adam Constabaris <adam@clownsinmycoffee.net> wrote:
>> Brian Moseley wrote:
>> >
>> > setting content as Content with type
>> > ==========================
>> >
>> > Content content = factory.newContent();
>> > content.setValue("foo");
>> > content.setMimeType("application/eim+xml");
>> > entry.setContent(content, "application/eim+xml");
>> >
>> > after doing this, entry.getContent() returns null, and when i ouput
>> > the entry document, the content element is empty (but once again has
>> > the correct type).
>> >
>> > any ideas?
>>
>> 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.
>
> Hmm, if that's the case that seems, well, bad to me.  Perhaps we
> should define some specific exception type to throw in that sort of
> case...
>
> -garrett
Just thinking out loud here:

"org.apache.abdera.model.InvalidContentException"?

It's a bit of a sticky wicket because of the range of things that can be 
content; on a first pass, the issue of baseline well-formedness only 
seems to crop up for XHTML and XML types (base64?), but if you stick a 
checked exception on the setContent() method and all of its 
permutations, you're forcing everybody to deal with it, even if they're 
dealing in HTML or plain text.   I suppose it could come up even for 
plain text if you didn't want to allow people to post inappropriate 
content etc. into your system, and you thought the parser throwing an 
exception was a good place to deal with it -- but that seems like a 
pretty bad idea =)

I appear to have been corrupted by the idea of using a hierarchy of 
unchecked exceptions for cases like this, however (cf. JPA operations).  
The basic idea is that you don't really know whether an exception of 
this type is going to be an issue for any given user, so why force 
everybody to deal with it?  The hierarchy allows you to get specific 
about the cause.  I realize that's not a universally held belief, and 
I'm not even sure how strongly I hold it, but there it is =)

AC

Mime
View raw message