Subversion Repositories SmartDukaan

Rev

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

Rev 21390 Rev 21426
Line 1... Line 1...
1
package com.spice.profitmandi.web.controller;
1
package com.spice.profitmandi.web.controller;
2
 
2
 
3
import java.time.LocalDateTime;
3
import java.time.LocalDateTime;
4
import java.util.Map;
-
 
5
 
4
 
6
import javax.servlet.http.HttpServletRequest;
5
import javax.servlet.http.HttpServletRequest;
7
 
6
 
8
import org.slf4j.Logger;
7
import org.slf4j.Logger;
9
import org.slf4j.LoggerFactory;
8
import org.slf4j.LoggerFactory;
Line 17... Line 16...
17
 
16
 
18
import com.spice.profitmandi.common.ResponseCodeHolder;
17
import com.spice.profitmandi.common.ResponseCodeHolder;
19
import com.spice.profitmandi.common.exception.ProfitMandiBusinessException;
18
import com.spice.profitmandi.common.exception.ProfitMandiBusinessException;
20
import com.spice.profitmandi.common.model.ProfitMandiConstants;
19
import com.spice.profitmandi.common.model.ProfitMandiConstants;
21
import com.spice.profitmandi.common.util.StringUtils;
20
import com.spice.profitmandi.common.util.StringUtils;
22
import com.spice.profitmandi.dao.entity.Role;
-
 
23
import com.spice.profitmandi.dao.enumuration.RoleType;
21
import com.spice.profitmandi.dao.enumuration.RoleType;
24
import com.spice.profitmandi.dao.enumuration.Status;
-
 
25
import com.spice.profitmandi.dao.repository.RoleRepository;
22
import com.spice.profitmandi.dao.repository.RoleRepository;
26
import com.spice.profitmandi.web.model.ProfitMandiResponse;
23
import com.spice.profitmandi.web.model.ProfitMandiResponse;
27
import com.spice.profitmandi.web.model.Response;
24
import com.spice.profitmandi.web.model.Response;
28
import com.spice.profitmandi.web.model.ResponseStatus;
25
import com.spice.profitmandi.web.model.ResponseStatus;
29
 
26
 
Line 37... Line 34...
37
	private static final Logger LOGGER=LoggerFactory.getLogger(RoleController.class);
34
	private static final Logger LOGGER=LoggerFactory.getLogger(RoleController.class);
38
	
35
	
39
	@Autowired
36
	@Autowired
40
	RoleRepository roleRepository;
37
	RoleRepository roleRepository;
41
	
38
	
42
	@RequestMapping(value = ProfitMandiConstants.URL_ROLE, method = RequestMethod.POST)
-
 
43
	public ResponseEntity<?> createRole(HttpServletRequest request){
-
 
44
		LOGGER.info("requested url : "+request.getRequestURL().toString());
-
 
45
		final Role role = (Role)request.getAttribute("role");
-
 
46
		request.removeAttribute("role");
-
 
47
		try {
-
 
48
			role.setStatus(Status.ACTIVE);
-
 
49
			role.setCreateTimestamp(LocalDateTime.now());
-
 
50
			role.setUpdateTimestamp(LocalDateTime.now());
-
 
51
			roleRepository.persist(role);
-
 
52
			final ProfitMandiResponse<?> profitMandiResponse=new ProfitMandiResponse<>(LocalDateTime.now(), request.getRequestURL().toString(), HttpStatus.OK.toString(), HttpStatus.OK, ResponseStatus.SUCCESS, ResponseCodeHolder.getMessage("ROL_OK_1000"));
-
 
53
			return new ResponseEntity<>(profitMandiResponse, HttpStatus.OK);
-
 
54
		}catch (ProfitMandiBusinessException pmbe) {
-
 
55
			LOGGER.error("ProfitMandi error: ", pmbe);
-
 
56
			final Response response=new Response(pmbe.getRejectedType(), pmbe.getRejectedValue(),pmbe.getCode(), pmbe.getMessage());
-
 
57
			final ProfitMandiResponse<Response> chatOnResponse=new ProfitMandiResponse<Response>(LocalDateTime.now(), request.getRequestURL().toString(), HttpStatus.BAD_REQUEST.toString(), HttpStatus.BAD_REQUEST, ResponseStatus.FAILURE, response);
-
 
58
			return new ResponseEntity<>(chatOnResponse,HttpStatus.BAD_REQUEST);
-
 
59
		}catch (Exception e) {
-
 
60
			LOGGER.error("Internal Server Error : ",e);
-
 
61
			final Response response=new Response("","","", e.getMessage());
-
 
62
			final ProfitMandiResponse<Response> chatOnResponse=new ProfitMandiResponse<Response>(LocalDateTime.now(), request.getRequestURL().toString(), HttpStatus.INTERNAL_SERVER_ERROR.toString(), HttpStatus.INTERNAL_SERVER_ERROR, ResponseStatus.FAILURE, response);
-
 
63
			return new ResponseEntity<>(chatOnResponse,HttpStatus.INTERNAL_SERVER_ERROR);
-
 
64
		}
-
 
65
	}
-
 
66
	
-
 
67
	@RequestMapping(value = ProfitMandiConstants.URL_ROLE_ALL,method=RequestMethod.GET)
