| Line 13... |
Line 13... |
| 13 |
import org.springframework.web.bind.annotation.RequestMapping;
|
13 |
import org.springframework.web.bind.annotation.RequestMapping;
|
| 14 |
import org.springframework.web.bind.annotation.RequestMethod;
|
14 |
import org.springframework.web.bind.annotation.RequestMethod;
|
| 15 |
import org.springframework.web.bind.annotation.RequestParam;
|
15 |
import org.springframework.web.bind.annotation.RequestParam;
|
| 16 |
|
16 |
|
| 17 |
import com.spice.profitmandi.common.ResponseCodeHolder;
|
17 |
import com.spice.profitmandi.common.ResponseCodeHolder;
|
| - |
|
18 |
import com.spice.profitmandi.common.exception.ProfitMandiBusinessException;
|
| 18 |
import com.spice.profitmandi.common.model.ProfitMandiConstants;
|
19 |
import com.spice.profitmandi.common.model.ProfitMandiConstants;
|
| - |
|
20 |
import com.spice.profitmandi.common.util.StringUtils;
|
| 19 |
import com.spice.profitmandi.dao.entity.Role;
|
21 |
import com.spice.profitmandi.dao.entity.Role;
|
| 20 |
import com.spice.profitmandi.dao.enumuration.PricePermission;
|
22 |
import com.spice.profitmandi.dao.enumuration.PricePermission;
|
| 21 |
import com.spice.profitmandi.dao.enumuration.RoleType;
|
23 |
import com.spice.profitmandi.dao.enumuration.RoleType;
|
| 22 |
import com.spice.profitmandi.dao.exception.EntityAlreadyExistException;
|
- |
|
| 23 |
import com.spice.profitmandi.dao.exception.EntityNotFoundException;
|
24 |
import com.spice.profitmandi.dao.enumuration.Status;
|
| 24 |
import com.spice.profitmandi.dao.repository.RoleRepository;
|
25 |
import com.spice.profitmandi.dao.repository.RoleRepository;
|
| 25 |
import com.spice.profitmandi.dao.repository.RoleRepositoryImpl;
|
26 |
import com.spice.profitmandi.dao.repository.RoleRepositoryImpl;
|
| 26 |
import com.spice.profitmandi.web.model.ProfitMandiResponse;
|
27 |
import com.spice.profitmandi.web.model.ProfitMandiResponse;
|
| 27 |
import com.spice.profitmandi.web.model.Response;
|
28 |
import com.spice.profitmandi.web.model.Response;
|
| 28 |
import com.spice.profitmandi.web.model.ResponseStatus;
|
29 |
import com.spice.profitmandi.web.model.ResponseStatus;
|
| 29 |
|
30 |
|
| - |
|
31 |
/**
|
| - |
|
32 |
* @author ashikali
|
| - |
|
33 |
*
|
| - |
|
34 |
*/
|
| 30 |
@Controller
|
35 |
@Controller
|
| 31 |
public class RoleController {
|
36 |
public class RoleController {
|
| 32 |
|
37 |
|
| 33 |
private static final Logger LOGGER=LoggerFactory.getLogger(RoleController.class);
|
38 |
private static final Logger LOGGER=LoggerFactory.getLogger(RoleController.class);
|
| 34 |
|
39 |
|
| Line 38... |
Line 43... |
| 38 |
public ResponseEntity<?> createRole(HttpServletRequest request){
|
43 |
public ResponseEntity<?> createRole(HttpServletRequest request){
|
| 39 |
LOGGER.info("requested url : "+request.getRequestURL().toString());
|
44 |
LOGGER.info("requested url : "+request.getRequestURL().toString());
|
| 40 |
final Role role = (Role)request.getAttribute("role");
|
45 |
final Role role = (Role)request.getAttribute("role");
|
| 41 |
request.removeAttribute("role");
|
46 |
request.removeAttribute("role");
|
| 42 |
try {
|
47 |
try {
|
| - |
|
48 |
role.setStatus(Status.ACTIVE);
|
| 43 |
role.setCreateTimestamp(LocalDateTime.now());
|
49 |
role.setCreateTimestamp(LocalDateTime.now());
|
| 44 |
role.setUpdateTimestamp(LocalDateTime.now());
|
50 |
role.setUpdateTimestamp(LocalDateTime.now());
|
| 45 |
roleRepository.persist(role);
|
51 |
roleRepository.persist(role);
|
| 46 |
final ProfitMandiResponse<?> profitMandiResponse=new ProfitMandiResponse<>(LocalDateTime.now(), request.getRequestURL().toString(), HttpStatus.OK.toString(), HttpStatus.OK, ResponseStatus.SUCCESS, ResponseCodeHolder.getMessage("ROL_OK_1000"));
|
52 |
final ProfitMandiResponse<?> profitMandiResponse=new ProfitMandiResponse<>(LocalDateTime.now(), request.getRequestURL().toString(), HttpStatus.OK.toString(), HttpStatus.OK, ResponseStatus.SUCCESS, ResponseCodeHolder.getMessage("ROL_OK_1000"));
|
| 47 |
return new ResponseEntity<>(profitMandiResponse, HttpStatus.OK);
|
53 |
return new ResponseEntity<>(profitMandiResponse, HttpStatus.OK);
|
| 48 |
}catch (EntityAlreadyExistException eaee) {
|
54 |
}catch (ProfitMandiBusinessException pmbe) {
|
| 49 |
LOGGER.error("Role already exist: ", eaee);
|
55 |
LOGGER.error("ProfitMandi error: ", pmbe);
|
| 50 |
final Response response=new Response(eaee.getRejectedType(), eaee.getRejectedValue(),eaee.getCode(), eaee.getMessage());
|
56 |
final Response response=new Response(pmbe.getRejectedType(), pmbe.getRejectedValue(),pmbe.getCode(), pmbe.getMessage());
|
| 51 |
final ProfitMandiResponse<Response> chatOnResponse=new ProfitMandiResponse<Response>(LocalDateTime.now(), request.getRequestURL().toString(), HttpStatus.BAD_REQUEST.toString(), HttpStatus.BAD_REQUEST, ResponseStatus.FAILURE, response);
|
57 |
final ProfitMandiResponse<Response> chatOnResponse=new ProfitMandiResponse<Response>(LocalDateTime.now(), request.getRequestURL().toString(), HttpStatus.BAD_REQUEST.toString(), HttpStatus.BAD_REQUEST, ResponseStatus.FAILURE, response);
|
| 52 |
return new ResponseEntity<>(chatOnResponse,HttpStatus.BAD_REQUEST);
|
58 |
return new ResponseEntity<>(chatOnResponse,HttpStatus.BAD_REQUEST);
|
| 53 |
}catch (Exception e) {
|
59 |
}catch (Exception e) {
|
| 54 |
LOGGER.error("Internal Server Error : ",e);
|
60 |
LOGGER.error("Internal Server Error : ",e);
|
| 55 |
final Response response=new Response("","","", e.getMessage());
|
61 |
final Response response=new Response("","","", e.getMessage());
|
| Line 76... |
Line 82... |
| 76 |
public ResponseEntity<?> getById(HttpServletRequest request, @RequestParam(name = "id") long id){
|
82 |
public ResponseEntity<?> getById(HttpServletRequest request, @RequestParam(name = "id") long id){
|
| 77 |
LOGGER.info("requested url : "+request.getRequestURL().toString());
|
83 |
LOGGER.info("requested url : "+request.getRequestURL().toString());
|
| 78 |
try {
|
84 |
try {
|
| 79 |
final ProfitMandiResponse<?> profitMandiResponse=new ProfitMandiResponse<>(LocalDateTime.now(), request.getRequestURL().toString(), HttpStatus.OK.toString(), HttpStatus.OK, ResponseStatus.SUCCESS, roleRepository.selectById(id));
|
85 |
final ProfitMandiResponse<?> profitMandiResponse=new ProfitMandiResponse<>(LocalDateTime.now(), request.getRequestURL().toString(), HttpStatus.OK.toString(), HttpStatus.OK, ResponseStatus.SUCCESS, roleRepository.selectById(id));
|
| 80 |
return new ResponseEntity<>(profitMandiResponse,HttpStatus.OK);
|
86 |
return new ResponseEntity<>(profitMandiResponse,HttpStatus.OK);
|
| 81 |
}catch (EntityNotFoundException enfe) {
|
87 |
}catch (ProfitMandiBusinessException pmbe) {
|
| 82 |
LOGGER.error("Role not found: ", enfe);
|
88 |
LOGGER.error("ProfitMandi error: ", pmbe);
|
| 83 |
final Response response=new Response(enfe.getRejectedType(), enfe.getRejectedValue(),enfe.getCode(), enfe.getMessage());
|
89 |
final Response response=new Response(pmbe.getRejectedType(), pmbe.getRejectedValue(),pmbe.getCode(), pmbe.getMessage());
|
| 84 |
final ProfitMandiResponse<Response> chatOnResponse=new ProfitMandiResponse<Response>(LocalDateTime.now(), request.getRequestURL().toString(), HttpStatus.BAD_REQUEST.toString(), HttpStatus.BAD_REQUEST, ResponseStatus.FAILURE, response);
|
90 |
final ProfitMandiResponse<Response> chatOnResponse=new ProfitMandiResponse<Response>(LocalDateTime.now(), request.getRequestURL().toString(), HttpStatus.BAD_REQUEST.toString(), HttpStatus.BAD_REQUEST, ResponseStatus.FAILURE, response);
|
| 85 |
return new ResponseEntity<>(chatOnResponse,HttpStatus.BAD_REQUEST);
|
91 |
return new ResponseEntity<>(chatOnResponse,HttpStatus.BAD_REQUEST);
|
| 86 |
}catch (Exception e) {
|
92 |
}catch (Exception e) {
|
| 87 |
LOGGER.error("Internal Server Error: ", e);
|
93 |
LOGGER.error("Internal Server Error: ", e);
|
| 88 |
final Response response=new Response("","","", e.getMessage());
|
94 |
final Response response=new Response("","","", e.getMessage());
|
| 89 |
final ProfitMandiResponse<Response> chatOnResponse=new ProfitMandiResponse<Response>(LocalDateTime.now(), request.getRequestURL().toString(), HttpStatus.INTERNAL_SERVER_ERROR.toString(), HttpStatus.INTERNAL_SERVER_ERROR, ResponseStatus.FAILURE, response);
|
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);
|
| 90 |
return new ResponseEntity<>(chatOnResponse,HttpStatus.INTERNAL_SERVER_ERROR);
|
96 |
return new ResponseEntity<>(chatOnResponse,HttpStatus.INTERNAL_SERVER_ERROR);
|
| 91 |
}
|
97 |
}
|
| 92 |
}
|
98 |
}
|
| 93 |
|
99 |
|
| - |
|
100 |
@RequestMapping(value = ProfitMandiConstants.URL_ROLE_TYPE,method=RequestMethod.GET)
|
| - |
|
101 |
public ResponseEntity<?> getByType(HttpServletRequest request, @RequestParam(name = "type") String typeName){
|
| - |
|
102 |
LOGGER.info("requested url : "+request.getRequestURL().toString());
|
| - |
|
103 |
try {
|
| - |
|
104 |
RoleType roleType = StringUtils.toRoleType(typeName);
|
| - |
|
105 |
final ProfitMandiResponse<?> profitMandiResponse=new ProfitMandiResponse<>(LocalDateTime.now(), request.getRequestURL().toString(), HttpStatus.OK.toString(), HttpStatus.OK, ResponseStatus.SUCCESS, roleRepository.selectByType(roleType));
|
| - |
|
106 |
return new ResponseEntity<>(profitMandiResponse,HttpStatus.OK);
|
| - |
|
107 |
}catch (ProfitMandiBusinessException pmbe) {
|
| - |
|
108 |
LOGGER.error("ProfitMandi error: ", pmbe);
|
| - |
|
109 |
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);
|
| - |
|
111 |
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 |
}
|
| - |
|
118 |
}
|
| - |
|
119 |
|
| - |
|
120 |
|
| 94 |
@RequestMapping(value = ProfitMandiConstants.URL_ROLE_NAME,method=RequestMethod.GET)
|
121 |
@RequestMapping(value = ProfitMandiConstants.URL_ROLE_NAME,method=RequestMethod.GET)
|
| 95 |
public ResponseEntity<?> getByName(HttpServletRequest request, @RequestParam(name = "name") String name){
|
122 |
public ResponseEntity<?> getByName(HttpServletRequest request, @RequestParam(name = "name") String name){
|
| 96 |
LOGGER.info("requested url : "+request.getRequestURL().toString());
|
123 |
LOGGER.info("requested url : "+request.getRequestURL().toString());
|
| 97 |
try {
|
124 |
try {
|
| 98 |
final ProfitMandiResponse<?> profitMandiResponse=new ProfitMandiResponse<>(LocalDateTime.now(), request.getRequestURL().toString(), HttpStatus.OK.toString(), HttpStatus.OK, ResponseStatus.SUCCESS, roleRepository.selectByName(name));
|
125 |
final ProfitMandiResponse<?> profitMandiResponse=new ProfitMandiResponse<>(LocalDateTime.now(), request.getRequestURL().toString(), HttpStatus.OK.toString(), HttpStatus.OK, ResponseStatus.SUCCESS, roleRepository.selectByName(name));
|
| 99 |
return new ResponseEntity<>(profitMandiResponse,HttpStatus.OK);
|
126 |
return new ResponseEntity<>(profitMandiResponse,HttpStatus.OK);
|
| - |
|
127 |
}catch (ProfitMandiBusinessException pmbe) {
|
| - |
|
128 |
LOGGER.error("ProfitMandi error: ", pmbe);
|
| - |
|
129 |
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);
|
| - |
|
131 |
return new ResponseEntity<>(chatOnResponse,HttpStatus.BAD_REQUEST);
|
| 100 |
}catch (Exception e) {
|
132 |
}catch (Exception e) {
|
| 101 |
LOGGER.error("Internal Server Error: ", e);
|
133 |
LOGGER.error("Internal Server Error: ", e);
|
| 102 |
final Response response=new Response("","","", e.getMessage());
|
134 |
final Response response=new Response("","","", e.getMessage());
|
| 103 |
final ProfitMandiResponse<Response> chatOnResponse=new ProfitMandiResponse<Response>(LocalDateTime.now(), request.getRequestURL().toString(), HttpStatus.INTERNAL_SERVER_ERROR.toString(), HttpStatus.INTERNAL_SERVER_ERROR, ResponseStatus.FAILURE, response);
|
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);
|
| 104 |
return new ResponseEntity<>(chatOnResponse, HttpStatus.INTERNAL_SERVER_ERROR);
|
136 |
return new ResponseEntity<>(chatOnResponse, HttpStatus.INTERNAL_SERVER_ERROR);
|
| Line 110... |
Line 142... |
| 110 |
LOGGER.info("requested url : "+request.getRequestURL().toString());
|
142 |
LOGGER.info("requested url : "+request.getRequestURL().toString());
|
| 111 |
try {
|
143 |
try {
|
| 112 |
roleRepository.deleteById(id);
|
144 |
roleRepository.deleteById(id);
|
| 113 |
final ProfitMandiResponse<?> profitMandiResponse=new ProfitMandiResponse<>(LocalDateTime.now(), request.getRequestURL().toString(), HttpStatus.OK.toString(), HttpStatus.OK, ResponseStatus.SUCCESS, ResponseCodeHolder.getMessage("ROL_OK_1001"));
|
145 |
final ProfitMandiResponse<?> profitMandiResponse=new ProfitMandiResponse<>(LocalDateTime.now(), request.getRequestURL().toString(), HttpStatus.OK.toString(), HttpStatus.OK, ResponseStatus.SUCCESS, ResponseCodeHolder.getMessage("ROL_OK_1001"));
|
| 114 |
return new ResponseEntity<>(profitMandiResponse,HttpStatus.OK);
|
146 |
return new ResponseEntity<>(profitMandiResponse,HttpStatus.OK);
|
| 115 |
}catch (EntityNotFoundException enfe) {
|
147 |
}catch (ProfitMandiBusinessException pmbe) {
|
| 116 |
LOGGER.error("Role not found: ", enfe);
|
148 |
LOGGER.error("ProfitMandi error: ", pmbe);
|
| 117 |
final Response response=new Response(enfe.getRejectedType(), enfe.getRejectedValue(),enfe.getCode(), enfe.getMessage());
|
149 |
final Response response=new Response(pmbe.getRejectedType(), pmbe.getRejectedValue(),pmbe.getCode(), pmbe.getMessage());
|
| 118 |
final ProfitMandiResponse<Response> chatOnResponse=new ProfitMandiResponse<Response>(LocalDateTime.now(), request.getRequestURL().toString(), HttpStatus.BAD_REQUEST.toString(), HttpStatus.BAD_REQUEST, ResponseStatus.FAILURE, response);
|
150 |
final ProfitMandiResponse<Response> chatOnResponse=new ProfitMandiResponse<Response>(LocalDateTime.now(), request.getRequestURL().toString(), HttpStatus.BAD_REQUEST.toString(), HttpStatus.BAD_REQUEST, ResponseStatus.FAILURE, response);
|
| 119 |
return new ResponseEntity<>(chatOnResponse,HttpStatus.BAD_REQUEST);
|
151 |
return new ResponseEntity<>(chatOnResponse,HttpStatus.BAD_REQUEST);
|
| 120 |
}catch (Exception e) {
|
152 |
}catch (Exception e) {
|
| 121 |
LOGGER.error("Internal Server Error: ", e);
|
153 |
LOGGER.error("Internal Server Error: ", e);
|
| 122 |
final Response response=new Response("","","", e.getMessage());
|
154 |
final Response response=new Response("","","", e.getMessage());
|
| Line 133... |
Line 165... |
| 133 |
request.removeAttribute("updateRoleMap");
|
165 |
request.removeAttribute("updateRoleMap");
|
| 134 |
try {
|
166 |
try {
|
| 135 |
roleRepository.updateById(map.get(ProfitMandiConstants.NAME).toString(), (RoleType)map.get(ProfitMandiConstants.TYPE), (PricePermission)map.get(ProfitMandiConstants.PRICE_PERMISSION), (Long)map.get(ProfitMandiConstants.ID));
|
167 |
roleRepository.updateById(map.get(ProfitMandiConstants.NAME).toString(), (RoleType)map.get(ProfitMandiConstants.TYPE), (PricePermission)map.get(ProfitMandiConstants.PRICE_PERMISSION), (Long)map.get(ProfitMandiConstants.ID));
|
| 136 |
final ProfitMandiResponse<?> profitMandiResponse=new ProfitMandiResponse<>(LocalDateTime.now(), request.getRequestURL().toString(), HttpStatus.OK.toString(), HttpStatus.OK, ResponseStatus.SUCCESS, ResponseCodeHolder.getMessage("ROL_OK_1000"));
|
168 |
final ProfitMandiResponse<?> profitMandiResponse=new ProfitMandiResponse<>(LocalDateTime.now(), request.getRequestURL().toString(), HttpStatus.OK.toString(), HttpStatus.OK, ResponseStatus.SUCCESS, ResponseCodeHolder.getMessage("ROL_OK_1000"));
|
| 137 |
return new ResponseEntity<>(profitMandiResponse, HttpStatus.OK);
|
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());
|
| 138 |
}catch (EntityNotFoundException enfe) {
|
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") long 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());
|
| 139 |
LOGGER.error("Role not found: ", enfe);
|
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") long apiId, @RequestParam(name = "roleId") long 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());
|
| 140 |
final Response response=new Response(enfe.getRejectedType(), enfe.getRejectedValue(),enfe.getCode(), enfe.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") long 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());
|
| 141 |
final ProfitMandiResponse<Response> chatOnResponse=new ProfitMandiResponse<Response>(LocalDateTime.now(), request.getRequestURL().toString(), HttpStatus.BAD_REQUEST.toString(), HttpStatus.BAD_REQUEST, ResponseStatus.FAILURE, response);
|
253 |
final ProfitMandiResponse<Response> chatOnResponse=new ProfitMandiResponse<Response>(LocalDateTime.now(), request.getRequestURL().toString(), HttpStatus.BAD_REQUEST.toString(), HttpStatus.BAD_REQUEST, ResponseStatus.FAILURE, response);
|
| 142 |
return new ResponseEntity<>(chatOnResponse,HttpStatus.BAD_REQUEST);
|
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());
|
| 143 |
}catch (EntityAlreadyExistException eaee) {
|
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 |
}
|
| - |
|
261 |
}
|
| - |
|
262 |
|
| - |
|
263 |
|
| - |
|
264 |
@RequestMapping(value = ProfitMandiConstants.URL_ROLE_API_BY_ID_WITH_NAME, method = RequestMethod.DELETE)
|
| - |
|
265 |
public ResponseEntity<?> removeApiByIdWithName(HttpServletRequest request, @RequestParam(name = "apiId") long 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) {
|
| 144 |
LOGGER.error("Role already exist: ", eaee);
|
272 |
LOGGER.error("ProfitMandi error: ", pmbe);
|
| 145 |
final Response response=new Response(eaee.getRejectedType(), eaee.getRejectedValue(),eaee.getCode(), eaee.getMessage());
|
273 |
final Response response=new Response(pmbe.getRejectedType(), pmbe.getRejectedValue(),pmbe.getCode(), pmbe.getMessage());
|
| 146 |
final ProfitMandiResponse<Response> chatOnResponse=new ProfitMandiResponse<Response>(LocalDateTime.now(), request.getRequestURL().toString(), HttpStatus.BAD_REQUEST.toString(), HttpStatus.BAD_REQUEST, ResponseStatus.FAILURE, response);
|
274 |
final ProfitMandiResponse<Response> chatOnResponse=new ProfitMandiResponse<Response>(LocalDateTime.now(), request.getRequestURL().toString(), HttpStatus.BAD_REQUEST.toString(), HttpStatus.BAD_REQUEST, ResponseStatus.FAILURE, response);
|
| 147 |
return new ResponseEntity<>(chatOnResponse,HttpStatus.BAD_REQUEST);
|
275 |
return new ResponseEntity<>(chatOnResponse,HttpStatus.BAD_REQUEST);
|
| 148 |
}catch (Exception e) {
|
276 |
}catch (Exception e) {
|
| 149 |
LOGGER.error("Internal Server Error : ",e);
|
277 |
LOGGER.error("Internal Server Error : ",e);
|
| 150 |
final Response response=new Response("","","", e.getMessage());
|
278 |
final Response response=new Response("","","", e.getMessage());
|
| 151 |
final ProfitMandiResponse<Response> chatOnResponse=new ProfitMandiResponse<Response>(LocalDateTime.now(), request.getRequestURL().toString(), HttpStatus.INTERNAL_SERVER_ERROR.toString(), HttpStatus.INTERNAL_SERVER_ERROR, ResponseStatus.FAILURE, response);
|
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);
|
| 152 |
return new ResponseEntity<>(chatOnResponse,HttpStatus.INTERNAL_SERVER_ERROR);
|
280 |
return new ResponseEntity<>(chatOnResponse,HttpStatus.INTERNAL_SERVER_ERROR);
|
| 153 |
}
|
281 |
}
|
| 154 |
}
|
282 |
}
|
| 155 |
|
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") long apiId, @RequestParam(name = "roleId") long 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") long 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 |
}
|
| 156 |
}
|
343 |
}
|