You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@abdera.apache.org by Ugo Cei <ug...@gmail.com> on 2006/08/08 15:25:41 UTC
Hi,
looking at the setContent* methods on the Entry interface, I cannot
figure out exactly which one should I use to output a <content>
element with an src attribute. IOW, I cannot find a method to easily
create out of line content.
TIA,
Ugo
--
Ugo Cei
Blog: http://agylen.com/
Open Source Zone: http://oszone.org/
Evil or Not?: http://evilornot.info/
Company: http://www.sourcesense.com/
Re:
Posted by Elias Torres <el...@torrez.us>.
Ugo,
This is how you would add a content with src.
Content content = Factory.INSTANCE.newContent(
new MimeType(jEntryContentType), entry);
content.setSrc("url");
entry.setContentElement(content);
Initially abdera had a every possible combination of shorthand API calls
to do this, but we decided to trim down and start with a small number
and only add the most used. Maybe this would be one of them, but hey at
least now you know how to do it.
-Elias
Garrett Rooney wrote:
> On 8/8/06, Ugo Cei <ug...@gmail.com> wrote:
>> Hi,
>>
>> looking at the setContent* methods on the Entry interface, I cannot
>> figure out exactly which one should I use to output a <content>
>> element with an src attribute. IOW, I cannot find a method to easily
>> create out of line content.
>
> Hmm, I don't see an obvious way to do it, but it sure seems like there
> should be one. Feel like putting together a patch that adds a
> setContentSrc(String) or maybe setContent(URI) version? It seems like
> it should be pretty straitforward to implement.
>
> -garrett
>
Re:
Posted by Ugo Cei <ug...@gmail.com>.
On Aug 8, 2006, at 7:15 PM, Garrett Rooney wrote:
> I wonder what's different between running the tests via maven and
> running them via ant. Is maven pulling down some new dependencies or
> something?
>
> They all seem to pass here...
Well, they don't pass here, even when using ant:
$ ant -f build/build.xml test
....
[echo] Running Stax Parser Tests...
[java] .........................................
[java] .........................................
[java] .........................................
[java] .........................................
[java] .........................................
[java] .........................................
[java] .........................F.F...F...
[java] Time: 66.456
[java] There were 3 failures:
The failing testcases seem to be the same as with Maven. By the way,
this is:
$ java -version
java version "1.5.0_06"
Java(TM) 2 Runtime Environment, Standard Edition (build 1.5.0_06-112)
Java HotSpot(TM) Client VM (build 1.5.0_06-64, mixed mode, sharing)
on OS X 10.4.7.
I'll see later if I can find out what is causing this.
Ugo
Re: Failing tests (was Re: )
Posted by Garrett Rooney <ro...@electricjellyfish.net>.
On 8/8/06, Garrett Rooney <ro...@electricjellyfish.net> wrote:
> Ahh, recent change, I was looking at an older working copy.
>
> I'd say that a more correct change would be to return a copy of the
> options, instead of a reference to the default one, but that's just
> me. It seems like modifying the ParserOptions you get from
> getDefaultParserOptions shouldn't change the defaults for everyone
> else.
Also, the fact that FOMParser includes a lazily initialized variable
like that is kind of disconcerting from a thread safety manner,
considering that it's likely to be accessed via Parser.INSTANCE...
-garrett
Re: Failing tests (was Re: )
Posted by Garrett Rooney <ro...@electricjellyfish.net>.
On 8/8/06, Ugo Cei <ug...@gmail.com> wrote:
>
> On Aug 8, 2006, at 8:04 PM, Garrett Rooney wrote:
>
> > I'd say that a more correct change would be to return a copy of the
> > options, instead of a reference to the default one, but that's just
> > me. It seems like modifying the ParserOptions you get from
> > getDefaultParserOptions shouldn't change the defaults for everyone
> > else.
>
> In this case, better leave the test as is and not apply my patch,
> since it's effect would be to hide what is effectively a bug.
>
> Besides, I forgot to remove some System.out.print statements before
> doing the diff.
For those not watching the commits list, these failing tests should be
fixed now.
-garrett
Re: Failing tests (was Re: )
Posted by Ugo Cei <ug...@gmail.com>.
On Aug 8, 2006, at 8:04 PM, Garrett Rooney wrote:
> I'd say that a more correct change would be to return a copy of the
> options, instead of a reference to the default one, but that's just
> me. It seems like modifying the ParserOptions you get from
> getDefaultParserOptions shouldn't change the defaults for everyone
> else.
In this case, better leave the test as is and not apply my patch,
since it's effect would be to hide what is effectively a bug.
Besides, I forgot to remove some System.out.print statements before
doing the diff.
Ugo
--
Ugo Cei
Blog: http://agylen.com/
Open Source Zone: http://oszone.org/
Evil or Not?: http://evilornot.info/
Company: http://www.sourcesense.com/
Re: Failing tests (was Re: )
Posted by Garrett Rooney <ro...@electricjellyfish.net>.
On 8/8/06, Ugo Cei <ug...@gmail.com> wrote:
>
> On Aug 8, 2006, at 7:53 PM, Garrett Rooney wrote:
>
> > Sounds promising, but...
> >
> > @Override
> > public ParserOptions getDefaultParserOptions() {
> > return new FOMParserOptions();
> > }
> >
> > That's from FOMParser.java, and FOMParserOptions doesn't seem to have
> > anything odd in it.
>
> Huh? My copy (rev. 429578) has:
>
> @Override
> public ParserOptions getDefaultParserOptions() {
> if (options == null)
> options = new FOMParserOptions();
> return options;
> }
>
> And this is indeed the problem, since I've modified the tests (patch
> attached) to make sure options are reset after every test (should
> probably use tearDown, though) and the tests now succeeed.
Ahh, recent change, I was looking at an older working copy.
I'd say that a more correct change would be to return a copy of the
options, instead of a reference to the default one, but that's just
me. It seems like modifying the ParserOptions you get from
getDefaultParserOptions shouldn't change the defaults for everyone
else.
-garrett
Re: Failing tests (was Re: )
Posted by James M Snell <ja...@gmail.com>.
Right, I made this change to make it possible to reuse the default
parser options. Calling Parser.setDefaultParserOptions(null) on each
test should effectively reset the internals.
- James
Ugo Cei wrote:
>
> On Aug 8, 2006, at 7:53 PM, Garrett Rooney wrote:
>
>> Sounds promising, but...
>>
>> @Override
>> public ParserOptions getDefaultParserOptions() {
>> return new FOMParserOptions();
>> }
>>
>> That's from FOMParser.java, and FOMParserOptions doesn't seem to have
>> anything odd in it.
>
> Huh? My copy (rev. 429578) has:
>
> @Override
> public ParserOptions getDefaultParserOptions() {
> if (options == null)
> options = new FOMParserOptions();
> return options;
> }
>
> And this is indeed the problem, since I've modified the tests (patch
> attached) to make sure options are reset after every test (should
> probably use tearDown, though) and the tests now succeeed.
>
> Ugo
>
>
> ------------------------------------------------------------------------
>
> Index: java/trunk/parser/src/test/java/org/apache/abdera/test/parser/stax/FOMTest.java
> ===================================================================
> --- java/trunk/parser/src/test/java/org/apache/abdera/test/parser/stax/FOMTest.java (revision 429743)
> +++ java/trunk/parser/src/test/java/org/apache/abdera/test/parser/stax/FOMTest.java (working copy)
> @@ -148,30 +148,35 @@
> filter.add(Constants.TITLE);
> filter.add(Constants.ID);
> ParserOptions options = Parser.INSTANCE.getDefaultParserOptions();
> - options.setParseFilter(filter);
> + try {
> + options.setParseFilter(filter);
> +
> + URL url = FOMTest.class.getResource("/simple.xml");
> + InputStream in = url.openStream();
>
> - URL url = FOMTest.class.getResource("/simple.xml");
> - InputStream in = url.openStream();
> -
> - Document<Feed> doc = Parser.INSTANCE.parse(in, url.toURI(), options);
> - Feed feed = doc.getRoot();
> + Document<Feed> doc = Parser.INSTANCE.parse(in, url.toURI(), options);
> + Feed feed = doc.getRoot();
> +
> + assertEquals(feed.getTitle(),"Example Feed");
> + assertEquals(feed.getTitleType(), Text.Type.TEXT);
> + assertNull(feed.getAlternateLink());
> + assertNull(feed.getUpdated());
> + assertNull(feed.getAuthor());
> + assertEquals(feed.getId().toString(), "urn:uuid:60a76c80-d399-11d9-b93C-0003939e0af6");
> +
> + Entry entry = feed.getEntries().get(0);
>
> - assertEquals(feed.getTitle(),"Example Feed");
> - assertEquals(feed.getTitleType(), Text.Type.TEXT);
> - assertNull(feed.getAlternateLink());
> - assertNull(feed.getUpdated());
> - assertNull(feed.getAuthor());
> - assertEquals(feed.getId().toString(), "urn:uuid:60a76c80-d399-11d9-b93C-0003939e0af6");
> -
> - Entry entry = feed.getEntries().get(0);
> -
> - assertEquals(entry.getTitle(),"Atom-Powered Robots Run Amok");
> - assertEquals(entry.getTitleType(), Text.Type.TEXT);
> - assertNull(entry.getAlternateLink());
> - assertEquals(entry.getId().toString(),"urn:uuid:1225c695-cfb8-4ebb-aaaa-80da344efa6a");
> - assertNull(entry.getUpdated());
> - assertNull(entry.getSummary());
> - assertNull(entry.getSummaryType());
> + assertEquals(entry.getTitle(),"Atom-Powered Robots Run Amok");
> + assertEquals(entry.getTitleType(), Text.Type.TEXT);
> + assertNull(entry.getAlternateLink());
> + assertEquals(entry.getId().toString(),"urn:uuid:1225c695-cfb8-4ebb-aaaa-80da344efa6a");
> + assertNull(entry.getUpdated());
> + assertNull(entry.getSummary());
> + assertNull(entry.getSummaryType());
> + }
> + finally {
> + options.setParseFilter(null);
> + }
> }
>
> public void testBlackListParseFilter() throws Exception {
> @@ -179,31 +184,35 @@
> ParseFilter filter = new BlackListParseFilter();
> filter.add(Constants.UPDATED);
> ParserOptions options = Parser.INSTANCE.getDefaultParserOptions();
> - options.setParseFilter(filter);
> + try {
> + options.setParseFilter(filter);
> +
> + URL url = FOMTest.class.getResource("/simple.xml");
> + InputStream in = url.openStream();
>
> - URL url = FOMTest.class.getResource("/simple.xml");
> - InputStream in = url.openStream();
> -
> - Document<Feed> doc = Parser.INSTANCE.parse(in, url.toURI(), options);
> - Feed feed = doc.getRoot();
> + Document<Feed> doc = Parser.INSTANCE.parse(in, url.toURI(), options);
> + Feed feed = doc.getRoot();
> +
> + assertEquals(feed.getTitle(),"Example Feed");
> + assertEquals(feed.getTitleType(), Text.Type.TEXT);
> + assertEquals(feed.getAlternateLink().getResolvedHref().toString(), "http://example.org/");
> + assertNull(feed.getUpdated());
> + assertEquals(feed.getAuthor().getName(), "John Doe");
> + assertEquals(feed.getId().toString(), "urn:uuid:60a76c80-d399-11d9-b93C-0003939e0af6");
> +
> + Entry entry = feed.getEntries().get(0);
>
> - assertEquals(feed.getTitle(),"Example Feed");
> - assertEquals(feed.getTitleType(), Text.Type.TEXT);
> - assertEquals(feed.getAlternateLink().getResolvedHref().toString(), "http://example.org/");
> - assertNull(feed.getUpdated());
> - assertEquals(feed.getAuthor().getName(), "John Doe");
> - assertEquals(feed.getId().toString(), "urn:uuid:60a76c80-d399-11d9-b93C-0003939e0af6");
> -
> - Entry entry = feed.getEntries().get(0);
> -
> - assertEquals(entry.getTitle(),"Atom-Powered Robots Run Amok");
> - assertEquals(entry.getTitleType(), Text.Type.TEXT);
> - assertEquals(entry.getAlternateLink().getResolvedHref().toString(), "http://example.org/2003/12/13/atom03");
> - assertEquals(entry.getId().toString(),"urn:uuid:1225c695-cfb8-4ebb-aaaa-80da344efa6a");
> - assertNull(entry.getUpdated());
> - assertEquals(entry.getSummary(), "Some text.");
> - assertEquals(entry.getSummaryType(), Text.Type.TEXT);
> -
> + assertEquals(entry.getTitle(),"Atom-Powered Robots Run Amok");
> + assertEquals(entry.getTitleType(), Text.Type.TEXT);
> + assertEquals(entry.getAlternateLink().getResolvedHref().toString(), "http://example.org/2003/12/13/atom03");
> + assertEquals(entry.getId().toString(),"urn:uuid:1225c695-cfb8-4ebb-aaaa-80da344efa6a");
> + assertNull(entry.getUpdated());
> + assertEquals(entry.getSummary(), "Some text.");
> + assertEquals(entry.getSummaryType(), Text.Type.TEXT);
> + }
> + finally {
> + options.setParseFilter(null);
> + }
> }
>
> public void testTextFilter() throws Exception {
> @@ -223,30 +232,39 @@
> };
>
> ParserOptions options = Parser.INSTANCE.getDefaultParserOptions();
> - options.setTextFilter(filter);
> + try {
> + options.setTextFilter(filter);
> +
> + URL url = FOMTest.class.getResource("/simple.xml");
> + InputStream in = url.openStream();
> + Document<Feed> doc = Parser.INSTANCE.parse(in, url.toURI(), options);
> + Feed feed = doc.getRoot();
> +
> + assertEquals(feed.getTitle(),"Example Feed");
> + assertEquals(feed.getTitleType(), Text.Type.TEXT);
> + assertEquals(feed.getAlternateLink().getResolvedHref().toString(), "http://example.org/");
> +
> + feed.writeTo(System.out);
> + System.out.println("Updated string: " + feed.getUpdatedString());
> + System.out.println("Updated: " + feed.getUpdated());
> +
> + assertNotNull(feed.getUpdated());
> + assertEquals(feed.getAuthor().getName(), "Jane Doe");
> + assertEquals(feed.getId().toString(), "urn:uuid:60a76c80-d399-11d9-b93C-0003939e0af6");
> +
> + Entry entry = feed.getEntries().get(0);
>
> - URL url = FOMTest.class.getResource("/simple.xml");
> - InputStream in = url.openStream();
> - Document<Feed> doc = Parser.INSTANCE.parse(in, url.toURI(), options);
> - Feed feed = doc.getRoot();
> -
> - assertEquals(feed.getTitle(),"Example Feed");
> - assertEquals(feed.getTitleType(), Text.Type.TEXT);
> - assertEquals(feed.getAlternateLink().getResolvedHref().toString(), "http://example.org/");
> - assertNotNull(feed.getUpdated());
> - assertEquals(feed.getAuthor().getName(), "Jane Doe");
> - assertEquals(feed.getId().toString(), "urn:uuid:60a76c80-d399-11d9-b93C-0003939e0af6");
> -
> - Entry entry = feed.getEntries().get(0);
> -
> - assertEquals(entry.getTitle(),"Atom-Powered Robots Run Crazy");
> - assertEquals(entry.getTitleType(), Text.Type.TEXT);
> - assertEquals(entry.getAlternateLink().getResolvedHref().toString(), "http://example.org/2003/12/13/atom03");
> - assertEquals(entry.getId().toString(),"urn:uuid:1225c695-cfb8-4ebb-aaaa-80da344efa6a");
> - assertNotNull(entry.getUpdated());
> - assertEquals(entry.getSummary(), "Some text.");
> - assertEquals(entry.getSummaryType(), Text.Type.TEXT);
> -
> + assertEquals(entry.getTitle(),"Atom-Powered Robots Run Crazy");
> + assertEquals(entry.getTitleType(), Text.Type.TEXT);
> + assertEquals(entry.getAlternateLink().getResolvedHref().toString(), "http://example.org/2003/12/13/atom03");
> + assertEquals(entry.getId().toString(),"urn:uuid:1225c695-cfb8-4ebb-aaaa-80da344efa6a");
> + assertNotNull(entry.getUpdated());
> + assertEquals(entry.getSummary(), "Some text.");
> + assertEquals(entry.getSummaryType(), Text.Type.TEXT);
> + }
> + finally {
> + options.setTextFilter(null);
> + }
> }
>
> public void testXPath() throws Exception {
>
>
> ------------------------------------------------------------------------
>
>
Re: Failing tests (was Re: )
Posted by Ugo Cei <ug...@gmail.com>.
On Aug 8, 2006, at 7:53 PM, Garrett Rooney wrote:
> Sounds promising, but...
>
> @Override
> public ParserOptions getDefaultParserOptions() {
> return new FOMParserOptions();
> }
>
> That's from FOMParser.java, and FOMParserOptions doesn't seem to have
> anything odd in it.
Huh? My copy (rev. 429578) has:
@Override
public ParserOptions getDefaultParserOptions() {
if (options == null)
options = new FOMParserOptions();
return options;
}
And this is indeed the problem, since I've modified the tests (patch
attached) to make sure options are reset after every test (should
probably use tearDown, though) and the tests now succeeed.
Ugo
Re: Failing tests (was Re: )
Posted by Garrett Rooney <ro...@electricjellyfish.net>.
On 8/8/06, Ugo Cei <ug...@gmail.com> wrote:
> More info about the failing tests. The following test methods fail:
>
> FOMTest#testTextFilter
> FOMTest#testXPath
> FOMTest#testRoundTrip
>
> Now, hold yourself tight, but if I run each of those tests *alone* in
> Eclipse, they succeed!
>
> This tells me there is some interaction between tests. What stands
> out is this, apparently:
>
>
> ParserOptions options = Parser.INSTANCE.getDefaultParserOptions();
> options.setTextFilter(filter);
>
> If the object returned by getDefaultParserOptions is a singleton,
> it's possible that one of the tests sets a filter and a subsequent
> tests fails because it expects the options to be empty. Just a
> suggestion.
Sounds promising, but...
@Override
public ParserOptions getDefaultParserOptions() {
return new FOMParserOptions();
}
That's from FOMParser.java, and FOMParserOptions doesn't seem to have
anything odd in it.
-garrett
Re: Failing tests (was Re: )
Posted by James M Snell <ja...@gmail.com>.
Ah! This is the change I made yesterday for persistently setting the
default parser options! doh! Mea culpa.
- James
Ugo Cei wrote:
> More info about the failing tests. The following test methods fail:
>
> FOMTest#testTextFilter
> FOMTest#testXPath
> FOMTest#testRoundTrip
>
> Now, hold yourself tight, but if I run each of those tests *alone* in
> Eclipse, they succeed!
>
> This tells me there is some interaction between tests. What stands out
> is this, apparently:
>
>
> ParserOptions options = Parser.INSTANCE.getDefaultParserOptions();
> options.setTextFilter(filter);
>
> If the object returned by getDefaultParserOptions is a singleton, it's
> possible that one of the tests sets a filter and a subsequent tests
> fails because it expects the options to be empty. Just a suggestion.
>
> Ugo
>
>
> --Ugo Cei
> Blog: http://agylen.com/
> Open Source Zone: http://oszone.org/
> Evil or Not?: http://evilornot.info/
> Company: http://www.sourcesense.com/
>
>
>
Failing tests (was Re: )
Posted by Ugo Cei <ug...@gmail.com>.
More info about the failing tests. The following test methods fail:
FOMTest#testTextFilter
FOMTest#testXPath
FOMTest#testRoundTrip
Now, hold yourself tight, but if I run each of those tests *alone* in
Eclipse, they succeed!
This tells me there is some interaction between tests. What stands
out is this, apparently:
ParserOptions options = Parser.INSTANCE.getDefaultParserOptions();
options.setTextFilter(filter);
If the object returned by getDefaultParserOptions is a singleton,
it's possible that one of the tests sets a filter and a subsequent
tests fails because it expects the options to be empty. Just a
suggestion.
Ugo
--
Ugo Cei
Blog: http://agylen.com/
Open Source Zone: http://oszone.org/
Evil or Not?: http://evilornot.info/
Company: http://www.sourcesense.com/
Re:
Posted by James M Snell <ja...@gmail.com>.
Cool, thx!
Ugo Cei wrote:
>
> On Aug 8, 2006, at 7:26 PM, James M Snell wrote:
>> well, I'm seeing some wierdness also. Running the tests via ant,
>> everything works. Running the tests from Eclipse, I'm seeing some
>> failures, but the failures don't make any sense at all. I'm willing to
>> trust the Ant build for now, but eventually we may need to explore
>> what's going on.
>
> Well, at least I'm getting consistent results: the same tests fail
> whether using Ant, Maven or Eclipse. I'm going to investigate this ASAP.
>
> Ugo
>
>
>
> --Ugo Cei
> Blog: http://agylen.com/
> Open Source Zone: http://oszone.org/
> Evil or Not?: http://evilornot.info/
> Company: http://www.sourcesense.com/
>
>
>
Re:
Posted by Ugo Cei <ug...@gmail.com>.
On Aug 8, 2006, at 7:26 PM, James M Snell wrote:
> well, I'm seeing some wierdness also. Running the tests via ant,
> everything works. Running the tests from Eclipse, I'm seeing some
> failures, but the failures don't make any sense at all. I'm
> willing to
> trust the Ant build for now, but eventually we may need to explore
> what's going on.
Well, at least I'm getting consistent results: the same tests fail
whether using Ant, Maven or Eclipse. I'm going to investigate this ASAP.
Ugo
--
Ugo Cei
Blog: http://agylen.com/
Open Source Zone: http://oszone.org/
Evil or Not?: http://evilornot.info/
Company: http://www.sourcesense.com/
Re:
Posted by James M Snell <ja...@gmail.com>.
Garrett Rooney wrote:
>[snip]
>> - I didn't know where to put some tests for this, as there doesn't
>> seem to be other tests already for the various setContent* methods,
>> so I simply added some code to the examples to see if everything
>> looked alright.
>
> Looks like a section of the code that could use some new tests...
>
must.... resist....
>> - There are some tests which fail (running mvn test) but they were
>> failing even before my changes:
>>
>> [surefire] Running org.apache.abdera.test.parser.stax.FOMTest
>> [surefire] Tests run: 11, Failures: 3, Errors: 0, Time elapsed: 0.511
>> sec <<<<<<<< FAILURE !!
>
> Interesting.
>
> I wonder what's different between running the tests via maven and
> running them via ant. Is maven pulling down some new dependencies or
> something?
>
> They all seem to pass here...
>
well, I'm seeing some wierdness also. Running the tests via ant,
everything works. Running the tests from Eclipse, I'm seeing some
failures, but the failures don't make any sense at all. I'm willing to
trust the Ant build for now, but eventually we may need to explore
what's going on.
- James
Re:
Posted by James M Snell <ja...@gmail.com>.
Patched! Thank's Ugo
Ugo Cei wrote:
>
> On Aug 8, 2006, at 7:23 PM, Garrett Rooney wrote:
>
>> Does it perhaps have a filename that looks ungood to one of the mail
>> servers in the way? Perhaps changing it to .txt?
>
> Let's try.
>
>
> ------------------------------------------------------------------------
>
> Index: java/trunk/core/src/main/java/org/apache/abdera/model/Entry.java
> ===================================================================
> --- java/trunk/core/src/main/java/org/apache/abdera/model/Entry.java (revision 429733)
> +++ java/trunk/core/src/main/java/org/apache/abdera/model/Entry.java (working copy)
> @@ -214,6 +214,17 @@
> Content setContent(String value, String mediatype) throws MimeTypeParseException;
>
> /**
> + * Sets the content for this entry as out of line.
> + *
> + * @param uri URI of the content (value of the "src" attribute).
> + * @param mediatype Type of the content.
> + * @return The new content element.
> + * @throws MimeTypeParseException if the mime type is invalid.
> + * @throws URISyntaxException if the URI is invalid.
> + */
> + Content setContent(URI uri, String mediatype) throws MimeTypeParseException, URISyntaxException;
> +
> + /**
> * Returns the text of the content element
> */
> String getContent();
> Index: java/trunk/parser/src/main/java/org/apache/abdera/parser/stax/FOMEntry.java
> ===================================================================
> --- java/trunk/parser/src/main/java/org/apache/abdera/parser/stax/FOMEntry.java (revision 429733)
> +++ java/trunk/parser/src/main/java/org/apache/abdera/parser/stax/FOMEntry.java (working copy)
> @@ -259,6 +259,19 @@
> setContentElement(content);
> return content;
> }
> +
> + /**
> + * Sets the content for this entry
> + * @throws MimeTypeParseException
> + * @throws URISyntaxException
> + */
> + public Content setContent(URI uri, String mediatype) throws MimeTypeParseException, URISyntaxException {
> + FOMFactory factory = (FOMFactory) this.factory;
> + Content content = factory.newContent(new MimeType(mediatype));
> + content.setSrc(uri.toString());
> + setContentElement(content);
> + return content;
> + }
>
>
> public List<Person> getContributors() {
> Index: java/trunk/examples/src/main/java/org/apache/abdera/examples/simple/Create.java
> ===================================================================
> --- java/trunk/examples/src/main/java/org/apache/abdera/examples/simple/Create.java (revision 429733)
> +++ java/trunk/examples/src/main/java/org/apache/abdera/examples/simple/Create.java (working copy)
> @@ -17,6 +17,7 @@
> */
> package org.apache.abdera.examples.simple;
>
> +import java.net.URI;
> import java.util.Date;
>
> import org.apache.abdera.factory.Factory;
> @@ -63,6 +64,14 @@
> entry3.setSummaryAsHtml("<p><a href=\"foo\">Test</a></p>").setBaseUri("http://example.org/site/");
> entry3.setSource(feed.getAsSource());
>
> + // Out-of-line content
> + Entry entry4 = feed.addEntry();
> + entry4.setTitle("re: Atom-Powered Robots Run Amok");
> + entry4.addLink("/2003/12/13/atom03/3");
> + entry4.setId("urn:uuid:1225c695-cfb8-4ebb-aaaa-cafebabecafe");
> + entry4.setUpdated(new Date());
> + entry4.setSummary("An entry with out-of-line content");
> + entry4.setContent(new URI("http://example.org/0xcafebabe"), "text/html");
> feed.getDocument().writeTo(System.out);
> }
>
>
>
> ------------------------------------------------------------------------
>
>
> Ugo
Re:
Posted by James M Snell <ja...@gmail.com>.
Got it.
Ugo Cei wrote:
>
> On Aug 8, 2006, at 7:23 PM, Garrett Rooney wrote:
>
>> Does it perhaps have a filename that looks ungood to one of the mail
>> servers in the way? Perhaps changing it to .txt?
>
> Let's try.
>
>
> ------------------------------------------------------------------------
>
> Index: java/trunk/core/src/main/java/org/apache/abdera/model/Entry.java
> ===================================================================
> --- java/trunk/core/src/main/java/org/apache/abdera/model/Entry.java (revision 429733)
> +++ java/trunk/core/src/main/java/org/apache/abdera/model/Entry.java (working copy)
> @@ -214,6 +214,17 @@
> Content setContent(String value, String mediatype) throws MimeTypeParseException;
>
> /**
> + * Sets the content for this entry as out of line.
> + *
> + * @param uri URI of the content (value of the "src" attribute).
> + * @param mediatype Type of the content.
> + * @return The new content element.
> + * @throws MimeTypeParseException if the mime type is invalid.
> + * @throws URISyntaxException if the URI is invalid.
> + */
> + Content setContent(URI uri, String mediatype) throws MimeTypeParseException, URISyntaxException;
> +
> + /**
> * Returns the text of the content element
> */
> String getContent();
> Index: java/trunk/parser/src/main/java/org/apache/abdera/parser/stax/FOMEntry.java
> ===================================================================
> --- java/trunk/parser/src/main/java/org/apache/abdera/parser/stax/FOMEntry.java (revision 429733)
> +++ java/trunk/parser/src/main/java/org/apache/abdera/parser/stax/FOMEntry.java (working copy)
> @@ -259,6 +259,19 @@
> setContentElement(content);
> return content;
> }
> +
> + /**
> + * Sets the content for this entry
> + * @throws MimeTypeParseException
> + * @throws URISyntaxException
> + */
> + public Content setContent(URI uri, String mediatype) throws MimeTypeParseException, URISyntaxException {
> + FOMFactory factory = (FOMFactory) this.factory;
> + Content content = factory.newContent(new MimeType(mediatype));
> + content.setSrc(uri.toString());
> + setContentElement(content);
> + return content;
> + }
>
>
> public List<Person> getContributors() {
> Index: java/trunk/examples/src/main/java/org/apache/abdera/examples/simple/Create.java
> ===================================================================
> --- java/trunk/examples/src/main/java/org/apache/abdera/examples/simple/Create.java (revision 429733)
> +++ java/trunk/examples/src/main/java/org/apache/abdera/examples/simple/Create.java (working copy)
> @@ -17,6 +17,7 @@
> */
> package org.apache.abdera.examples.simple;
>
> +import java.net.URI;
> import java.util.Date;
>
> import org.apache.abdera.factory.Factory;
> @@ -63,6 +64,14 @@
> entry3.setSummaryAsHtml("<p><a href=\"foo\">Test</a></p>").setBaseUri("http://example.org/site/");
> entry3.setSource(feed.getAsSource());
>
> + // Out-of-line content
> + Entry entry4 = feed.addEntry();
> + entry4.setTitle("re: Atom-Powered Robots Run Amok");
> + entry4.addLink("/2003/12/13/atom03/3");
> + entry4.setId("urn:uuid:1225c695-cfb8-4ebb-aaaa-cafebabecafe");
> + entry4.setUpdated(new Date());
> + entry4.setSummary("An entry with out-of-line content");
> + entry4.setContent(new URI("http://example.org/0xcafebabe"), "text/html");
> feed.getDocument().writeTo(System.out);
> }
>
>
>
> ------------------------------------------------------------------------
>
>
> Ugo
Re:
Posted by Ugo Cei <ug...@gmail.com>.
On Aug 8, 2006, at 7:23 PM, Garrett Rooney wrote:
> Does it perhaps have a filename that looks ungood to one of the mail
> servers in the way? Perhaps changing it to .txt?
Let's try.
Re:
Posted by Garrett Rooney <ro...@electricjellyfish.net>.
On 8/8/06, Ugo Cei <ug...@gmail.com> wrote:
>
> On Aug 8, 2006, at 7:15 PM, Garrett Rooney wrote:
>
> > On 8/8/06, Ugo Cei <ug...@gmail.com> wrote:
> >
> >> OK, here's your patch. A couple of things to note:
> >
> > Your patch seems to have been stripped someplace along the line...
>
> I'm trying to send it again.
Nope :(
Does it perhaps have a filename that looks ungood to one of the mail
servers in the way? Perhaps changing it to .txt?
-garrett
Re:
Posted by James M Snell <ja...@gmail.com>.
Strange. Thunderbird is telling me that there is an attachment, but no
attachment is to be found anywhere. Try attaching it with a different
extension (txt, for instance).
- James
Ugo Cei wrote:
>
> On Aug 8, 2006, at 7:15 PM, Garrett Rooney wrote:
>
>> On 8/8/06, Ugo Cei <ug...@gmail.com> wrote:
>>
>>> OK, here's your patch. A couple of things to note:
>>
>> Your patch seems to have been stripped someplace along the line...
>
> I'm trying to send it again.
>
Re:
Posted by Ugo Cei <ug...@gmail.com>.
On Aug 8, 2006, at 7:15 PM, Garrett Rooney wrote:
> On 8/8/06, Ugo Cei <ug...@gmail.com> wrote:
>
>> OK, here's your patch. A couple of things to note:
>
> Your patch seems to have been stripped someplace along the line...
I'm trying to send it again.
Re:
Posted by Garrett Rooney <ro...@electricjellyfish.net>.
On 8/8/06, Ugo Cei <ug...@gmail.com> wrote:
> OK, here's your patch. A couple of things to note:
Your patch seems to have been stripped someplace along the line...
> - I didn't know where to put some tests for this, as there doesn't
> seem to be other tests already for the various setContent* methods,
> so I simply added some code to the examples to see if everything
> looked alright.
Looks like a section of the code that could use some new tests...
> - There are some tests which fail (running mvn test) but they were
> failing even before my changes:
>
> [surefire] Running org.apache.abdera.test.parser.stax.FOMTest
> [surefire] Tests run: 11, Failures: 3, Errors: 0, Time elapsed: 0.511
> sec <<<<<<<< FAILURE !!
Interesting.
I wonder what's different between running the tests via maven and
running them via ant. Is maven pulling down some new dependencies or
something?
They all seem to pass here...
-garrett
Re:
Posted by Ugo Cei <ug...@gmail.com>.
On Aug 8, 2006, at 6:27 PM, James M Snell wrote:
> Ugo Cei wrote:
>> Thanks. I will implement this ASAP, unless someone
>> else beats me to it.
>
> Will.... restrain.... myself.... must.... not.... open.... eclipse....
OK, here's your patch. A couple of things to note:
- I didn't know where to put some tests for this, as there doesn't
seem to be other tests already for the various setContent* methods,
so I simply added some code to the examples to see if everything
looked alright.
- There are some tests which fail (running mvn test) but they were
failing even before my changes:
[surefire] Running org.apache.abdera.test.parser.stax.FOMTest
[surefire] Tests run: 11, Failures: 3, Errors: 0, Time elapsed: 0.511
sec <<<<<<<< FAILURE !!
Ugo
Re:
Posted by James M Snell <ja...@gmail.com>.
Ugo Cei wrote:
> Thanks. I will implement this ASAP, unless someone
> else beats me to it.
Will.... restrain.... myself.... must.... not.... open.... eclipse....
;-)
Re:
Posted by Ugo Cei <ug...@gmail.com>.
On Aug 8, 2006, at 5:48 PM, James M Snell wrote:
> Keep in mind that the mime type is required on out of line content, so
> it should be setContent(URI uri, String mediatype) It should be very
> simple to do. As a hint to get you started, look at the Entry and
> FOMEntry classes. Specifically, look at the implementation of the
> existing setContent(String value, String mediatype) method as a
> template. Implementing the new method should require only changing
> one
> line of code from that method.
Thanks. I will implement this ASAP, unless someone else beats me to it.
Ugo
--
Ugo Cei
Blog: http://agylen.com/
Open Source Zone: http://oszone.org/
Evil or Not?: http://evilornot.info/
Company: http://www.sourcesense.com/
Re:
Posted by James M Snell <ja...@gmail.com>.
Keep in mind that the mime type is required on out of line content, so
it should be setContent(URI uri, String mediatype) It should be very
simple to do. As a hint to get you started, look at the Entry and
FOMEntry classes. Specifically, look at the implementation of the
existing setContent(String value, String mediatype) method as a
template. Implementing the new method should require only changing one
line of code from that method.
- James
Garrett Rooney wrote:
> On 8/8/06, Ugo Cei <ug...@gmail.com> wrote:
>> Hi,
>>
>> looking at the setContent* methods on the Entry interface, I cannot
>> figure out exactly which one should I use to output a <content>
>> element with an src attribute. IOW, I cannot find a method to easily
>> create out of line content.
>
> Hmm, I don't see an obvious way to do it, but it sure seems like there
> should be one. Feel like putting together a patch that adds a
> setContentSrc(String) or maybe setContent(URI) version? It seems like
> it should be pretty straitforward to implement.
>
> -garrett
>
Re:
Posted by Garrett Rooney <ro...@electricjellyfish.net>.
On 8/8/06, Ugo Cei <ug...@gmail.com> wrote:
> Hi,
>
> looking at the setContent* methods on the Entry interface, I cannot
> figure out exactly which one should I use to output a <content>
> element with an src attribute. IOW, I cannot find a method to easily
> create out of line content.
Hmm, I don't see an obvious way to do it, but it sure seems like there
should be one. Feel like putting together a patch that adds a
setContentSrc(String) or maybe setContent(URI) version? It seems like
it should be pretty straitforward to implement.
-garrett