39
	@RequestMapping(value = ProfitMandiConstants.URL_ROLE_ALL,method=RequestMethod.GET)
68
	public ResponseEntity<?> getAll(HttpServletRequest request){
40
	public ResponseEntity<?> getAll(HttpServletRequest request){
69
		LOGGER.info("requested url : "+request.getRequestURL().toString());
41
		LOGGER.info("requested url : "+request.getRequestURL().toString());
70
		try {
-
 
71
			final ProfitMandiResponse<?> profitMandiResponse=new ProfitMandiResponse<>(LocalDateTime.now(), request.getRequestURL().toString(), HttpStatus.OK.toString(), HttpStatus.OK, ResponseStatus.SUCCESS, roleRepository.selectAll());
42
		final ProfitMandiResponse<?> profitMandiResponse=new ProfitMandiResponse<>(LocalDateTime.now(), request.getRequestURL().toString(), HttpStatus.OK.toString(), HttpStatus.OK, ResponseStatus.SUCCESS, roleRepository.selectAll());
72
			return new ResponseEntity<>(profitMandiResponse,HttpStatus.OK);
43
		return new ResponseEntity<>(profitMandiResponse,HttpStatus.OK);
73
		}catch (Exception e) {
-
 
74
			LOGGER.error("Internal Server Error : ",e);
-
 
75
			final Response response=new Response("","","", e.getMessage());
-
 
76
			final ProfitMandiResponse<Response> chatOnResponse=new ProfitMandiResponse<Response>(LocalDateTime.now(), request.getRequestURL().toString(), HttpStatus.INTERNAL_SERVER_ERROR.toString(), HttpStatus.INTERNAL_SERVER_ERROR, ResponseStatus.FAILURE, response);
-
 
77
			return new ResponseEntity<>(chatOnResponse,HttpStatus.INTERNAL_SERVER_ERROR);
-
 
78
		}
-
 
79
	}
44
	}
80
	
45
	
81
	@RequestMapping(value = ProfitMandiConstants.URL_ROLE_ID,method=RequestMethod.GET)
46
	@RequestMapping(value = ProfitMandiConstants.URL_ROLE_ID,method=RequestMethod.GET)
82
	public ResponseEntity<?> getById(HttpServletRequest request, @RequestParam(name = "id") int id){
47
	public ResponseEntity<?> getById(HttpServletRequest request, @RequestParam(name = "id") long id){
83
		LOGGER.info("requested url : "+request.getRequestURL().toString());
48
		LOGGER.info("requested url : "+request.getRequestURL().toString());
84
		try {
49
		try {
85
			final ProfitMandiResponse<?> profitMandiResponse=new ProfitMandiResponse<>(LocalDateTime.now(), request.getRequestURL().toString(), HttpStatus.OK.toString(), HttpStatus.OK, ResponseStatus.SUCCESS, roleRepository.selectById(id));
50
			final ProfitMandiResponse<?> profitMandiResponse=new ProfitMandiResponse<>(LocalDateTime.now(), request.getRequestURL().toString(), HttpStatus.OK.toString(), HttpStatus.OK, ResponseStatus.SUCCESS, roleRepository.selectById(id));
86
			return new ResponseEntity<>(profitMandiResponse,HttpStatus.OK);
51
			return new ResponseEntity<>(profitMandiResponse,HttpStatus.OK);
87
		}catch (ProfitMandiBusinessException pmbe) {
52
		}catch (ProfitMandiBusinessException pmbe) {
88
			LOGGER.error("ProfitMandi error: ", pmbe);
53
			LOGGER.error("ProfitMandi error: ", pmbe);
89
			final Response response=new Response(pmbe.getRejectedType(), pmbe.getRejectedValue(),pmbe.getCode(), pmbe.getMessage());
54
			final Response response=new Response(pmbe.getRejectedType(), pmbe.getRejectedValue(),pmbe.getCode(), pmbe.getMessage());
90
			final ProfitMandiResponse<Response> chatOnResponse=new ProfitMandiResponse<Response>(LocalDateTime.now(), request.getRequestURL().toString(), HttpStatus.BAD_REQUEST.toString(), HttpStatus.BAD_REQUEST, ResponseStatus.FAILURE, response);
55
			final ProfitMandiResponse<Response> chatOnResponse=new ProfitMandiResponse<Response>(LocalDateTime.now(), request.getRequestURL().toString(), HttpStatus.BAD_REQUEST.toString(), HttpStatus.BAD_REQUEST, ResponseStatus.FAILURE, response);
91
			return new ResponseEntity<>(chatOnResponse,HttpStatus.BAD_REQUEST);
56
			return new ResponseEntity<>(chatOnResponse,HttpStatus.BAD_REQUEST);
92
		}catch (Exception e) {
-
 
93
			LOGGER.error("Internal Server Error: ", e);
-
 
94
			final Response response=new Response("","","", e.getMessage());
-
 
95
			final ProfitMandiResponse<Response> chatOnResponse=new ProfitMandiResponse<Response>(LocalDateTime.now(), request.getRequestURL().toString(), HttpStatus.INTERNAL_SERVER_ERROR.toString(), HttpStatus.INTERNAL_SERVER_ERROR, ResponseStatus.FAILURE, response);
-
 
96
			return new ResponseEntity<>(chatOnResponse,HttpStatus.INTERNAL_SERVER_ERROR);
-
 
97
		}
57
		}
98
	}
58
	}
