Subversion Repositories SmartDukaan

Rev

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

Rev 21278 Rev 21390
Line 69... Line 69...
69
			final ProfitMandiResponse<Response> chatOnResponse=new ProfitMandiResponse<Response>(LocalDateTime.now(), request.getRequestURL().toString(), HttpStatus.INTERNAL_SERVER_ERROR.toString(), HttpStatus.INTERNAL_SERVER_ERROR, ResponseStatus.FAILURE, response);
69
			final ProfitMandiResponse<Response> chatOnResponse=new ProfitMandiResponse<Response>(LocalDateTime.now(), request.getRequestURL().toString(), HttpStatus.INTERNAL_SERVER_ERROR.toString(), HttpStatus.INTERNAL_SERVER_ERROR, ResponseStatus.FAILURE, response);
70
			return new ResponseEntity<>(chatOnResponse,HttpStatus.INTERNAL_SERVER_ERROR);
70
			return new ResponseEntity<>(chatOnResponse,HttpStatus.INTERNAL_SERVER_ERROR);
71
		}
71
		}
72
	}
72
	}
73
	@RequestMapping(value = ProfitMandiConstants.URL_API_ID,method=RequestMethod.GET)
73
	@RequestMapping(value = ProfitMandiConstants.URL_API_ID,method=RequestMethod.GET)
74
	public ResponseEntity<?> getById(HttpServletRequest request, @RequestParam(name = "id") long id){
74
	public ResponseEntity<?> getById(HttpServletRequest request, @RequestParam(name = "id") int id){
75
		LOGGER.info("requested url : "+request.getRequestURL().toString());
75
		LOGGER.info("requested url : "+request.getRequestURL().toString());
76
		try {
76
		try {
77
			final ProfitMandiResponse<?> profitMandiResponse=new ProfitMandiResponse<>(LocalDateTime.now(), request.getRequestURL().toString(), HttpStatus.OK.toString(), HttpStatus.OK, ResponseStatus.SUCCESS, apiRepository.selectById(id));
77
			final ProfitMandiResponse<?> profitMandiResponse=new ProfitMandiResponse<>(LocalDateTime.now(), request.getRequestURL().toString(), HttpStatus.OK.toString(), HttpStatus.OK, ResponseStatus.SUCCESS, apiRepository.selectById(id));
78
			return new ResponseEntity<>(profitMandiResponse,HttpStatus.OK);
78
			return new ResponseEntity<>(profitMandiResponse,HttpStatus.OK);
79
		}catch (ProfitMandiBusinessException pmbe) {
79
		}catch (ProfitMandiBusinessException pmbe) {
Line 121... Line 121...
121
			return new ResponseEntity<>(chatOnResponse,HttpStatus.INTERNAL_SERVER_ERROR);
121
			return new ResponseEntity<>(chatOnResponse,HttpStatus.INTERNAL_SERVER_ERROR);
122
		}
122
		}
123
	}
123
	}
124
	
124
	
125
	@RequestMapping(value = ProfitMandiConstants.URL_API_ID,method=RequestMethod.DELETE)
125
	@RequestMapping(value = ProfitMandiConstants.URL_API_ID,method=RequestMethod.DELETE)
126
	public ResponseEntity<?> deleteById(HttpServletRequest request, @RequestParam(name = "id") long id){
126
	public ResponseEntity<?> deleteById(HttpServletRequest request, @RequestParam(name = "id") int id){
127
		LOGGER.info("requested url : "+request.getRequestURL().toString());
127
		LOGGER.info("requested url : "+request.getRequestURL().toString());
128
		try {
128
		try {
129
			apiRepository.deleteById(id);
129
			apiRepository.deleteById(id);
130
			final ProfitMandiResponse<?> profitMandiResponse=new ProfitMandiResponse<>(LocalDateTime.now(), request.getRequestURL().toString(), HttpStatus.OK.toString(), HttpStatus.OK, ResponseStatus.SUCCESS, ResponseCodeHolder.getMessage("API_OK_1001"));
130
			final ProfitMandiResponse<?> profitMandiResponse=new ProfitMandiResponse<>(LocalDateTime.now(), request.getRequestURL().toString(), HttpStatus.OK.toString(), HttpStatus.OK, ResponseStatus.SUCCESS, ResponseCodeHolder.getMessage("API_OK_1001"));
131
			return new ResponseEntity<>(profitMandiResponse,HttpStatus.OK);
131
			return new ResponseEntity<>(profitMandiResponse,HttpStatus.OK);
Line 147... Line 147...
147
	public ResponseEntity<?> updateNameById(HttpServletRequest request){
147
	public ResponseEntity<?> updateNameById(HttpServletRequest request){
148
		LOGGER.info("requested url : "+request.getRequestURL().toString());
148
		LOGGER.info("requested url : "+request.getRequestURL().toString());
149
		final Map<String, Object> updateApiMap = (Map<String, Object>)request.getAttribute(ProfitMandiConstants.UPDATE_API_MAP);
149
		final Map<String, Object> updateApiMap = (Map<String, Object>)request.getAttribute(ProfitMandiConstants.UPDATE_API_MAP);
150
		request.removeAttribute(ProfitMandiConstants.UPDATE_API_MAP);
150
		request.removeAttribute(ProfitMandiConstants.UPDATE_API_MAP);
151
		try {
151
		try {
152
			apiRepository.updateNameById(updateApiMap.get(ProfitMandiConstants.NAME).toString(), updateApiMap.get(ProfitMandiConstants.URI).toString(),(Method)updateApiMap.get(ProfitMandiConstants.METHOD), (Long)updateApiMap.get(ProfitMandiConstants.ID));
152
			apiRepository.updateNameById(updateApiMap.get(ProfitMandiConstants.NAME).toString(), updateApiMap.get(ProfitMandiConstants.URI).toString(),(Method)updateApiMap.get(ProfitMandiConstants.METHOD), (Integer)updateApiMap.get(ProfitMandiConstants.ID));
153
			final ProfitMandiResponse<?> profitMandiResponse=new ProfitMandiResponse<>(LocalDateTime.now(), request.getRequestURL().toString(), HttpStatus.OK.toString(), HttpStatus.OK, ResponseStatus.SUCCESS, ResponseCodeHolder.getMessage("API_OK_1002"));
153
			final ProfitMandiResponse<?> profitMandiResponse=new ProfitMandiResponse<>(LocalDateTime.now(), request.getRequestURL().toString(), HttpStatus.OK.toString(), HttpStatus.OK, ResponseStatus.SUCCESS, ResponseCodeHolder.getMessage("API_OK_1002"));
154
			return new ResponseEntity<>(profitMandiResponse,HttpStatus.OK);
154
			return new ResponseEntity<>(profitMandiResponse,HttpStatus.OK);
155
		}catch (ProfitMandiBusinessException pmbe) {
155
		}catch (ProfitMandiBusinessException pmbe) {
156
			LOGGER.error("ProfitMandi error: ", pmbe);
156
			LOGGER.error("ProfitMandi error: ", pmbe);
157
			final Response response=new Response(pmbe.getRejectedType(), pmbe.getRejectedValue(),pmbe.getCode(), pmbe.getMessage());
157
			final Response response=new Response(pmbe.getRejectedType(), pmbe.getRejectedValue(),pmbe.getCode(), pmbe.getMessage());