Subversion Repositories SmartDukaan

Rev

Rev 22931 | Show entire file | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed

Rev 22931 Rev 23273
Line 30... Line 30...
30
	
30
	
31
	@Autowired
31
	@Autowired
32
	private ApiRepository apiRepository;
32
	private ApiRepository apiRepository;
33
	
33
	
34
	@RequestMapping(value = ProfitMandiConstants.URL_API, method=RequestMethod.POST)
34
	@RequestMapping(value = ProfitMandiConstants.URL_API, method=RequestMethod.POST)
35
	public ResponseEntity<?> createApi(HttpServletRequest request){
35
	public ResponseEntity<?> createApi(HttpServletRequest request) throws ProfitMandiBusinessException{
36
		LOGGER.info("requested url : "+request.getRequestURL().toString());
36
		LOGGER.info("requested url : "+request.getRequestURL().toString());
37
		final Api api = (Api)request.getAttribute(ProfitMandiConstants.API);
37
		final Api api = (Api)request.getAttribute(ProfitMandiConstants.API);
38
		request.removeAttribute(ProfitMandiConstants.API);
38
		request.removeAttribute(ProfitMandiConstants.API);
39
		try {
39
		apiRepository.selectByUriAndMethod(api.getUri(), api.getMethod());
40
			apiRepository.persist(api);
40
		apiRepository.persist(api);
41
			return responseSender.ok(ResponseCodeHolder.getMessage("API_OK_1000"));
41
		return responseSender.ok(ResponseCodeHolder.getMessage("API_OK_1000"));
42
		}catch (ProfitMandiBusinessException profitMandiBusinessException) {
-
 
43
			LOGGER.error("ProfitMandi error: ",  profitMandiBusinessException);
-
 
44
			return responseSender.badRequest(profitMandiBusinessException);
-
 
45
		}
-
 
46
	}
42
	}
47
	
43
	
48
	@RequestMapping(value = ProfitMandiConstants.URL_API_ALL,method=RequestMethod.GET)
44
	@RequestMapping(value = ProfitMandiConstants.URL_API_ALL,method=RequestMethod.GET)
49
	public ResponseEntity<?> getAll(HttpServletRequest request, @RequestParam(name = ProfitMandiConstants.PAGE_NUMBER) int pageNumber, @RequestParam(name = ProfitMandiConstants.PAGE_SIZE) int pageSize){
45
	public ResponseEntity<?> getAll(HttpServletRequest request, @RequestParam(name = ProfitMandiConstants.PAGE_NUMBER) int pageNumber, @RequestParam(name = ProfitMandiConstants.PAGE_SIZE) int pageSize){
50
		LOGGER.info("requested url : "+request.getRequestURL().toString());
46
		LOGGER.info("requested url : "+request.getRequestURL().toString());
Line 83... Line 79...
83
		
79
		
84
		
80
		
85
	}
81
	}
86
	
82
	
87
	@RequestMapping(value = ProfitMandiConstants.URL_API_ID,method=RequestMethod.DELETE)
83
	@RequestMapping(value = ProfitMandiConstants.URL_API_ID,method=RequestMethod.DELETE)
88
	public ResponseEntity<?> deleteById(HttpServletRequest request, @RequestParam(name = "id") int id){
84
	public ResponseEntity<?> deleteById(HttpServletRequest request, @RequestParam(name = "id") int id) throws ProfitMandiBusinessException{
89
		LOGGER.info("requested url : "+request.getRequestURL().toString());
85
		LOGGER.info("requested url : "+request.getRequestURL().toString());
90
		try {
-
 
91
			apiRepository.deleteById(id);
86
		apiRepository.deleteById(id);
92
			return responseSender.ok(ResponseCodeHolder.getMessage("API_OK_1001"));
87
		return responseSender.ok(ResponseCodeHolder.getMessage("API_OK_1001"));
93
		}catch (ProfitMandiBusinessException profitMandiBusinessException) {
-
 
94
			LOGGER.error("ProfitMandi error: ",  profitMandiBusinessException);
-
 
95
			return responseSender.badRequest(profitMandiBusinessException);
-
 
96
		}
-
 
97
	}
88
	}
98
		
89
		
99
}
90
}
100
91