99
	
59
	
100
	@RequestMapping(value = ProfitMandiConstants.URL_ROLE_TYPE,method=RequestMethod.GET)
60
	@RequestMapping(value = ProfitMandiConstants.URL_ROLE_TYPE,method=RequestMethod.GET)
101
	public ResponseEntity<?> getByType(HttpServletRequest request, @RequestParam(name = "type") String typeName){
61
	public ResponseEntity<?> getByType(HttpServletRequest request, @RequestParam(name = "type") String typeName){
Line 107... Line 67...
107
		}catch (ProfitMandiBusinessException pmbe) {
67
		}catch (ProfitMandiBusinessException pmbe) {
108
			LOGGER.error("ProfitMandi error: ", pmbe);
68
			LOGGER.error("ProfitMandi error: ", pmbe);
109
			final Response response=new Response(pmbe.getRejectedType(), pmbe.getRejectedValue(),pmbe.getCode(), pmbe.getMessage());
69
			final Response response=new Response(pmbe.getRejectedType(), pmbe.getRejectedValue(),pmbe.getCode(), pmbe.getMessage());
110
			final ProfitMandiResponse<Response> chatOnResponse=new ProfitMandiResponse<Response>(LocalDateTime.now(), request.getRequestURL().toString(), HttpStatus.BAD_REQUEST.toString(), HttpStatus.BAD_REQUEST, ResponseStatus.FAILURE, response);
70
			final ProfitMandiResponse<Response> chatOnResponse=new ProfitMandiResponse<Response>(LocalDateTime.now(), request.getRequestURL().toString(), HttpStatus.BAD_REQUEST.toString(), HttpStatus.BAD_REQUEST, ResponseStatus.FAILURE, response);
111
			return new ResponseEntity<>(chatOnResponse,HttpStatus.BAD_REQUEST);
71
			return new ResponseEntity<>(chatOnResponse,HttpStatus.BAD_REQUEST);
112
		}catch (Exception e) {
-
 
113
			LOGGER.error("Internal Server Error: ", e);
-
 
114
			final Response response=new Response("","","", e.getMessage());
-
 
115
			final ProfitMandiResponse<Response> chatOnResponse=new ProfitMandiResponse<Response>(LocalDateTime.now(), request.getRequestURL().toString(), HttpStatus.INTERNAL_SERVER_ERROR.toString(), HttpStatus.INTERNAL_SERVER_ERROR, ResponseStatus.FAILURE, response);
-
 
116
			return new ResponseEntity<>(chatOnResponse, HttpStatus.INTERNAL_SERVER_ERROR);
-
 
117
		}
72
		}
118
	}
73
	}
119
	
74
	
120
	
75
	
121
	@RequestMapping(value = ProfitMandiConstants.URL_ROLE_NAME,method=RequestMethod.GET)
76
	@RequestMapping(value = ProfitMandiConstants.URL_ROLE_NAME,method=RequestMethod.GET)
Line 127... Line 82...
127
		}catch (ProfitMandiBusinessException pmbe) {
82
		}catch (ProfitMandiBusinessException pmbe) {
128
			LOGGER.error("ProfitMandi error: ", pmbe);
83
			LOGGER.error("ProfitMandi error: ", pmbe);
129
			final Response response=new Response(pmbe.getRejectedType(), pmbe.getRejectedValue(),pmbe.getCode(), pmbe.getMessage());
84
			final Response response=new Response(pmbe.getRejectedType(), pmbe.getRejectedValue(),pmbe.getCode(), pmbe.getMessage());
130
			final ProfitMandiResponse<Response> chatOnResponse=new ProfitMandiResponse<Response>(LocalDateTime.now(), request.getRequestURL().toString(), HttpStatus.BAD_REQUEST.toString(), HttpStatus.BAD_REQUEST, ResponseStatus.FAILURE, response);
85
			final ProfitMandiResponse<Response> chatOnResponse=new ProfitMandiResponse<Response>(LocalDateTime.now(), request.getRequestURL().toString(), HttpStatus.BAD_REQUEST.toString(), HttpStatus.BAD_REQUEST, ResponseStatus.FAILURE, response);
131
			return new ResponseEntity<>(chatOnResponse,HttpStatus.BAD_REQUEST);
86
			return new ResponseEntity<>(chatOnResponse,HttpStatus.BAD_REQUEST);
132
		}catch (Exception e) {
-
 
133
			LOGGER.error("Internal Server Error: ", e);
-
 
134
			final Response response=new Response("","","", e.getMessage());
-
 
135
			final ProfitMandiResponse<Response> chatOnResponse=new ProfitMandiResponse<Response>(LocalDateTime.now(), request.getRequestURL().toString(), HttpStatus.INTERNAL_SERVER_ERROR.toString(), HttpStatus.INTERNAL_SERVER_ERROR, ResponseStatus.FAILURE, response);
-
 
136
			return new ResponseEntity<>(chatOnResponse, HttpStatus.INTERNAL_SERVER_ERROR);
-
 
137
		}
87
		}
138
	}
88
	}
139
	
89
	
140
	@RequestMapping(value = ProfitMandiConstants.URL_ROLE_ID,method=RequestMethod.DELETE)
90
	@RequestMapping(value = ProfitMandiConstants.URL_ROLE_ID,method=RequestMethod.DELETE)
141
	public ResponseEntity<?> deleteById(HttpServletRequest request, @RequestParam(name = "id") int id){
91
	public ResponseEntity<?> deleteById(HttpServletRequest request, @RequestParam(name = "id") long id){
142
		LOGGER.info("requested url : "+request.getRequestURL().toString());
92
		LOGGER.info("requested url : "+request.getRequestURL().toString());
143
		try {
93
		try {
144
			roleRepository.deleteById(id);
94
			roleRepository.deleteById(id);
145
			final ProfitMandiResponse<?> profitMandiResponse=new ProfitMandiResponse<>(LocalDateTime.now(), request.getRequestURL().toString(), HttpStatus.OK.toString(), HttpStatus.OK, ResponseStatus.SUCCESS, ResponseCodeHolder.getMessage("ROL_OK_1001"));
95
			final ProfitMandiResponse<?> profitMandiResponse=new ProfitMandiResponse<>(LocalDateTime.now(), request.getRequestURL().toString(), HttpStatus.OK.toString(), HttpStatus.OK, ResponseStatus.SUCCESS, ResponseCodeHolder.getMessage("ROL_OK_1001"));
146
			return new ResponseEntity<>(profitMandiResponse,HttpStatus.OK);
96
			return new ResponseEntity<>(profitMandiResponse,HttpStatus.OK);
147
		}catch (ProfitMandiBusinessException pmbe) {
97
		}catch (ProfitMandiBusinessException pmbe) {
148
			LOGGER.error("ProfitMandi error: ", pmbe);
98
			LOGGER.error("ProfitMandi error: ", pmbe);
149
			final Response response=new Response(pmbe.getRejectedType(), pmbe.getRejectedValue(),pmbe.getCode(), pmbe.getMessage());
99
			final Response response=new Response(pmbe.getRejectedType(), pmbe.getRejectedValue(),pmbe.getCode(), pmbe.getMessage());
150
			final ProfitMandiResponse<Response> chatOnResponse=new ProfitMandiResponse<Response>(LocalDateTime.now(), request.getRequestURL().toString(), HttpStatus.BAD_REQUEST.toString(), HttpStatus.BAD_REQUEST, ResponseStatus.FAILURE, response);
100
			final ProfitMandiResponse<Response> chatOnResponse=new ProfitMandiResponse<Response>(LocalDateTime.now(), request.getRequestURL().toString(), HttpStatus.BAD_REQUEST.toString(), HttpStatus.BAD_REQUEST, ResponseStatus.FAILURE, response);
151
			return new ResponseEntity<>(chatOnResponse,HttpStatus.BAD_REQUEST);
101
			return new ResponseEntity<>(chatOnResponse,HttpStatus.BAD_REQUEST);
152
		}catch (Exception e) {
-
 
153
			LOGGER.error("Internal Server Error: ", e);
-
 
154
			final Response response=new Response("","","", e.getMessage());
-
 
155
			final ProfitMandiResponse<Response> chatOnResponse=new ProfitMandiResponse<Response>(LocalDateTime.now(), request.getRequestURL().toString(), HttpStatus.INTERNAL_SERVER_ERROR.toString(), HttpStatus.INTERNAL_SERVER_ERROR, ResponseStatus.FAILURE, response);
-
 
156
			return new ResponseEntity<>(chatOnResponse,HttpStatus.INTERNAL_SERVER_ERROR);
-
 
157
		}
-
 
158
	}
-
 
159
	
-
 
160
	@SuppressWarnings("unchecked")
-
 
161
	@RequestMapping(value = ProfitMandiConstants.URL_ROLE, method = RequestMethod.PUT)
-
 
162
	public ResponseEntity<?> updateRole(HttpServletRequest request){
-
 
163
		LOGGER.info("requested url : "+request.getRequestURL().toString());
-
 
164
		final Map<String, Object> map = (Map<String, Object>)request.getAttribute("updateRoleMap");
-
 
165
		request.removeAttribute("updateRoleMap");
-
 
166
		try {
-
 
167
			roleRepository.updateById(map.get(ProfitMandiConstants.NAME).toString(), (RoleType)map.get(ProfitMandiConstants.TYPE), (Integer)map.get(ProfitMandiConstants.ID));
-
 
168
			final ProfitMandiResponse<?> profitMandiResponse=new ProfitMandiResponse<>(LocalDateTime.now(), request.getRequestURL().toString(), HttpStatus.OK.toString(), HttpStatus.OK, ResponseStatus.SUCCESS, ResponseCodeHolder.getMessage("ROL_OK_1000"));
-
 
169
			return new ResponseEntity<>(profitMandiResponse, HttpStatus.OK);
-
 
170
		}catch (ProfitMandiBusinessException pmbe) {
-
 
171
			LOGGER.error("ProfitMandi error: ", pmbe);
-
 
172
			final Response response=new Response(pmbe.getRejectedType(), pmbe.getRejectedValue(),pmbe.getCode(), pmbe.getMessage());
-
 
173
			final ProfitMandiResponse<Response> chatOnResponse=new ProfitMandiResponse<Response>(LocalDateTime.now(), request.getRequestURL().toString(), HttpStatus.BAD_REQUEST.toString(), HttpStatus.BAD_REQUEST, ResponseStatus.FAILURE, response);
-
 
174
			return new ResponseEntity<>(chatOnResponse,HttpStatus.BAD_REQUEST);
-
 
175
		}catch (Exception e) {
-
 
176
			LOGGER.error("Internal Server Error : ",e);
-
 
177
			final Response response=new Response("","","", e.getMessage());
-
 
178
			final ProfitMandiResponse<Response> chatOnResponse=new ProfitMandiResponse<Response>(LocalDateTime.now(), request.getRequestURL().toString(), HttpStatus.INTERNAL_SERVER_ERROR.toString(), HttpStatus.INTERNAL_SERVER_ERROR, ResponseStatus.FAILURE, response);
-
 
179
			return new ResponseEntity<>(chatOnResponse,HttpStatus.INTERNAL_SERVER_ERROR);
-
 
180
		}
-
 
181
	}
-
 
182
	
-
 
183
	@RequestMapping(value = ProfitMandiConstants.URL_ROLE_API_BY_ID_WITH_NAME, method = RequestMethod.PUT)
-
 
184
	public ResponseEntity<?> addApiByIdWithName(HttpServletRequest request, @RequestParam(name = "apiId") int id, @RequestParam(name = "roleName") String name){
-
 
185
		LOGGER.info("requested url : "+request.getRequestURL().toString());
-
 
186
		try {
-
 
187
			roleRepository.addByIdWithName(id, name);
-
 
188
			final ProfitMandiResponse<?> profitMandiResponse=new ProfitMandiResponse<>(LocalDateTime.now(), request.getRequestURL().toString(), HttpStatus.OK.toString(), HttpStatus.OK, ResponseStatus.SUCCESS, ResponseCodeHolder.getMessage("ROL_OK_1001"));
-
 
189
			return new ResponseEntity<>(profitMandiResponse, HttpStatus.OK);
-
 
190
		}catch (ProfitMandiBusinessException pmbe) {
-
 
191
			LOGGER.error("ProfitMandi error: ", pmbe);
-
 
192
			final Response response=new Response(pmbe.getRejectedType(), pmbe.getRejectedValue(),pmbe.getCode(), pmbe.getMessage());
-
 
193
			final ProfitMandiResponse<Response> chatOnResponse=new ProfitMandiResponse<Response>(LocalDateTime.now(), request.getRequestURL().toString(), HttpStatus.BAD_REQUEST.toString(), HttpStatus.BAD_REQUEST, ResponseStatus.FAILURE, response);
-
 
194
			return new ResponseEntity<>(chatOnResponse,HttpStatus.BAD_REQUEST);
-
 
195
		}catch (Exception e) {
-
 
196
			LOGGER.error("Internal Server Error : ",e);
-
 
197
			final Response response=new Response("","","", e.getMessage());
-
 
198
			final ProfitMandiResponse<Response> chatOnResponse=new ProfitMandiResponse<Response>(LocalDateTime.now(), request.getRequestURL().toString(), HttpStatus.INTERNAL_SERVER_ERROR.toString(), HttpStatus.INTERNAL_SERVER_ERROR, ResponseStatus.FAILURE, response);
-
 
199
			return new ResponseEntity<>(chatOnResponse,HttpStatus.INTERNAL_SERVER_ERROR);
-
 
200
		}
-
 
201
	}
-
 
202
	
-
 
203
	@RequestMapping(value = ProfitMandiConstants.URL_ROLE_API_BY_NAME_WITH_NAME, method = RequestMethod.PUT)
-
 
204
	public ResponseEntity<?> addApiByNameWithName(HttpServletRequest request, @RequestParam(name = "apiName") String apiName, @RequestParam(name = "roleName") String roleName){
-
 
205
		LOGGER.info("requested url : "+request.getRequestURL().toString());
-
 
206
		try {
-
 
207
			roleRepository.addByNameWithName(apiName, roleName);
-
 
208
			final ProfitMandiResponse<?> profitMandiResponse=new ProfitMandiResponse<>(LocalDateTime.now(), request.getRequestURL().toString(), HttpStatus.OK.toString(), HttpStatus.OK, ResponseStatus.SUCCESS, ResponseCodeHolder.getMessage("ROL_OK_1001"));
-
 
209
			return new ResponseEntity<>(profitMandiResponse, HttpStatus.OK);
-
 
210
		}catch (ProfitMandiBusinessException pmbe) {
-
 
211
			LOGGER.error("ProfitMandi error: ", pmbe);
-
 
212
			final Response response=new Response(pmbe.getRejectedType(), pmbe.getRejectedValue(),pmbe.getCode(), pmbe.getMessage());
-
 
213
			final ProfitMandiResponse<Response> chatOnResponse=new ProfitMandiResponse<Response>(LocalDateTime.now(), request.getRequestURL().toString(), HttpStatus.BAD_REQUEST.toString(), HttpStatus.BAD_REQUEST, ResponseStatus.FAILURE, response);
-
 
214
			return new ResponseEntity<>(chatOnResponse,HttpStatus.BAD_REQUEST);
-
 
215
		}catch (Exception e) {
-
 
216
			LOGGER.error("Internal Server Error : ",e);
-
 
217
			final Response response=new Response("","","", e.getMessage());
-
 
218
			final ProfitMandiResponse<Response> chatOnResponse=new ProfitMandiResponse<Response>(LocalDateTime.now(), request.getRequestURL().toString(), HttpStatus.INTERNAL_SERVER_ERROR.toString(), HttpStatus.INTERNAL_SERVER_ERROR, ResponseStatus.FAILURE, response);
-
 
219
			return new ResponseEntity<>(chatOnResponse,HttpStatus.INTERNAL_SERVER_ERROR);
-
 
220
		}
-
 
221
	}
-
 
222
	
-
 
223
	@RequestMapping(value = ProfitMandiConstants.URL_ROLE_API_BY_ID_WITH_ID, method = RequestMethod.PUT)
-
 
224
	public ResponseEntity<?> addApiByIdWithId(HttpServletRequest request, @RequestParam(name = "apiId") int apiId, @RequestParam(name = "roleId") int roleId){
-
 
225
		LOGGER.info("requested url : "+request.getRequestURL().toString());
-
 
226
		try {
-
 
227
			roleRepository.addByIdWithId(apiId, roleId);
-
 
228
			final ProfitMandiResponse<?> profitMandiResponse=new ProfitMandiResponse<>(LocalDateTime.now(), request.getRequestURL().toString(), HttpStatus.OK.toString(), HttpStatus.OK, ResponseStatus.SUCCESS, ResponseCodeHolder.getMessage("ROL_OK_1001"));
-
 
229
			return new ResponseEntity<>(profitMandiResponse, HttpStatus.OK);
-
 
230
		}catch (ProfitMandiBusinessException pmbe) {
-
 
231
			LOGGER.error("ProfitMandi error: ", pmbe);
-
 
232
			final Response response=new Response(pmbe.getRejectedType(), pmbe.getRejectedValue(),pmbe.getCode(), pmbe.getMessage());
-
 
233
			final ProfitMandiResponse<Response> chatOnResponse=new ProfitMandiResponse<Response>(LocalDateTime.now(), request.getRequestURL().toString(), HttpStatus.BAD_REQUEST.toString(), HttpStatus.BAD_REQUEST, ResponseStatus.FAILURE, response);
-
 
234
			return new ResponseEntity<>(chatOnResponse,HttpStatus.BAD_REQUEST);
-
 
235
		}catch (Exception e) {
-
 
236
			LOGGER.error("Internal Server Error : ",e);
-
 
237
			final Response response=new Response("","","", e.getMessage());
-
 
238
			final ProfitMandiResponse<Response> chatOnResponse=new ProfitMandiResponse<Response>(LocalDateTime.now(), request.getRequestURL().toString(), HttpStatus.INTERNAL_SERVER_ERROR.toString(), HttpStatus.INTERNAL_SERVER_ERROR, ResponseStatus.FAILURE, response);
-
 
239
			return new ResponseEntity<>(chatOnResponse,HttpStatus.INTERNAL_SERVER_ERROR);
-
 
240
		}
-
 
241
	}
-
 
242
	
-
 
243
	@RequestMapping(value = ProfitMandiConstants.URL_ROLE_API_BY_NAME_WITH_ID, method = RequestMethod.PUT)
-
 
244
	public ResponseEntity<?> addApiByNameWithId(HttpServletRequest request, @RequestParam(name = "apiName") String name, @RequestParam(name = "roleId") int id){
-
 
245
		LOGGER.info("requested url : "+request.getRequestURL().toString());
-
 
246
		try {
-
 
247
			roleRepository.addByNameWithId(name, id);
-
 
248
			final ProfitMandiResponse<?> profitMandiResponse=new ProfitMandiResponse<>(LocalDateTime.now(), request.getRequestURL().toString(), HttpStatus.OK.toString(), HttpStatus.OK, ResponseStatus.SUCCESS, ResponseCodeHolder.getMessage("ROL_OK_1001"));
-
 
249
			return new ResponseEntity<>(profitMandiResponse, HttpStatus.OK);
-
 
250
		}catch (ProfitMandiBusinessException pmbe) {
-
 
251
			LOGGER.error("ProfitMandi error: ", pmbe);
-
 
252
			final Response response=new Response(pmbe.getRejectedType(), pmbe.getRejectedValue(),pmbe.getCode(), pmbe.getMessage());
-
 
253
			final ProfitMandiResponse<Response> chatOnResponse=new ProfitMandiResponse<Response>(LocalDateTime.now(), request.getRequestURL().toString(), HttpStatus.BAD_REQUEST.toString(), HttpStatus.BAD_REQUEST, ResponseStatus.FAILURE, response);
-
 
254
			return new ResponseEntity<>(chatOnResponse,HttpStatus.BAD_REQUEST);
-
 
255
		}catch (Exception e) {
-
 
256
			LOGGER.error("Internal Server Error : ",e);
-
 
257
			final Response response=new Response("","","", e.getMessage());
-
 
258
			final ProfitMandiResponse<Response> chatOnResponse=new ProfitMandiResponse<Response>(LocalDateTime.now(), request.getRequestURL().toString(), HttpStatus.INTERNAL_SERVER_ERROR.toString(), HttpStatus.INTERNAL_SERVER_ERROR, ResponseStatus.FAILURE, response);
-
 
259
			return new ResponseEntity<>(chatOnResponse,HttpStatus.INTERNAL_SERVER_ERROR);
-
 
260
		}
102
		}
261
	}
103
	}
