Subversion Repositories SmartDukaan

Rev

Rev 22861 | Rev 22987 | Go to most recent revision | Show entire file | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed

Rev 22861 Rev 22924
Line 24... Line 24...
24
	
24
	
25
	public ResponseEntity<?> ok(Object response){
25
	public ResponseEntity<?> ok(Object response){
26
		final ProfitMandiResponse<?> profitMandiResponse=new ProfitMandiResponse<>(HttpStatus.OK.toString(), HttpStatus.OK, ResponseStatus.SUCCESS, response);
26
		final ProfitMandiResponse<?> profitMandiResponse=new ProfitMandiResponse<>(HttpStatus.OK.toString(), HttpStatus.OK, ResponseStatus.SUCCESS, response);
27
		return new ResponseEntity<>(profitMandiResponse, HttpStatus.OK);
27
		return new ResponseEntity<>(profitMandiResponse, HttpStatus.OK);
28
	}
28
	}
-
 
29
	public ResponseEntity<?> badRequest(Object response){
-
 
30
		final ProfitMandiResponse<?> profitMandiResponse=new ProfitMandiResponse<>(HttpStatus.OK.toString(), HttpStatus.OK, ResponseStatus.SUCCESS, response);
-
 
31
		return new ResponseEntity<>(profitMandiResponse, HttpStatus.BAD_REQUEST);
-
 
32
	}
-
 
33
	public ResponseEntity<?> unauthorized(Object response){
-
 
34
		final ProfitMandiResponse<?> profitMandiResponse=new ProfitMandiResponse<>(HttpStatus.OK.toString(), HttpStatus.OK, ResponseStatus.SUCCESS, response);
-
 
35
		return new ResponseEntity<>(profitMandiResponse, HttpStatus.UNAUTHORIZED);
-
 
36
	}
-
 
37
	public ResponseEntity<?> forbidden(Object response){
-
 
38
		final ProfitMandiResponse<?> profitMandiResponse=new ProfitMandiResponse<>(HttpStatus.OK.toString(), HttpStatus.OK, ResponseStatus.SUCCESS, response);
-
 
39
		return new ResponseEntity<>(profitMandiResponse, HttpStatus.FORBIDDEN);
-
 
40
	}
-
 
41
	public ResponseEntity<?> notFound(Object response){
-
 
42
		final ProfitMandiResponse<?> profitMandiResponse=new ProfitMandiResponse<>(HttpStatus.OK.toString(), HttpStatus.OK, ResponseStatus.SUCCESS, response);
-
 
43
		return new ResponseEntity<>(profitMandiResponse, HttpStatus.NOT_FOUND);
-
 
44
	}
29
	public ResponseEntity<?> badRequest(ProfitMandiBusinessException profitMandiBusinessException){
45
	public ResponseEntity<?> badRequest(ProfitMandiBusinessException profitMandiBusinessException){
30
		return this.genericError(profitMandiBusinessException, HttpStatus.BAD_REQUEST);
46
		return this.genericError(profitMandiBusinessException, HttpStatus.BAD_REQUEST);
31
	}
47
	}
32
	public ResponseEntity<?> unauthorized(ProfitMandiBusinessException profitMandiBusinessException){
48
	public ResponseEntity<?> unauthorized(ProfitMandiBusinessException profitMandiBusinessException){
33
		return this.genericError(profitMandiBusinessException, HttpStatus.UNAUTHORIZED);
49
		return this.genericError(profitMandiBusinessException, HttpStatus.UNAUTHORIZED);
Line 37... Line 53...
37
	}
53
	}
38
	public ResponseEntity<?> notFound(ProfitMandiBusinessException profitMandiBusinessException){
54
	public ResponseEntity<?> notFound(ProfitMandiBusinessException profitMandiBusinessException){
39
		return this.genericError(profitMandiBusinessException, HttpStatus.NOT_FOUND);
55
		return this.genericError(profitMandiBusinessException, HttpStatus.NOT_FOUND);
40
	}
56
	}
41
	public ResponseEntity<?> internalServerError(Throwable exception){
57
	public ResponseEntity<?> internalServerError(Throwable exception){
42
		final Response response=new Response("", "", "errorCode", exception.getMessage());
58
		final Response response=new Response("", "", "GE_1007", exception.getMessage());
43
		return this.generic(response, HttpStatus.INTERNAL_SERVER_ERROR);
59
		return this.generic(response, HttpStatus.INTERNAL_SERVER_ERROR);
44
	}
60
	}
45
	
61
	
46
	private ResponseEntity<?> genericError(ProfitMandiBusinessException profitMandiBusinessException, HttpStatus status){
62
	private ResponseEntity<?> genericError(ProfitMandiBusinessException profitMandiBusinessException, HttpStatus status){
47
		final Response response=new Response(profitMandiBusinessException.getRejectedType(), profitMandiBusinessException.getRejectedValue(),profitMandiBusinessException.getCode(), profitMandiBusinessException.getMessage());
63
		final Response response=new Response(profitMandiBusinessException.getRejectedType(), profitMandiBusinessException.getRejectedValue(),profitMandiBusinessException.getCode(), profitMandiBusinessException.getMessage());