Returns a feed document containing the single requested entry. NOTE: this is a deviation from atompub. TODO: not much point in returning feed now; prolly should conform to spec.
(RequestContext request)
| 588 | * prolly should conform to spec. |
| 589 | */ |
| 590 | public ResponseContext getEntry(RequestContext request) { |
| 591 | // make a copy of the current template |
| 592 | Feed result; |
| 593 | try { |
| 594 | result = currentFeed(request); |
| 595 | // add requested entry |
| 596 | String entryId = request.getTarget().getParameter("entry"); |
| 597 | Document<Entry> entry = getEntry(persistence, feedId, |
| 598 | Common.toEntryId(entryId)); |
| 599 | if (entry != null) { |
| 600 | result.addEntry(entry.getRoot()); |
| 601 | } else { |
| 602 | return ProviderHelper.notfound(request); |
| 603 | } |
| 604 | return ProviderHelper.returnBase(result, 200, result.getUpdated()); |
| 605 | // FIXME: Abdera's etag creator doesn't create valid etags |
| 606 | // .setEntityTag(ProviderHelper.calculateEntityTag(result)); |
| 607 | } catch (FileNotFoundException e) { |
| 608 | log.debug("Could not find feed: " + feedId, e); |
| 609 | return ProviderHelper.notfound(request); |
| 610 | } catch (ParseException e) { |
| 611 | log.error("Could not parse stored feed: " + feedId, e); |
| 612 | return ProviderHelper.servererror(request, e); |
| 613 | } catch (IOException e) { |
| 614 | log.error("Unexpected error reading feed: " + feedId, e); |
| 615 | return ProviderHelper.servererror(request, e); |
| 616 | } |
| 617 | } |
| 618 | |
| 619 | protected static Document<Entry> getEntry(Storage storage, String feedId, |
| 620 | long entryId) { |
no test coverage detected