262
	
104
	
263
	
105
	
264
	@RequestMapping(value = ProfitMandiConstants.URL_ROLE_API_BY_ID_WITH_NAME, method = RequestMethod.DELETE)
-
 
265
	public ResponseEntity<?> removeApiByIdWithName(HttpServletRequest request, @RequestParam(name = "apiId") int id, @RequestParam(name = "roleName") String name){
-
 
266
		LOGGER.info("requested url : "+request.getRequestURL().toString());
-
 
267
		try {
-
 
268
			roleRepository.deleteByIdWithName(id, name);
-
 
269
			final ProfitMandiResponse<?> profitMandiResponse=new ProfitMandiResponse<>(LocalDateTime.now(), request.getRequestURL().toString(), HttpStatus.OK.toString(), HttpStatus.OK, ResponseStatus.SUCCESS, ResponseCodeHolder.getMessage("ROL_OK_1002"));
-
 
270
			return new ResponseEntity<>(profitMandiResponse, HttpStatus.OK);
-
 
271
		}catch (ProfitMandiBusinessException pmbe) {
-
 
272
			LOGGER.error("ProfitMandi error: ", pmbe);
-
 
273
			final Response response=new Response(pmbe.getRejectedType(), pmbe.getRejectedValue(),pmbe.getCode(), pmbe.getMessage());
-
 
274
			final ProfitMandiResponse<Response> chatOnResponse=new ProfitMandiResponse<Response>(LocalDateTime.now(), request.getRequestURL().toString(), HttpStatus.BAD_REQUEST.toString(), HttpStatus.BAD_REQUEST, ResponseStatus.FAILURE, response);
-
 
275
			return new ResponseEntity<>(chatOnResponse,HttpStatus.BAD_REQUEST);
-
 
276
		}catch (Exception e) {
-
 
277
			LOGGER.error("Internal Server Error : ",e);
-
 
278
			final Response response=new Response("","","", e.getMessage());
-
 
279
			final ProfitMandiResponse<Response> chatOnResponse=new ProfitMandiResponse<Response>(LocalDateTime.now(), request.getRequestURL().toString(), HttpStatus.INTERNAL_SERVER_ERROR.toString(), HttpStatus.INTERNAL_SERVER_ERROR, ResponseStatus.FAILURE, response);
-
 
280
			return new ResponseEntity<>(chatOnResponse,HttpStatus.INTERNAL_SERVER_ERROR);
-
 
281
		}
-
 
282
	}
