Spring Framework ResponseEntity - top ranked examples from Open Source projects

These code examples were ranked by Codota’s semantic indexing as the best open source examples for Spring Framework ResponseEntity class.

This code example shows how to use the following methods:
    @ExceptionHandler 
    public View handleException(ScimException e) {
        // No need to log the underlying exception (it will be logged by the 
        // caller) 
        return new ConvertingExceptionView(new ResponseEntity<ExceptionReport>(new ExceptionReport(
                        new BadCredentialsException("Invalid password change request"), false), e.getStatus()),
                        messageConverters);
    } 
 
    private void checkPasswordChangeIsAllowed(String userId, String oldPassword) {
        if (securityContextAccessor.isClient()) {
            // Trusted client (not acting on behalf of user) 
            return; 
        } 
 
        // Call is by or on behalf of end user 
        String currentUser = securityContextAccessor.getUserId();
 
        if (securityContextAccessor.isAdmin()) {
 
4
CodeRank
Connect your IDE to all the code out there  Get Codota for Java
This code example shows how to use the following methods:
  } 
 
  public static ResponseEntity<OpenLmisResponse> response(String key, String message, HttpStatus statusCode, String contentType) {
    MultiValueMap<String, String> headers = new LinkedMultiValueMap<>();
    headers.add("Content-Type", contentType);
    return new ResponseEntity<>(new OpenLmisResponse(key, message), headers, statusCode);
  } 
 
  public static ResponseEntity<OpenLmisResponse> response(String key, Object value) {
    return new ResponseEntity<>(new OpenLmisResponse(key, value), OK);
  } 
 
  public static ResponseEntity<OpenLmisResponse> response(String key, Object value, HttpStatus status) {
    return new ResponseEntity<>(new OpenLmisResponse(key, value), status);
  } 
 
  public static ResponseEntity<OpenLmisResponse> response(Map<String, String> messages, HttpStatus status) {
    return response(messages, status, APPLICATION_JSON_VALUE);
  } 
 
3
CodeRank
Connect your IDE to all the code out there  Get Codota for Java
This code example shows how to use the following methods:
 
		if (HttpStatus.INTERNAL_SERVER_ERROR.equals(status)) { 
			request.setAttribute("javax.servlet.error.exception", ex, WebRequest.SCOPE_REQUEST); 
		} 
 
		return new ResponseEntity<Object>(body, headers, status); 
	} 
 
	/** 
	 * Customize the response for NoSuchRequestHandlingMethodException. 
	 * This method logs a warning and delegates to 
	 * {@link #handleExceptionInternal(Exception, Object, HttpHeaders, HttpStatus, WebRequest)}. 
	 * @param ex the exception 
	 * @param headers the headers to be written to the response 
	 * @param status the selected response status 
	 * @param request the current request 
	 * @return a {@code ResponseEntity} instance 
	 */ 
	protected ResponseEntity<Object> handleNoSuchRequestHandlingMethod(NoSuchRequestHandlingMethodException ex, 
			HttpHeaders headers, HttpStatus status, WebRequest request) { 
4
CodeRank
Connect your IDE to all the code out there  Get Codota for Java
This code example shows how to use the following methods:
	 * {@link HttpStatus#OK}. 
	 *  
	 * @param entity must not be {@literal null}. 
	 */ 
	private HeaderLinksResponseEntity(HttpEntity<T> entity) {
		this(new ResponseEntity<T>(entity.getBody(), entity.getHeaders(), HttpStatus.OK));
	} 
 
	/** 
	 * Wraps the given {@link HttpEntity} into a {@link HeaderLinksResponseEntity}. Will default the status code to 
	 * {@link HttpStatus#OK} if the given value is not a {@link ResponseEntity}. 
	 *  
	 * @param entity must not be {@literal null}. 
	 * @return 
	 */ 
	public static <S extends ResourceSupport> HeaderLinksResponseEntity<S> wrap(HttpEntity<S> entity) {
 
		Assert.notNull(entity, "Given HttpEntity must not be null!");
 
		if (entity instanceof ResponseEntity) {
3
CodeRank
Connect your IDE to all the code out there  Get Codota for Java
This code example shows how to use the following methods:
    public static ResponseEntity<ExceptionMessageJson> createExceptionMessage(String message) {
        return createExceptionMessage(message, HttpStatus.BAD_REQUEST);
    } 
 
    public static ResponseEntity<ExceptionMessageJson> createExceptionMessage(String message, HttpStatus statusCode) {
        return new ResponseEntity<>(new ExceptionMessageJson(message), statusCode);
    } 
 
    public static ResponseEntity<IdExceptionMessageJson> createIdExceptionMessage(long id, String message, HttpStatus statusCode) {
        return new ResponseEntity<>(new IdExceptionMessageJson(id, message), statusCode);
    } 
} 
3
CodeRank
Connect your IDE to all the code out there  Get Codota for Java
This code example shows how to use the following methods:
    public ResponseStatusRestExceptionHandler(HttpStatus status) { 
        this.status = status; 
    } 
 
    public ResponseEntity<Void> handleException(Exception ex, HttpServletRequest request) { 
        return new ResponseEntity<>(status); 
    } 
} 
4
CodeRank
Connect your IDE to all the code out there  Get Codota for Java
This code example shows how to use the following methods:
            L.debug(R.getString("D-SPRINGMVC-REST-HANDLER#0014"), e); 
        } 
        HttpStatus status = e.getStatusCode(); 
        ErrorMessage error = createServerErrorMessage(status); 
        warn(error, e); 
        return new ResponseEntity<ErrorMessage>(error, headers, status); 
    } 
 
    /** 
     * {@link HttpServerErrorException}をハンドリングします。 
     * @param e {@link HttpServerErrorException} 
     * @return {@link ErrorMessage} 
     *      HTTPステータス 500 でレスポンスを返却します。 
     */ 
    @ExceptionHandler(HttpServerErrorException.class) 
    @ResponseBody 
    @ResponseStatus(value = HttpStatus.INTERNAL_SERVER_ERROR) 
    @Override 
    public ErrorMessage handle(HttpServerErrorException e) { 
        if (L.isDebugEnabled()) { 
1
CodeRank
Connect your IDE to all the code out there  Get Codota for Java
This code example shows how to use the following methods:
    private ResponseEntity<ClusterJson> createClusterJsonResponse(Cluster cluster) {
        return createClusterJsonResponse(cluster, HttpStatus.OK);
    } 
 
    private ResponseEntity<ClusterJson> createClusterJsonResponse(Cluster cluster, HttpStatus status) {
        return new ResponseEntity<>(clusterConverter.convert(cluster), status);
    } 
 
} 
3
CodeRank
Connect your IDE to all the code out there  Get Codota for Java
This code example shows how to use the following methods:
    private ResponseEntity<ScalingPoliciesJson> createScalingPoliciesJsonResponse(ScalingPolicies scalingPolicies) {
        return createScalingPoliciesJsonResponse(scalingPolicies, HttpStatus.OK);
    } 
 
    private ResponseEntity<ScalingPoliciesJson> createScalingPoliciesJsonResponse(ScalingPolicies scalingPolicies, HttpStatus status) {
        return new ResponseEntity<>(policiesConverter.convert(scalingPolicies), status);
    } 
 
} 
4
CodeRank
Connect your IDE to all the code out there  Get Codota for Java
See Code Examples for Spring Framework ResponseEntity Methods: