List of usage examples for org.springframework.dao DuplicateKeyException toString
public String toString()
From source file:com.poscoict.license.web.controller.ExceptionControllerAdvice.java
@ExceptionHandler(DuplicateKeyException.class) public ModelAndView handleDuplicateKeyException(DuplicateKeyException ex) { logger.error(ex.toString()); ModelAndView mv = new ModelAndView(DEFAULT_ERROR_VIEW); mv.addObject("name", ex.getClass().getSimpleName()); mv.addObject("message", "? ?. ?? ? ."); return mv;//w ww. j av a 2s.co m }
From source file:com.trenako.web.controllers.RollingStocksController.java
@RequestMapping(method = RequestMethod.POST) public String create(@ModelAttribute @Valid RollingStockForm form, BindingResult bindingResult, ModelMap model, RedirectAttributes redirectAtts) { MultipartFile file = form.getFile(); RollingStock rs = form.buildRollingStock(valuesService, secContext, new Date()); if (bindingResult.hasErrors()) { model.addAttribute(rejectForm(form, valuesService)); return "rollingstock/new"; }//w w w .j ava2 s . c om try { service.createNew(rs); if (!file.isEmpty()) { imgService.saveImageWithThumb(UploadRequest.create(rs, file), 100); } redirectAtts.addFlashAttribute("message", ROLLING_STOCK_CREATED_MSG); redirectAtts.addAttribute("slug", rs.getSlug()); return "redirect:/rollingstocks/{slug}"; } catch (DuplicateKeyException duplEx) { log.error(duplEx.toString()); model.addAttribute(newForm(rs, valuesService)); model.addAttribute("message", ROLLING_STOCK_DUPLICATED_VALUE_MSG); return "rollingstock/new"; } catch (DataAccessException dataEx) { log.error(dataEx.toString()); model.addAttribute(newForm(rs, valuesService)); model.addAttribute("message", ROLLING_STOCK_DATABASE_ERROR_MSG); return "rollingstock/new"; } }
From source file:eu.dasish.annotation.backend.rest.PrincipalResource.java
/** * It is a convenience method limiting proliferation of user profiles, however * the method is currently not used till security issues will be discussed with the LAT * system administrators.//from w w w . j av a2s .com * @param remoteId a shibboleth remote id, which will be set as a basic-authentication remote id as well. * @param password a shibboleth password which will be set as a basic-authentication password. * @return a message about amount of records; which must be 2 if everything goes well: * 1 record for the "principal" table, 1is for the "authorities" tabl. * @throws IOException if sending an error fails. */ @POST @Consumes(MediaType.APPLICATION_FORM_URLENCODED) @Produces(MediaType.TEXT_PLAIN) @Path("register/shibbolethasnonshibboleth") public String registerShibbolizedPrincipalAsNonShibb(@FormParam("remoteId") String remoteId, @FormParam("password") String password) throws IOException { try { int result = dbDispatcher.addSpringUser(remoteId, password, shaStrength, remoteId); return result + " record(s) has been added. Must be 2: 1 record for the principal, another for the authorities table."; } catch (DuplicateKeyException e) { loggerServer.error(e.toString()); httpServletResponse.sendError(HttpServletResponse.SC_BAD_REQUEST); return e.toString(); } }