-
 
283
	
-
 
284
	@RequestMapping(value = ProfitMandiConstants.URL_ROLE_API_BY_NAME_WITH_NAME, method = RequestMethod.DELETE)
-
 
285
	public ResponseEntity<?> removeApiByNameWithName(HttpServletRequest request, @RequestParam(name = "apiName") String apiName, @RequestParam(name = "roleName") String roleName){
-
 
286
		LOGGER.info("requested url : "+request.getRequestURL().toString());
-
 
287
		try {
-
 
288
			roleRepository.deleteByNameWithName(apiName, roleName);
-
 
289
			final ProfitMandiResponse<?> profitMandiResponse=new ProfitMandiResponse<>(LocalDateTime.now(), request.getRequestURL().toString(), HttpStatus.OK.toString(), HttpStatus.OK, ResponseStatus.SUCCESS, ResponseCodeHolder.getMessage("ROL_OK_1002"));
-
 
290
			return new ResponseEntity<>(profitMandiResponse, HttpStatus.OK);
-
 
291
		}catch (ProfitMandiBusinessException pmbe) {
-
 
292
			LOGGER.error("ProfitMandi error: ", pmbe);
-
 
293
			final Response response=new Response(pmbe.getRejectedType(), pmbe.getRejectedValue(),pmbe.getCode(), pmbe.getMessage());
-
 
294
			final ProfitMandiResponse<Response> chatOnResponse=new ProfitMandiResponse<Response>(LocalDateTime.now(), request.getRequestURL().toString(), HttpStatus.BAD_REQUEST.toString(), HttpStatus.BAD_REQUEST, ResponseStatus.FAILURE, response);
-
 
295
			return new ResponseEntity<>(chatOnResponse,HttpStatus.BAD_REQUEST);
-
 
296
		}catch (Exception e) {
-
 
297
			LOGGER.error("Internal Server Error : ",e);
-
 
298
			final Response response=new Response("","","", e.getMessage());
-
 
299
			final ProfitMandiResponse<Response> chatOnResponse=new ProfitMandiResponse<Response>(LocalDateTime.now(), request.getRequestURL().toString(), HttpStatus.INTERNAL_SERVER_ERROR.toString(), HttpStatus.INTERNAL_SERVER_ERROR, ResponseStatus.FAILURE, response);
-
 
300
			return new ResponseEntity<>(chatOnResponse,HttpStatus.INTERNAL_SERVER_ERROR);
-
 
301
		}
-
 
302
	}
