@Override protected List<Entry> buildFeedEntries(Map<String, Object> model, HttpServletRequest request, HttpServletResponse response) { List<Entry> entries = new ArrayList<>(); for (String name : model.keySet()) { Entry entry = new Entry(); entry.setTitle(name); Content content = new Content(); content.setValue((String) model.get(name)); entry.setSummary(content); entries.add(entry); } return entries; } }
@Test public void write() throws IOException, SAXException { Feed feed = new Feed("atom_1.0"); feed.setTitle("title"); Entry entry1 = new Entry(); entry1.setId("id1"); entry1.setTitle("title1"); Entry entry2 = new Entry(); entry2.setId("id2"); entry2.setTitle("title2"); List<Entry> entries = new ArrayList<>(2); entries.add(entry1); entries.add(entry2); feed.setEntries(entries); MockHttpOutputMessage outputMessage = new MockHttpOutputMessage(); converter.write(feed, null, outputMessage); assertEquals("Invalid content-type", new MediaType("application", "atom+xml", StandardCharsets.UTF_8), outputMessage.getHeaders().getContentType()); String expected = "<feed xmlns=\"http://www.w3.org/2005/Atom\">" + "<title>title</title>" + "<entry><id>id1</id><title>title1</title></entry>" + "<entry><id>id2</id><title>title2</title></entry></feed>"; NodeMatcher nm = new DefaultNodeMatcher(ElementSelectors.byName); assertThat(outputMessage.getBodyAsString(StandardCharsets.UTF_8), isSimilarTo(expected).ignoreWhitespace().withNodeMatcher(nm)); }
@Override protected List<Entry> buildFeedEntries(Map<String, Object> model, HttpServletRequest request, HttpServletResponse response) throws Exception { log.info("In buildFeedEntries: " + model); Vets vets = (Vets) model.get("vets"); List<Vet> vetList = vets.getVetList(); List<Entry> entries = new ArrayList<Entry>(vetList.size()); for (Vet vet : vetList) { Entry entry = new Entry(); // see // http://diveintomark.org/archives/2004/05/28/howto-atom-id#other entry.setId(String.format("tag:springsource.org,%s", vet.getId())); entry.setTitle(String.format("Vet: %s %s", vet.getFirstName(), vet.getLastName())); entry.setUpdated(new Date()); Content summary = new Content(); summary.setValue(vet.getSpecialties().toString()); entry.setSummary(summary); entries.add(entry); } response.setContentType("blabla"); return entries; } }
resource.setTitle(title); final Content content = new Content(); content.setType(areq.getContentType());
entry.setTitle(slug);
@Override protected List<Entry> buildFeedEntries(Map<String, Object> model, HttpServletRequest request, HttpServletResponse response) throws Exception { List<Entry> entries = new ArrayList<Entry>(); List<Customer> customerlist = (List<Customer>) model.get("customers"); for (Customer o : customerlist) { Entry entry = new Entry(); entry.setId("https://github.com/mploed/event-driven-spring-boot/customer/" + Long.toString(o.getId())); entry.setUpdated(o.getUpdated()); entry.setTitle("Customer " + o.getId()); List<Content> contents = new ArrayList<Content>(); Content content = new Content(); content.setSrc(baseUrl(request) + "customer/rest/" + Long.toString(o.getId())); content.setType("application/json"); contents.add(content); entry.setContents(contents); Content summary = new Content(); summary.setValue("This is the customer " + o.getId()); entry.setSummary(summary); entries.add(entry); } return entries; } }
private void updateMediaEntryAppLinks(final Entry entry, final String fileName, final boolean singleEntry) { // TODO: figure out why PNG is missing from Java MIME types final FileTypeMap map = FileTypeMap.getDefaultFileTypeMap(); if (map instanceof MimetypesFileTypeMap) { try { ((MimetypesFileTypeMap) map).addMimeTypes("image/png png PNG"); } catch (final Exception ignored) { } } entry.setId(getEntryMediaViewURI(fileName)); entry.setTitle(fileName); entry.setUpdated(new Date()); final List<Link> otherlinks = new ArrayList<Link>(); entry.setOtherLinks(otherlinks); final Link editlink = new Link(); editlink.setRel("edit"); editlink.setHref(getEntryEditURI(fileName, relativeURIs, singleEntry)); otherlinks.add(editlink); final Link editMedialink = new Link(); editMedialink.setRel("edit-media"); editMedialink.setHref(getEntryMediaEditURI(fileName, relativeURIs, singleEntry)); otherlinks.add(editMedialink); final Content content = entry.getContents().get(0); content.setSrc(getEntryMediaViewURI(fileName)); final List<Content> contents = new ArrayList<Content>(); contents.add(content); entry.setContents(contents); }
@Override protected List<Entry> buildFeedEntries(Map<String, Object> model, HttpServletRequest request, HttpServletResponse response) throws Exception { List<Entry> entries = new ArrayList<Entry>(); ObjectMapper mapper = new ObjectMapper(); for (PersonRating personRating : personRatingRepository.findAll(new Sort(Sort.Direction.DESC, "lastUpdated"))) { Entry entry = new Entry(); entry.setId("https://github.com/mploed/ddd-with-spring/person-rating/" + personRating.getId()); entry.setUpdated(personRating.getLastUpdated()); entry.setTitle("Person Rating " + personRating.getId()); List<Content> contents = new ArrayList<Content>(); Content content = new Content(); content.setSrc(baseUrl(request) + "rating/rest/" + personRating.getId()); content.setType("application/json"); contents.add(content); entry.setContents(contents); Content summary = new Content(); summary.setValue(mapper.writeValueAsString(personRating)); entry.setSummary(summary); entries.add(entry); } return entries; } }
@Override protected List<Entry> buildFeedEntries(Map<String, Object> model, HttpServletRequest request, HttpServletResponse response) throws Exception { List<Entry> entries = new ArrayList<Entry>(); List<DecisionMemo> decisionMemos = (List<DecisionMemo>) model.get("approvedDecisions"); for (DecisionMemo o : decisionMemos) { Entry entry = new Entry(); entry.setId("https://github.com/mploed/event-driven-spring-boot/decision-memo/" + o.getId()); entry.setUpdated(o.getLastUpdate()); entry.setTitle("Approved Decision " + o.getId()); List<Content> contents = new ArrayList<Content>(); Content content = new Content(); content.setSrc(baseUrl(request) + "credit-decision/rest/" + o.getId()); content.setType("application/json"); contents.add(content); entry.setContents(contents); Content summary = new Content(); summary.setValue(o.getApplicationNumber()); entry.setSummary(summary); entries.add(entry); } return entries; } }
entry.setTitle(file.getName()); entry.setUpdated(new Date(file.getLastModified()));
atomEntry.setTitle( entry.getTitle()); atomEntry.setPublished( entry.getPubTime()); atomEntry.setUpdated( entry.getUpdateTime());