Package org.springframework.http

Examples of org.springframework.http.ResponseEntity$BodyBuilder


      latestEtag = eTagHelper.get(url1);
    } catch (InvalidTagException e) {
      // ignore
    }
    if (latestEtag != null && clientEtag != null && clientEtag.equals(latestEtag)) {
      return new ResponseEntity(null, new HttpHeaders(), HttpStatus.NOT_MODIFIED);
    }

    Object retVal = pjp.proceed();
    ResponseEntity entity = (ResponseEntity) retVal;
    HttpHeaders headers = new HttpHeaders();
    String url = ServletUriComponentsBuilder.fromRequest(request).build().toString();
    String tag = null;
    try {
      tag = eTagHelper.get(url);
    } catch (InvalidTagException e) {
      tag = eTagHelper.generate(url, entity.getBody());
    }
    headers.add("Etag", tag);
    return new ResponseEntity(entity.getBody(), headers, entity.getStatusCode());
  }
View Full Code Here


  @SuppressWarnings({ "rawtypes", "unchecked" })
  private Object handlePUT(ProceedingJoinPoint pjp) throws Throwable {
    HttpServletRequest request = ((ServletRequestAttributes) RequestContextHolder.getRequestAttributes())
        .getRequest();
    ResponseEntity responseEntity = (ResponseEntity) pjp.proceed();
    String url = ServletUriComponentsBuilder.fromRequest(request).build().toString();
    HttpHeaders headers = new HttpHeaders();
    BaseDomain domain = (BaseDomain) responseEntity.getBody();
    String newTag = eTagHelper.update(url, domain);
    headers.add("Etag", newTag);
    return new ResponseEntity(responseEntity.getBody(), headers, responseEntity.getStatusCode());
  }
View Full Code Here

    HttpServletRequest request = ((ServletRequestAttributes) RequestContextHolder.getRequestAttributes())
        .getRequest();
    String url = ServletUriComponentsBuilder.fromRequest(request).build().toString();
    pjp.proceed();
    eTagHelper.remove(url);
    return new ResponseEntity(HttpStatus.NO_CONTENT);
  }
View Full Code Here

    case PUT:
      if (checkEtag()) {
        retVal = handlePUT(pjp);
      } else {
        retVal = new ResponseEntity(HttpStatus.PRECONDITION_FAILED);
      }
      break;

    case DELETE:
      if (checkEtag()) {
        retVal = handleDELETE(pjp);
      } else {
        retVal = new ResponseEntity(HttpStatus.PRECONDITION_FAILED);
      }
      break;

    case HEAD:
      retVal = pjp.proceed();
View Full Code Here

    Long id = task.getId();
    URI uri = uriBuilder.path("/api/v1/task/" + id).build().toUri();
    HttpHeaders headers = new HttpHeaders();
    headers.setLocation(uri);

    return new ResponseEntity(headers, HttpStatus.CREATED);
  }
View Full Code Here

    Long id = task.getId();
    URI uri = uriBuilder.path("/api/v1/task/" + id).build().toUri();
    HttpHeaders headers = new HttpHeaders();
    headers.setLocation(uri);

    return new ResponseEntity(headers, HttpStatus.CREATED);
  }
View Full Code Here

    // 按照Restful风格约定,创建指向新任务的url, 也可以直接返回id或对象.
    Long id = task.getId();
    HttpHeaders headers = createLocation(uriBuilder, "/task/" + id);

    return new ResponseEntity(headers, HttpStatus.CREATED);
  }
View Full Code Here

    } catch (AmazonServiceException e) {
      int statusCode = 400;
      if (e instanceof InternalServerErrorException) {
        statusCode = 500;
      }
      ResponseEntity responseEntity = new ResponseEntity<String>(new AmazonServiceExceptionMarshaller().marshall(e), new HttpHeaders(), HttpStatus.valueOf(statusCode));
            return responseEntity;
    }
  }
View Full Code Here

    @Autowired
    private RestTemplate restTemplate;

    @Test
    public void testGetResourcesInJson() throws Exception {
        ResponseEntity response = restTemplate.exchange( URL_STRING+"/bioQualifiers.json",
                HttpMethod.GET,new HttpEntity<String>(new HttpHeaders()), String.class);
        assertEquals("",response.getBody());

    }
View Full Code Here

        final Specification filterSpecification = specificationFromRequest(request, persistentEntity);

        if (isPredicateScope(scope)) {
            final PredicateScopeMetadata predicateScope = (PredicateScopeMetadata) scope;

            return new ResponseEntity(countItemsBySpecificationAndPredicate(repositoryInvoker, filterSpecification, predicateScope.predicate()), HttpStatus.OK);
        }

        if (isSpecificationScope(scope)) {
            final Specification scopeSpecification = ((ScopeMetadataUtils.SpecificationScopeMetadata) scope).specification();

            return new ResponseEntity(countItemsBySpecification(repositoryInvoker, and(scopeSpecification, filterSpecification)), HttpStatus.OK);
        }

        return new ResponseEntity(countItemsBySpecification(repositoryInvoker, filterSpecification), HttpStatus.OK);
    }
View Full Code Here

TOP

Related Classes of org.springframework.http.ResponseEntity$BodyBuilder

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.