-
 
303
	
-
 
304
	@RequestMapping(value = ProfitMandiConstants.URL_ROLE_API_BY_ID_WITH_ID, method = RequestMethod.DELETE)
-
 
305
	public ResponseEntity<?> removeApiByIdWithId(HttpServletRequest request, @RequestParam(name = "apiId") int apiId, @RequestParam(name = "roleId") int roleId){
-
 
306
		LOGGER.info("requested url : "+request.getRequestURL().toString());
-
 
307
		try {
-
 
308
			roleRepository.deleteByIdWithId(apiId, roleId);
-
 
309
			final ProfitMandiResponse<?> profitMandiResponse=new ProfitMandiResponse<>(LocalDateTime.now(), request.getRequestURL().toString(), HttpStatus.OK.toString(), HttpStatus.OK, ResponseStatus.SUCCESS, ResponseCodeHolder.getMessage("ROL_OK_1002"));
-
 
310
			return new ResponseEntity<>(profitMandiResponse, HttpStatus.OK);
-
 
311
		}catch (ProfitMandiBusinessException pmbe) {
-
 
312
			LOGGER.error("ProfitMandi error: ", pmbe);
-
 
313
			final Response response=new Response(pmbe.getRejectedType(), pmbe.getRejectedValue(),pmbe.getCode(), pmbe.getMessage());
-
 
314
			final ProfitMandiResponse<Response> chatOnResponse=new ProfitMandiResponse<Response>(LocalDateTime.now(), request.getRequestURL().toString(), HttpStatus.BAD_REQUEST.toString(), HttpStatus.BAD_REQUEST, ResponseStatus.FAILURE, response);
-
 
315
			return new ResponseEntity<>(chatOnResponse,HttpStatus.BAD_REQUEST);
-
 
316
		}catch (Exception e) {
-
 
317
			LOGGER.error("Internal Server Error : ",e);
-
 
318
			final Response response=new Response("","","", e.getMessage());
-
 
319
			final ProfitMandiResponse<Response> chatOnResponse=new ProfitMandiResponse<Response>(LocalDateTime.now(), request.getRequestURL().toString(), HttpStatus.INTERNAL_SERVER_ERROR.toString(), HttpStatus.INTERNAL_SERVER_ERROR, ResponseStatus.FAILURE, response);
-
 
320
			return new ResponseEntity<>(chatOnResponse,HttpStatus.INTERNAL_SERVER_ERROR);
-
 
321
		}
-
 
322
	}
