diff options
Diffstat (limited to 'branches/sca-java-1.x/modules')
3 files changed, 39 insertions, 37 deletions
diff --git a/branches/sca-java-1.x/modules/binding-atom-abdera/src/main/java/org/apache/tuscany/sca/binding/atom/provider/AtomBindingInvoker.java b/branches/sca-java-1.x/modules/binding-atom-abdera/src/main/java/org/apache/tuscany/sca/binding/atom/provider/AtomBindingInvoker.java index 3deb26feb1..91072067ea 100644 --- a/branches/sca-java-1.x/modules/binding-atom-abdera/src/main/java/org/apache/tuscany/sca/binding/atom/provider/AtomBindingInvoker.java +++ b/branches/sca-java-1.x/modules/binding-atom-abdera/src/main/java/org/apache/tuscany/sca/binding/atom/provider/AtomBindingInvoker.java @@ -383,10 +383,11 @@ class AtomBindingInvoker implements Invoker { } } else if (status == 404) { - if ( provider.supportsFeedEntries()) + if ( provider.supportsFeedEntries()) { msg.setFaultBody(new NotFoundException()); - else - msg.setFaultBody(new org.apache.tuscany.sca.data.collection.NotFoundException()); + } else { + msg.setFaultBody(new org.apache.tuscany.sca.data.collection.NotFoundException()); + } } else { msg.setFaultBody(new ServiceRuntimeException("HTTP status code: " + status)); } diff --git a/branches/sca-java-1.x/modules/binding-atom-abdera/src/main/java/org/apache/tuscany/sca/binding/atom/provider/AtomBindingUtil.java b/branches/sca-java-1.x/modules/binding-atom-abdera/src/main/java/org/apache/tuscany/sca/binding/atom/provider/AtomBindingUtil.java index 62fde86122..fad06a0c99 100644 --- a/branches/sca-java-1.x/modules/binding-atom-abdera/src/main/java/org/apache/tuscany/sca/binding/atom/provider/AtomBindingUtil.java +++ b/branches/sca-java-1.x/modules/binding-atom-abdera/src/main/java/org/apache/tuscany/sca/binding/atom/provider/AtomBindingUtil.java @@ -24,6 +24,7 @@ import java.util.Date; import org.apache.abdera.factory.Factory; import org.apache.abdera.model.Content; import org.apache.abdera.model.Link; +import org.apache.abdera.model.Content.Type; import org.apache.tuscany.sca.data.collection.Entry; import org.apache.tuscany.sca.data.collection.Item; import org.apache.tuscany.sca.databinding.Mediator; @@ -47,13 +48,13 @@ class AtomBindingUtil { static Entry<Object, Object> entry(org.apache.abdera.model.Entry feedEntry, DataType<?> itemClassType, DataType<?> itemXMLType, Mediator mediator) { if (feedEntry != null) { - if (itemClassType.getPhysical() == Item.class) { + if (itemClassType.getPhysical() == Item.class || feedEntry.getContentType() == Type.HTML ) { String key = feedEntry.getId().toString(); - + Item item = new Item(); item.setTitle(feedEntry.getTitle()); item.setContents(feedEntry.getContent()); - + for (Link link : feedEntry.getLinks()) { if (link.getRel() == null || "self".equals(link.getRel())) { if (item.getLink() == null) { @@ -65,25 +66,25 @@ class AtomBindingUtil { item.setAlternate(link.getHref().toString()); } } - + item.setDate(feedEntry.getUpdated()); - + return new Entry<Object, Object>(key, item); - + } else { String key = null; if ( feedEntry.getId() != null) { - key = feedEntry.getId().toString(); + key = feedEntry.getId().toString(); } - + // Create the item from XML if (feedEntry.getContentElement().getElements().size() == 0) { - return null; + return null; } - + String value = feedEntry.getContent(); Object data = mediator.mediate(value, itemXMLType, itemClassType, null); - + return new Entry<Object, Object>(key, data); } } else { @@ -107,19 +108,19 @@ class AtomBindingUtil { Object data = entry.getData(); if (data instanceof Item) { Item item = (Item)data; - + org.apache.abdera.model.Entry feedEntry = factory.newEntry(); if (key != null) { feedEntry.setId(key.toString()); } feedEntry.setTitle(item.getTitle()); feedEntry.setContentAsHtml(item.getContents()); - + String href = item.getLink(); if (href == null && key != null) { href = key.toString(); } - + if (href != null) { feedEntry.addLink(href); } @@ -131,31 +132,31 @@ class AtomBindingUtil { if (alternate != null) { feedEntry.addLink(alternate, "alternate"); } - + Date date = item.getDate(); if (date != null) { feedEntry.setUpdated(date); } return feedEntry; - + } else if (data != null) { org.apache.abdera.model.Entry feedEntry = factory.newEntry(); - feedEntry.setId(key.toString()); - feedEntry.setTitle("item"); - - - // Convert the item to XML - String value = mediator.mediate(data, itemClassType, itemXMLType, null).toString(); - - Content content = factory.newContent(); - content.setContentType(Content.Type.XML); - content.setValue(value); - - feedEntry.setContentElement(content); - - feedEntry.addLink(key.toString()); - - return feedEntry; + feedEntry.setId(key.toString()); + feedEntry.setTitle("item"); + + + // Convert the item to XML + String value = mediator.mediate(data, itemClassType, itemXMLType, null).toString(); + + Content content = factory.newContent(); + content.setContentType(Content.Type.XML); + content.setValue(value); + + feedEntry.setContentElement(content); + + feedEntry.addLink(key.toString()); + + return feedEntry; } else { return null; } diff --git a/branches/sca-java-1.x/modules/binding-atom-abdera/src/test/java/org/apache/tuscany/sca/binding/atom/aggregator/AggregatorTestCase.java b/branches/sca-java-1.x/modules/binding-atom-abdera/src/test/java/org/apache/tuscany/sca/binding/atom/aggregator/AggregatorTestCase.java index 547bfe058a..c3666f1916 100644 --- a/branches/sca-java-1.x/modules/binding-atom-abdera/src/test/java/org/apache/tuscany/sca/binding/atom/aggregator/AggregatorTestCase.java +++ b/branches/sca-java-1.x/modules/binding-atom-abdera/src/test/java/org/apache/tuscany/sca/binding/atom/aggregator/AggregatorTestCase.java @@ -55,8 +55,8 @@ public class AggregatorTestCase { new Socket("127.0.0.1", 8085); } - @Ignore("TUSCANY-2939") - //@Test + //@Ignore("TUSCANY-2939") + @Test public void testAggregator() throws Exception { Entry<String, Item>[] entries = aggregatorService.getAll(); |