Java Code Examples for com.rometools.rome.feed.atom.Entry#getUpdated()
The following examples show how to use
com.rometools.rome.feed.atom.Entry#getUpdated() .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: CreditAgencyPoller.java From ddd-with-spring with Apache License 2.0 | 4 votes |
@Scheduled(fixedDelay = 30000) public void poll() { HttpHeaders requestHeaders = new HttpHeaders(); if (lastModified != null) { requestHeaders.set("If-Modified-Since", DateUtils.formatDate(lastModified)); } HttpEntity<?> requestEntity = new HttpEntity(requestHeaders); log.info("Polling Credit Agency for new ratings"); ResponseEntity<Feed> response = restTemplate.exchange(creditAgencyFeed, HttpMethod.GET, requestEntity, Feed.class); if (response.getStatusCode() != HttpStatus.NOT_MODIFIED) { Feed feed = response.getBody(); Date lastUpdateInFeed = null; ObjectMapper mapper = new ObjectMapper(); for (Entry entry : feed.getEntries()) { String ratingAsJson = entry.getSummary().getValue(); if ((lastModified == null) || (entry.getUpdated().after(lastModified))) { log.info(entry.getTitle() + " is new, processing"); try { AgencyRating agencyRating = mapper.readValue(ratingAsJson, AgencyRating.class); scoringApplicationService.scoreAgencyResult(agencyRating.getFirstName(), agencyRating.getLastName(), agencyRating.getStreet(), agencyRating.getPostCode(), agencyRating.getCity(), agencyRating.getPoints()); lastUpdateInFeed = entry.getUpdated(); } catch (IOException e) { //we should handle this exception more properly e.printStackTrace(); } } } if (response.getHeaders().getFirst("Last-Modified") != null) { lastModified = DateUtils.parseDate(response.getHeaders().getFirst("Last-Modified")); log.info("LastModified header {}", lastModified); } else { if (lastUpdateInFeed != null) { lastModified = lastUpdateInFeed; log.info("Last in feed {}", lastModified); } } } }
Example 2
Source File: CreditDecisionPoller.java From event-driven-spring-boot with Apache License 2.0 | 4 votes |
@Scheduled(fixedDelay = 15000) public void poll() { HttpHeaders requestHeaders = new HttpHeaders(); if (lastModified != null) { requestHeaders.set("If-Modified-Since", DateUtils.formatDate(lastModified)); } HttpEntity<?> requestEntity = new HttpEntity(requestHeaders); ResponseEntity<Feed> response = restTemplate.exchange(creditDecisionFeed, HttpMethod.GET, requestEntity, Feed.class); if (response.getStatusCode() != HttpStatus.NOT_MODIFIED) { Feed feed = response.getBody(); Date lastUpdateInFeed = null; for (Entry entry : feed.getEntries()) { String applicationNumber = entry.getSummary().getValue(); if ((lastModified == null) || (entry.getUpdated().after(lastModified))) { log.info(applicationNumber + " is new, updating the status"); CreditApplicationStatus applicationStatus = repository.findByApplicationNumber(applicationNumber); if (applicationStatus != null) { applicationStatus.setApproved(true); repository.save(applicationStatus); } if ((lastUpdateInFeed == null) || (entry.getUpdated().after(lastUpdateInFeed))) { lastUpdateInFeed = entry.getUpdated(); } } } if (response.getHeaders().getFirst("Last-Modified") != null) { lastModified = DateUtils.parseDate(response.getHeaders().getFirst("Last-Modified")); log.info("LastModified header {}", lastModified); } else { if (lastUpdateInFeed != null) { lastModified = lastUpdateInFeed; log.info("Last in feed {}", lastModified); } } } }