-
 
323
	
-
 
324
	@RequestMapping(value = ProfitMandiConstants.URL_ROLE_API_BY_NAME_WITH_ID, method = RequestMethod.DELETE)
-
 
325
	public ResponseEntity<?> removeApiByNameWithId(HttpServletRequest request, @RequestParam(name = "apiName") String name, @RequestParam(name = "roleId") int id){
-
 
326
		LOGGER.info("requested url : "+request.getRequestURL().toString());
-
 
327
		try {
-
 
328
			roleRepository.deleteByNameWithId(name, id);
-
 
329
			final ProfitMandiResponse<?> profitMandiResponse=new ProfitMandiResponse<>(LocalDateTime.now(), request.getRequestURL().toString(), HttpStatus.OK.toString(), HttpStatus.OK, ResponseStatus.SUCCESS, ResponseCodeHolder.getMessage("ROL_OK_1002"));
-
 
330
			return new ResponseEntity<>(profitMandiResponse, HttpStatus.OK);
-
 
331
		}catch (ProfitMandiBusinessException pmbe) {
-
 
332
			LOGGER.error("ProfitMandi error: ", pmbe);
-
 
333
			final Response response=new Response(pmbe.getRejectedType(), pmbe.getRejectedValue(),pmbe.getCode(), pmbe.getMessage());
-
 
334
			final ProfitMandiResponse<Response> chatOnResponse=new ProfitMandiResponse<Response>(LocalDateTime.now(), request.getRequestURL().toString(), HttpStatus.BAD_REQUEST.toString(), HttpStatus.BAD_REQUEST, ResponseStatus.FAILURE, response);
-
 
335
			return new ResponseEntity<>(chatOnResponse,HttpStatus.BAD_REQUEST);
-
 
336
		}catch (Exception e) {
-
 
337
			LOGGER.error("Internal Server Error : ",e);
-
 
338
			final Response response=new Response("","","", e.getMessage());
-
 
339
			final ProfitMandiResponse<Response> chatOnResponse=new ProfitMandiResponse<Response>(LocalDateTime.now(), request.getRequestURL().toString(), HttpStatus.INTERNAL_SERVER_ERROR.toString(), HttpStatus.INTERNAL_SERVER_ERROR, ResponseStatus.FAILURE, response);
-
 
340
			return new ResponseEntity<>(chatOnResponse,HttpStatus.INTERNAL_SERVER_ERROR);
-
 
341
		}
-
 
342
	}
-
 
343
}
106
}