本文整理汇总了Java中org.springframework.http.HttpStatus.NOT_MODIFIED属性的典型用法代码示例。如果您正苦于以下问题:Java HttpStatus.NOT_MODIFIED属性的具体用法?Java HttpStatus.NOT_MODIFIED怎么用?Java HttpStatus.NOT_MODIFIED使用的例子?那么恭喜您, 这里精选的属性代码示例或许可以为您提供帮助。您也可以进一步了解该属性所在类org.springframework.http.HttpStatus
的用法示例。
在下文中一共展示了HttpStatus.NOT_MODIFIED属性的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: postClassMapping
@RequestMapping(value= "/mapping", method = RequestMethod.POST)
public ResponseEntity<?> postClassMapping(JwtAuthenticationToken token, @RequestBody ClassMapping cm) {
UserContext userContext = (UserContext) token.getPrincipal();
ClassMapping classMapping = null;
ClassMapping existingClassMapping = mongoClassMappingRepository
.findByTenantIdAndOrganizationIdAndClassExternalId(userContext.getTenantId(), userContext.getOrgId(), cm.getClassExternalId());
if (existingClassMapping == null) {
classMapping
= new ClassMapping.Builder()
.withClassExternalId(cm.getClassExternalId())
.withClassSourcedId(cm.getClassSourcedId())
.withDateLastModified(LocalDateTime.now(ZoneId.of("UTC")))
.withOrganizationId(userContext.getOrgId())
.withTenantId(userContext.getTenantId())
.build();
ClassMapping saved = mongoClassMappingRepository.save(classMapping);
return new ResponseEntity<>(saved, null, HttpStatus.CREATED);
}
return new ResponseEntity<>(existingClassMapping, null, HttpStatus.NOT_MODIFIED);
}
示例2: postUserMapping
@RequestMapping(value= "/mapping", method = RequestMethod.POST)
public ResponseEntity<?> postUserMapping(JwtAuthenticationToken token, @RequestBody UserMapping um) {
UserContext userContext = (UserContext) token.getPrincipal();
UserMapping existingUserMapping = mongoUserMappingRepository
.findByTenantIdAndOrganizationIdAndUserExternalIdIgnoreCase(userContext.getTenantId(), userContext.getOrgId(), um.getUserExternalId());
if (existingUserMapping == null) {
UserMapping userMapping
= new UserMapping.Builder()
.withUserExternalId(um.getUserExternalId())
.withUserSourcedId(um.getUserSourcedId())
.withDateLastModified(LocalDateTime.now(ZoneId.of("UTC")))
.withOrganizationId(userContext.getOrgId())
.withTenantId(userContext.getTenantId())
.build();
UserMapping saved = mongoUserMappingRepository.save(userMapping);
return new ResponseEntity<>(saved, null, HttpStatus.CREATED);
}
return new ResponseEntity<>(existingUserMapping, null, HttpStatus.NOT_MODIFIED);
}
示例3: hasMessageBody
/**
* Indicates whether the given response has a message body. <p>Default implementation
* returns {@code false} for a response status of {@code 204} or {@code 304}, or a {@code
* Content-Length} of {@code 0}.
*
* @param response the response to check for a message body
* @return {@code true} if the response has a body, {@code false} otherwise
* @throws IOException in case of I/O errors
*/
protected boolean hasMessageBody(ClientHttpResponse response) throws IOException {
HttpStatus responseStatus = response.getStatusCode();
if (responseStatus == HttpStatus.NO_CONTENT ||
responseStatus == HttpStatus.NOT_MODIFIED) {
return false;
}
long contentLength = response.getHeaders().getContentLength();
return contentLength != 0;
}
示例4: pollInternal
public void pollInternal() {
HttpHeaders requestHeaders = new HttpHeaders();
if (lastModified != null) {
requestHeaders.set(HttpHeaders.IF_MODIFIED_SINCE, DateUtils.formatDate(lastModified));
}
HttpEntity<?> requestEntity = new HttpEntity(requestHeaders);
ResponseEntity<Feed> response = restTemplate.exchange(url, HttpMethod.GET, requestEntity, Feed.class);
if (response.getStatusCode() != HttpStatus.NOT_MODIFIED) {
log.trace("data has been modified");
Feed feed = response.getBody();
for (Entry entry : feed.getEntries()) {
if ((lastModified == null) || (entry.getUpdated().after(lastModified))) {
Invoice invoice = restTemplate
.getForEntity(entry.getContents().get(0).getSrc(), Invoice.class).getBody();
log.trace("saving invoice {}", invoice.getId());
invoiceService.generateInvoice(invoice);
}
}
if (response.getHeaders().getFirst(HttpHeaders.LAST_MODIFIED) != null) {
lastModified = DateUtils.parseDate(response.getHeaders().getFirst(HttpHeaders.LAST_MODIFIED));
log.trace("Last-Modified header {}", lastModified);
}
} else {
log.trace("no new data");
}
}
示例5: pollInternal
public void pollInternal() {
HttpHeaders requestHeaders = new HttpHeaders();
if (lastModified != null) {
requestHeaders.set(HttpHeaders.IF_MODIFIED_SINCE, DateUtils.formatDate(lastModified));
}
HttpEntity<?> requestEntity = new HttpEntity(requestHeaders);
ResponseEntity<Feed> response = restTemplate.exchange(url, HttpMethod.GET, requestEntity, Feed.class);
if (response.getStatusCode() != HttpStatus.NOT_MODIFIED) {
log.trace("data has been modified");
Feed feed = response.getBody();
for (Entry entry : feed.getEntries()) {
if ((lastModified == null) || (entry.getUpdated().after(lastModified))) {
Shipment shipping = restTemplate
.getForEntity(entry.getContents().get(0).getSrc(), Shipment.class).getBody();
log.trace("saving shipping {}", shipping.getId());
shipmentService.ship(shipping);
}
}
if (response.getHeaders().getFirst("Last-Modified") != null) {
lastModified = DateUtils.parseDate(response.getHeaders().getFirst(HttpHeaders.LAST_MODIFIED));
log.trace("Last-Modified header {}", lastModified);
}
} else {
log.trace("no new data");
}
}
示例6: poll
@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);
}
}
}
}