當前位置: 首頁>>代碼示例>>Java>>正文


Java HttpStatus.NOT_MODIFIED屬性代碼示例

本文整理匯總了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);
}
 
開發者ID:Apereo-Learning-Analytics-Initiative,項目名稱:OpenLRW,代碼行數:26,代碼來源:ClassController.java

示例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);

}
 
開發者ID:Apereo-Learning-Analytics-Initiative,項目名稱:OpenLRW,代碼行數:25,代碼來源:UserController.java

示例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;
}
 
開發者ID:lamsfoundation,項目名稱:lams,代碼行數:18,代碼來源:HttpMessageConverterExtractor.java

示例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");
	}
}
 
開發者ID:ewolff,項目名稱:microservice-atom,代碼行數:27,代碼來源:InvoicePoller.java

示例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");
	}
}
 
開發者ID:ewolff,項目名稱:microservice-atom,代碼行數:27,代碼來源:ShippingPoller.java

示例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);
			}

		}
	}
}
 
開發者ID:mploed,項目名稱:event-driven-spring-boot,代碼行數:41,代碼來源:CreditDecisionPoller.java


注:本文中的org.springframework.http.HttpStatus.NOT_MODIFIED屬性示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。