Rev 21278 | Blame | Last modification | View Log | RSS feed
package com.spice.profitmandi.web.controller;import java.time.LocalDateTime;import java.util.Map;import javax.servlet.http.HttpServletRequest;import org.slf4j.Logger;import org.slf4j.LoggerFactory;import org.springframework.beans.factory.annotation.Autowired;import org.springframework.http.HttpStatus;import org.springframework.http.ResponseEntity;import org.springframework.stereotype.Controller;import org.springframework.web.bind.annotation.RequestMapping;import org.springframework.web.bind.annotation.RequestMethod;import org.springframework.web.bind.annotation.RequestParam;import com.spice.profitmandi.common.ResponseCodeHolder;import com.spice.profitmandi.common.exception.ProfitMandiBusinessException;import com.spice.profitmandi.common.model.ProfitMandiConstants;import com.spice.profitmandi.common.util.StringUtils;import com.spice.profitmandi.dao.entity.Role;import com.spice.profitmandi.dao.enumuration.RoleType;import com.spice.profitmandi.dao.enumuration.Status;import com.spice.profitmandi.dao.repository.RoleRepository;import com.spice.profitmandi.web.model.ProfitMandiResponse;import com.spice.profitmandi.web.model.Response;import com.spice.profitmandi.web.model.ResponseStatus;/*** @author ashikali**/@Controllerpublic class RoleController {private static final Logger LOGGER=LoggerFactory.getLogger(RoleController.class);@AutowiredRoleRepository roleRepository;@RequestMapping(value = ProfitMandiConstants.URL_ROLE, method = RequestMethod.POST)public ResponseEntity<?> createRole(HttpServletRequest request){LOGGER.info("requested url : "+request.getRequestURL().toString());final Role role = (Role)request.getAttribute("role");request.removeAttribute("role");try {role.setStatus(Status.ACTIVE);role.setCreateTimestamp(LocalDateTime.now());role.setUpdateTimestamp(LocalDateTime.now());roleRepository.persist(role);final ProfitMandiResponse<?> profitMandiResponse=new ProfitMandiResponse<>(LocalDateTime.now(), request.getRequestURL().toString(), HttpStatus.OK.toString(), HttpStatus.OK, ResponseStatus.SUCCESS, ResponseCodeHolder.getMessage("ROL_OK_1000"));return new ResponseEntity<>(profitMandiResponse, HttpStatus.OK);}catch (ProfitMandiBusinessException pmbe) {LOGGER.error("ProfitMandi error: ", pmbe);final Response response=new Response(pmbe.getRejectedType(), pmbe.getRejectedValue(),pmbe.getCode(), pmbe.getMessage());final ProfitMandiResponse<Response> chatOnResponse=new ProfitMandiResponse<Response>(LocalDateTime.now(), request.getRequestURL().toString(), HttpStatus.BAD_REQUEST.toString(), HttpStatus.BAD_REQUEST, ResponseStatus.FAILURE, response);return new ResponseEntity<>(chatOnResponse,HttpStatus.BAD_REQUEST);}catch (Exception e) {LOGGER.error("Internal Server Error : ",e);final Response response=new Response("","","", e.getMessage());final ProfitMandiResponse<Response> chatOnResponse=new ProfitMandiResponse<Response>(LocalDateTime.now(), request.getRequestURL().toString(), HttpStatus.INTERNAL_SERVER_ERROR.toString(), HttpStatus.INTERNAL_SERVER_ERROR, ResponseStatus.FAILURE, response);return new ResponseEntity<>(chatOnResponse,HttpStatus.INTERNAL_SERVER_ERROR);}}@RequestMapping(value = ProfitMandiConstants.URL_ROLE_ALL,method=RequestMethod.GET)public ResponseEntity<?> getAll(HttpServletRequest request){LOGGER.info("requested url : "+request.getRequestURL().toString());try {final ProfitMandiResponse<?> profitMandiResponse=new ProfitMandiResponse<>(LocalDateTime.now(), request.getRequestURL().toString(), HttpStatus.OK.toString(), HttpStatus.OK, ResponseStatus.SUCCESS, roleRepository.selectAll());return new ResponseEntity<>(profitMandiResponse,HttpStatus.OK);}catch (Exception e) {LOGGER.error("Internal Server Error : ",e);final Response response=new Response("","","", e.getMessage());final ProfitMandiResponse<Response> chatOnResponse=new ProfitMandiResponse<Response>(LocalDateTime.now(), request.getRequestURL().toString(), HttpStatus.INTERNAL_SERVER_ERROR.toString(), HttpStatus.INTERNAL_SERVER_ERROR, ResponseStatus.FAILURE, response);return new ResponseEntity<>(chatOnResponse,HttpStatus.INTERNAL_SERVER_ERROR);}}@RequestMapping(value = ProfitMandiConstants.URL_ROLE_ID,method=RequestMethod.GET)public ResponseEntity<?> getById(HttpServletRequest request, @RequestParam(name = "id") int id){LOGGER.info("requested url : "+request.getRequestURL().toString());try {final ProfitMandiResponse<?> profitMandiResponse=new ProfitMandiResponse<>(LocalDateTime.now(), request.getRequestURL().toString(), HttpStatus.OK.toString(), HttpStatus.OK, ResponseStatus.SUCCESS, roleRepository.selectById(id));return new ResponseEntity<>(profitMandiResponse,HttpStatus.OK);}catch (ProfitMandiBusinessException pmbe) {LOGGER.error("ProfitMandi error: ", pmbe);final Response response=new Response(pmbe.getRejectedType(), pmbe.getRejectedValue(),pmbe.getCode(), pmbe.getMessage());final ProfitMandiResponse<Response> chatOnResponse=new ProfitMandiResponse<Response>(LocalDateTime.now(), request.getRequestURL().toString(), HttpStatus.BAD_REQUEST.toString(), HttpStatus.BAD_REQUEST, ResponseStatus.FAILURE, response);return new ResponseEntity<>(chatOnResponse,HttpStatus.BAD_REQUEST);}catch (Exception e) {LOGGER.error("Internal Server Error: ", e);final Response response=new Response("","","", e.getMessage());final ProfitMandiResponse<Response> chatOnResponse=new ProfitMandiResponse<Response>(LocalDateTime.now(), request.getRequestURL().toString(), HttpStatus.INTERNAL_SERVER_ERROR.toString(), HttpStatus.INTERNAL_SERVER_ERROR, ResponseStatus.FAILURE, response);return new ResponseEntity<>(chatOnResponse,HttpStatus.INTERNAL_SERVER_ERROR);}}@RequestMapping(value = ProfitMandiConstants.URL_ROLE_TYPE,method=RequestMethod.GET)public ResponseEntity<?> getByType(HttpServletRequest request, @RequestParam(name = "type") String typeName){LOGGER.info("requested url : "+request.getRequestURL().toString());try {RoleType roleType = StringUtils.toRoleType(typeName);final ProfitMandiResponse<?> profitMandiResponse=new ProfitMandiResponse<>(LocalDateTime.now(), request.getRequestURL().toString(), HttpStatus.OK.toString(), HttpStatus.OK, ResponseStatus.SUCCESS, roleRepository.selectByType(roleType));return new ResponseEntity<>(profitMandiResponse,HttpStatus.OK);}catch (ProfitMandiBusinessException pmbe) {LOGGER.error("ProfitMandi error: ", pmbe);final Response response=new Response(pmbe.getRejectedType(), pmbe.getRejectedValue(),pmbe.getCode(), pmbe.getMessage());final ProfitMandiResponse<Response> chatOnResponse=new ProfitMandiResponse<Response>(LocalDateTime.now(), request.getRequestURL().toString(), HttpStatus.BAD_REQUEST.toString(), HttpStatus.BAD_REQUEST, ResponseStatus.FAILURE, response);return new ResponseEntity<>(chatOnResponse,HttpStatus.BAD_REQUEST);}catch (Exception e) {LOGGER.error("Internal Server Error: ", e);final Response response=new Response("","","", e.getMessage());final ProfitMandiResponse<Response> chatOnResponse=new ProfitMandiResponse<Response>(LocalDateTime.now(), request.getRequestURL().toString(), HttpStatus.INTERNAL_SERVER_ERROR.toString(), HttpStatus.INTERNAL_SERVER_ERROR, ResponseStatus.FAILURE, response);return new ResponseEntity<>(chatOnResponse, HttpStatus.INTERNAL_SERVER_ERROR);}}@RequestMapping(value = ProfitMandiConstants.URL_ROLE_NAME,method=RequestMethod.GET)public ResponseEntity<?> getByName(HttpServletRequest request, @RequestParam(name = "name") String name){LOGGER.info("requested url : "+request.getRequestURL().toString());try {final ProfitMandiResponse<?> profitMandiResponse=new ProfitMandiResponse<>(LocalDateTime.now(), request.getRequestURL().toString(), HttpStatus.OK.toString(), HttpStatus.OK, ResponseStatus.SUCCESS, roleRepository.selectByName(name));return new ResponseEntity<>(profitMandiResponse,HttpStatus.OK);}catch (ProfitMandiBusinessException pmbe) {LOGGER.error("ProfitMandi error: ", pmbe);final Response response=new Response(pmbe.getRejectedType(), pmbe.getRejectedValue(),pmbe.getCode(), pmbe.getMessage());final ProfitMandiResponse<Response> chatOnResponse=new ProfitMandiResponse<Response>(LocalDateTime.now(), request.getRequestURL().toString(), HttpStatus.BAD_REQUEST.toString(), HttpStatus.BAD_REQUEST, ResponseStatus.FAILURE, response);return new ResponseEntity<>(chatOnResponse,HttpStatus.BAD_REQUEST);}catch (Exception e) {LOGGER.error("Internal Server Error: ", e);final Response response=new Response("","","", e.getMessage());final ProfitMandiResponse<Response> chatOnResponse=new ProfitMandiResponse<Response>(LocalDateTime.now(), request.getRequestURL().toString(), HttpStatus.INTERNAL_SERVER_ERROR.toString(), HttpStatus.INTERNAL_SERVER_ERROR, ResponseStatus.FAILURE, response);return new ResponseEntity<>(chatOnResponse, HttpStatus.INTERNAL_SERVER_ERROR);}}@RequestMapping(value = ProfitMandiConstants.URL_ROLE_ID,method=RequestMethod.DELETE)public ResponseEntity<?> deleteById(HttpServletRequest request, @RequestParam(name = "id") int id){LOGGER.info("requested url : "+request.getRequestURL().toString());try {roleRepository.deleteById(id);final ProfitMandiResponse<?> profitMandiResponse=new ProfitMandiResponse<>(LocalDateTime.now(), request.getRequestURL().toString(), HttpStatus.OK.toString(), HttpStatus.OK, ResponseStatus.SUCCESS, ResponseCodeHolder.getMessage("ROL_OK_1001"));return new ResponseEntity<>(profitMandiResponse,HttpStatus.OK);}catch (ProfitMandiBusinessException pmbe) {LOGGER.error("ProfitMandi error: ", pmbe);final Response response=new Response(pmbe.getRejectedType(), pmbe.getRejectedValue(),pmbe.getCode(), pmbe.getMessage());final ProfitMandiResponse<Response> chatOnResponse=new ProfitMandiResponse<Response>(LocalDateTime.now(), request.getRequestURL().toString(), HttpStatus.BAD_REQUEST.toString(), HttpStatus.BAD_REQUEST, ResponseStatus.FAILURE, response);return new ResponseEntity<>(chatOnResponse,HttpStatus.BAD_REQUEST);}catch (Exception e) {LOGGER.error("Internal Server Error: ", e);final Response response=new Response("","","", e.getMessage());final ProfitMandiResponse<Response> chatOnResponse=new ProfitMandiResponse<Response>(LocalDateTime.now(), request.getRequestURL().toString(), HttpStatus.INTERNAL_SERVER_ERROR.toString(), HttpStatus.INTERNAL_SERVER_ERROR, ResponseStatus.FAILURE, response);return new ResponseEntity<>(chatOnResponse,HttpStatus.INTERNAL_SERVER_ERROR);}}@SuppressWarnings("unchecked")@RequestMapping(value = ProfitMandiConstants.URL_ROLE, method = RequestMethod.PUT)public ResponseEntity<?> updateRole(HttpServletRequest request){LOGGER.info("requested url : "+request.getRequestURL().toString());final Map<String, Object> map = (Map<String, Object>)request.getAttribute("updateRoleMap");request.removeAttribute("updateRoleMap");try {roleRepository.updateById(map.get(ProfitMandiConstants.NAME).toString(), (RoleType)map.get(ProfitMandiConstants.TYPE), (Integer)map.get(ProfitMandiConstants.ID));final ProfitMandiResponse<?> profitMandiResponse=new ProfitMandiResponse<>(LocalDateTime.now(), request.getRequestURL().toString(), HttpStatus.OK.toString(), HttpStatus.OK, ResponseStatus.SUCCESS, ResponseCodeHolder.getMessage("ROL_OK_1000"));return new ResponseEntity<>(profitMandiResponse, HttpStatus.OK);}catch (ProfitMandiBusinessException pmbe) {LOGGER.error("ProfitMandi error: ", pmbe);final Response response=new Response(pmbe.getRejectedType(), pmbe.getRejectedValue(),pmbe.getCode(), pmbe.getMessage());final ProfitMandiResponse<Response> chatOnResponse=new ProfitMandiResponse<Response>(LocalDateTime.now(), request.getRequestURL().toString(), HttpStatus.BAD_REQUEST.toString(), HttpStatus.BAD_REQUEST, ResponseStatus.FAILURE, response);return new ResponseEntity<>(chatOnResponse,HttpStatus.BAD_REQUEST);}catch (Exception e) {LOGGER.error("Internal Server Error : ",e);final Response response=new Response("","","", e.getMessage());final ProfitMandiResponse<Response> chatOnResponse=new ProfitMandiResponse<Response>(LocalDateTime.now(), request.getRequestURL().toString(), HttpStatus.INTERNAL_SERVER_ERROR.toString(), HttpStatus.INTERNAL_SERVER_ERROR, ResponseStatus.FAILURE, response);return new ResponseEntity<>(chatOnResponse,HttpStatus.INTERNAL_SERVER_ERROR);}}@RequestMapping(value = ProfitMandiConstants.URL_ROLE_API_BY_ID_WITH_NAME, method = RequestMethod.PUT)public ResponseEntity<?> addApiByIdWithName(HttpServletRequest request, @RequestParam(name = "apiId") int id, @RequestParam(name = "roleName") String name){LOGGER.info("requested url : "+request.getRequestURL().toString());try {roleRepository.addByIdWithName(id, name);final ProfitMandiResponse<?> profitMandiResponse=new ProfitMandiResponse<>(LocalDateTime.now(), request.getRequestURL().toString(), HttpStatus.OK.toString(), HttpStatus.OK, ResponseStatus.SUCCESS, ResponseCodeHolder.getMessage("ROL_OK_1001"));return new ResponseEntity<>(profitMandiResponse, HttpStatus.OK);}catch (ProfitMandiBusinessException pmbe) {LOGGER.error("ProfitMandi error: ", pmbe);final Response response=new Response(pmbe.getRejectedType(), pmbe.getRejectedValue(),pmbe.getCode(), pmbe.getMessage());final ProfitMandiResponse<Response> chatOnResponse=new ProfitMandiResponse<Response>(LocalDateTime.now(), request.getRequestURL().toString(), HttpStatus.BAD_REQUEST.toString(), HttpStatus.BAD_REQUEST, ResponseStatus.FAILURE, response);return new ResponseEntity<>(chatOnResponse,HttpStatus.BAD_REQUEST);}catch (Exception e) {LOGGER.error("Internal Server Error : ",e);final Response response=new Response("","","", e.getMessage());final ProfitMandiResponse<Response> chatOnResponse=new ProfitMandiResponse<Response>(LocalDateTime.now(), request.getRequestURL().toString(), HttpStatus.INTERNAL_SERVER_ERROR.toString(), HttpStatus.INTERNAL_SERVER_ERROR, ResponseStatus.FAILURE, response);return new ResponseEntity<>(chatOnResponse,HttpStatus.INTERNAL_SERVER_ERROR);}}@RequestMapping(value = ProfitMandiConstants.URL_ROLE_API_BY_NAME_WITH_NAME, method = RequestMethod.PUT)public ResponseEntity<?> addApiByNameWithName(HttpServletRequest request, @RequestParam(name = "apiName") String apiName, @RequestParam(name = "roleName") String roleName){LOGGER.info("requested url : "+request.getRequestURL().toString());try {roleRepository.addByNameWithName(apiName, roleName);final ProfitMandiResponse<?> profitMandiResponse=new ProfitMandiResponse<>(LocalDateTime.now(), request.getRequestURL().toString(), HttpStatus.OK.toString(), HttpStatus.OK, ResponseStatus.SUCCESS, ResponseCodeHolder.getMessage("ROL_OK_1001"));return new ResponseEntity<>(profitMandiResponse, HttpStatus.OK);}catch (ProfitMandiBusinessException pmbe) {LOGGER.error("ProfitMandi error: ", pmbe);final Response response=new Response(pmbe.getRejectedType(), pmbe.getRejectedValue(),pmbe.getCode(), pmbe.getMessage());final ProfitMandiResponse<Response> chatOnResponse=new ProfitMandiResponse<Response>(LocalDateTime.now(), request.getRequestURL().toString(), HttpStatus.BAD_REQUEST.toString(), HttpStatus.BAD_REQUEST, ResponseStatus.FAILURE, response);return new ResponseEntity<>(chatOnResponse,HttpStatus.BAD_REQUEST);}catch (Exception e) {LOGGER.error("Internal Server Error : ",e);final Response response=new Response("","","", e.getMessage());final ProfitMandiResponse<Response> chatOnResponse=new ProfitMandiResponse<Response>(LocalDateTime.now(), request.getRequestURL().toString(), HttpStatus.INTERNAL_SERVER_ERROR.toString(), HttpStatus.INTERNAL_SERVER_ERROR, ResponseStatus.FAILURE, response);return new ResponseEntity<>(chatOnResponse,HttpStatus.INTERNAL_SERVER_ERROR);}}@RequestMapping(value = ProfitMandiConstants.URL_ROLE_API_BY_ID_WITH_ID, method = RequestMethod.PUT)public ResponseEntity<?> addApiByIdWithId(HttpServletRequest request, @RequestParam(name = "apiId") int apiId, @RequestParam(name = "roleId") int roleId){LOGGER.info("requested url : "+request.getRequestURL().toString());try {roleRepository.addByIdWithId(apiId, roleId);final ProfitMandiResponse<?> profitMandiResponse=new ProfitMandiResponse<>(LocalDateTime.now(), request.getRequestURL().toString(), HttpStatus.OK.toString(), HttpStatus.OK, ResponseStatus.SUCCESS, ResponseCodeHolder.getMessage("ROL_OK_1001"));return new ResponseEntity<>(profitMandiResponse, HttpStatus.OK);}catch (ProfitMandiBusinessException pmbe) {LOGGER.error("ProfitMandi error: ", pmbe);final Response response=new Response(pmbe.getRejectedType(), pmbe.getRejectedValue(),pmbe.getCode(), pmbe.getMessage());final ProfitMandiResponse<Response> chatOnResponse=new ProfitMandiResponse<Response>(LocalDateTime.now(), request.getRequestURL().toString(), HttpStatus.BAD_REQUEST.toString(), HttpStatus.BAD_REQUEST, ResponseStatus.FAILURE, response);return new ResponseEntity<>(chatOnResponse,HttpStatus.BAD_REQUEST);}catch (Exception e) {LOGGER.error("Internal Server Error : ",e);final Response response=new Response("","","", e.getMessage());final ProfitMandiResponse<Response> chatOnResponse=new ProfitMandiResponse<Response>(LocalDateTime.now(), request.getRequestURL().toString(), HttpStatus.INTERNAL_SERVER_ERROR.toString(), HttpStatus.INTERNAL_SERVER_ERROR, ResponseStatus.FAILURE, response);return new ResponseEntity<>(chatOnResponse,HttpStatus.INTERNAL_SERVER_ERROR);}}@RequestMapping(value = ProfitMandiConstants.URL_ROLE_API_BY_NAME_WITH_ID, method = RequestMethod.PUT)public ResponseEntity<?> addApiByNameWithId(HttpServletRequest request, @RequestParam(name = "apiName") String name, @RequestParam(name = "roleId") int id){LOGGER.info("requested url : "+request.getRequestURL().toString());try {roleRepository.addByNameWithId(name, id);final ProfitMandiResponse<?> profitMandiResponse=new ProfitMandiResponse<>(LocalDateTime.now(), request.getRequestURL().toString(), HttpStatus.OK.toString(), HttpStatus.OK, ResponseStatus.SUCCESS, ResponseCodeHolder.getMessage("ROL_OK_1001"));return new ResponseEntity<>(profitMandiResponse, HttpStatus.OK);}catch (ProfitMandiBusinessException pmbe) {LOGGER.error("ProfitMandi error: ", pmbe);final Response response=new Response(pmbe.getRejectedType(), pmbe.getRejectedValue(),pmbe.getCode(), pmbe.getMessage());final ProfitMandiResponse<Response> chatOnResponse=new ProfitMandiResponse<Response>(LocalDateTime.now(), request.getRequestURL().toString(), HttpStatus.BAD_REQUEST.toString(), HttpStatus.BAD_REQUEST, ResponseStatus.FAILURE, response);return new ResponseEntity<>(chatOnResponse,HttpStatus.BAD_REQUEST);}catch (Exception e) {LOGGER.error("Internal Server Error : ",e);final Response response=new Response("","","", e.getMessage());final ProfitMandiResponse<Response> chatOnResponse=new ProfitMandiResponse<Response>(LocalDateTime.now(), request.getRequestURL().toString(), HttpStatus.INTERNAL_SERVER_ERROR.toString(), HttpStatus.INTERNAL_SERVER_ERROR, ResponseStatus.FAILURE, response);return new ResponseEntity<>(chatOnResponse,HttpStatus.INTERNAL_SERVER_ERROR);}}@RequestMapping(value = ProfitMandiConstants.URL_ROLE_API_BY_ID_WITH_NAME, method = RequestMethod.DELETE)public ResponseEntity<?> removeApiByIdWithName(HttpServletRequest request, @RequestParam(name = "apiId") int id, @RequestParam(name = "roleName") String name){LOGGER.info("requested url : "+request.getRequestURL().toString());try {roleRepository.deleteByIdWithName(id, name);final ProfitMandiResponse<?> profitMandiResponse=new ProfitMandiResponse<>(LocalDateTime.now(), request.getRequestURL().toString(), HttpStatus.OK.toString(), HttpStatus.OK, ResponseStatus.SUCCESS, ResponseCodeHolder.getMessage("ROL_OK_1002"));return new ResponseEntity<>(profitMandiResponse, HttpStatus.OK);}catch (ProfitMandiBusinessException pmbe) {LOGGER.error("ProfitMandi error: ", pmbe);final Response response=new Response(pmbe.getRejectedType(), pmbe.getRejectedValue(),pmbe.getCode(), pmbe.getMessage());final ProfitMandiResponse<Response> chatOnResponse=new ProfitMandiResponse<Response>(LocalDateTime.now(), request.getRequestURL().toString(), HttpStatus.BAD_REQUEST.toString(), HttpStatus.BAD_REQUEST, ResponseStatus.FAILURE, response);return new ResponseEntity<>(chatOnResponse,HttpStatus.BAD_REQUEST);}catch (Exception e) {LOGGER.error("Internal Server Error : ",e);final Response response=new Response("","","", e.getMessage());final ProfitMandiResponse<Response> chatOnResponse=new ProfitMandiResponse<Response>(LocalDateTime.now(), request.getRequestURL().toString(), HttpStatus.INTERNAL_SERVER_ERROR.toString(), HttpStatus.INTERNAL_SERVER_ERROR, ResponseStatus.FAILURE, response);return new ResponseEntity<>(chatOnResponse,HttpStatus.INTERNAL_SERVER_ERROR);}}@RequestMapping(value = ProfitMandiConstants.URL_ROLE_API_BY_NAME_WITH_NAME, method = RequestMethod.DELETE)public ResponseEntity<?> removeApiByNameWithName(HttpServletRequest request, @RequestParam(name = "apiName") String apiName, @RequestParam(name = "roleName") String roleName){LOGGER.info("requested url : "+request.getRequestURL().toString());try {roleRepository.deleteByNameWithName(apiName, roleName);final ProfitMandiResponse<?> profitMandiResponse=new ProfitMandiResponse<>(LocalDateTime.now(), request.getRequestURL().toString(), HttpStatus.OK.toString(), HttpStatus.OK, ResponseStatus.SUCCESS, ResponseCodeHolder.getMessage("ROL_OK_1002"));return new ResponseEntity<>(profitMandiResponse, HttpStatus.OK);}catch (ProfitMandiBusinessException pmbe) {LOGGER.error("ProfitMandi error: ", pmbe);final Response response=new Response(pmbe.getRejectedType(), pmbe.getRejectedValue(),pmbe.getCode(), pmbe.getMessage());final ProfitMandiResponse<Response> chatOnResponse=new ProfitMandiResponse<Response>(LocalDateTime.now(), request.getRequestURL().toString(), HttpStatus.BAD_REQUEST.toString(), HttpStatus.BAD_REQUEST, ResponseStatus.FAILURE, response);return new ResponseEntity<>(chatOnResponse,HttpStatus.BAD_REQUEST);}catch (Exception e) {LOGGER.error("Internal Server Error : ",e);final Response response=new Response("","","", e.getMessage());final ProfitMandiResponse<Response> chatOnResponse=new ProfitMandiResponse<Response>(LocalDateTime.now(), request.getRequestURL().toString(), HttpStatus.INTERNAL_SERVER_ERROR.toString(), HttpStatus.INTERNAL_SERVER_ERROR, ResponseStatus.FAILURE, response);return new ResponseEntity<>(chatOnResponse,HttpStatus.INTERNAL_SERVER_ERROR);}}@RequestMapping(value = ProfitMandiConstants.URL_ROLE_API_BY_ID_WITH_ID, method = RequestMethod.DELETE)public ResponseEntity<?> removeApiByIdWithId(HttpServletRequest request, @RequestParam(name = "apiId") int apiId, @RequestParam(name = "roleId") int roleId){LOGGER.info("requested url : "+request.getRequestURL().toString());try {roleRepository.deleteByIdWithId(apiId, roleId);final ProfitMandiResponse<?> profitMandiResponse=new ProfitMandiResponse<>(LocalDateTime.now(), request.getRequestURL().toString(), HttpStatus.OK.toString(), HttpStatus.OK, ResponseStatus.SUCCESS, ResponseCodeHolder.getMessage("ROL_OK_1002"));return new ResponseEntity<>(profitMandiResponse, HttpStatus.OK);}catch (ProfitMandiBusinessException pmbe) {LOGGER.error("ProfitMandi error: ", pmbe);final Response response=new Response(pmbe.getRejectedType(), pmbe.getRejectedValue(),pmbe.getCode(), pmbe.getMessage());final ProfitMandiResponse<Response> chatOnResponse=new ProfitMandiResponse<Response>(LocalDateTime.now(), request.getRequestURL().toString(), HttpStatus.BAD_REQUEST.toString(), HttpStatus.BAD_REQUEST, ResponseStatus.FAILURE, response);return new ResponseEntity<>(chatOnResponse,HttpStatus.BAD_REQUEST);}catch (Exception e) {LOGGER.error("Internal Server Error : ",e);final Response response=new Response("","","", e.getMessage());final ProfitMandiResponse<Response> chatOnResponse=new ProfitMandiResponse<Response>(LocalDateTime.now(), request.getRequestURL().toString(), HttpStatus.INTERNAL_SERVER_ERROR.toString(), HttpStatus.INTERNAL_SERVER_ERROR, ResponseStatus.FAILURE, response);return new ResponseEntity<>(chatOnResponse,HttpStatus.INTERNAL_SERVER_ERROR);}}@RequestMapping(value = ProfitMandiConstants.URL_ROLE_API_BY_NAME_WITH_ID, method = RequestMethod.DELETE)public ResponseEntity<?> removeApiByNameWithId(HttpServletRequest request, @RequestParam(name = "apiName") String name, @RequestParam(name = "roleId") int id){LOGGER.info("requested url : "+request.getRequestURL().toString());try {roleRepository.deleteByNameWithId(name, id);final ProfitMandiResponse<?> profitMandiResponse=new ProfitMandiResponse<>(LocalDateTime.now(), request.getRequestURL().toString(), HttpStatus.OK.toString(), HttpStatus.OK, ResponseStatus.SUCCESS, ResponseCodeHolder.getMessage("ROL_OK_1002"));return new ResponseEntity<>(profitMandiResponse, HttpStatus.OK);}catch (ProfitMandiBusinessException pmbe) {LOGGER.error("ProfitMandi error: ", pmbe);final Response response=new Response(pmbe.getRejectedType(), pmbe.getRejectedValue(),pmbe.getCode(), pmbe.getMessage());final ProfitMandiResponse<Response> chatOnResponse=new ProfitMandiResponse<Response>(LocalDateTime.now(), request.getRequestURL().toString(), HttpStatus.BAD_REQUEST.toString(), HttpStatus.BAD_REQUEST, ResponseStatus.FAILURE, response);return new ResponseEntity<>(chatOnResponse,HttpStatus.BAD_REQUEST);}catch (Exception e) {LOGGER.error("Internal Server Error : ",e);final Response response=new Response("","","", e.getMessage());final ProfitMandiResponse<Response> chatOnResponse=new ProfitMandiResponse<Response>(LocalDateTime.now(), request.getRequestURL().toString(), HttpStatus.INTERNAL_SERVER_ERROR.toString(), HttpStatus.INTERNAL_SERVER_ERROR, ResponseStatus.FAILURE, response);return new ResponseEntity<>(chatOnResponse,HttpStatus.INTERNAL_SERVER_ERROR);}}}