Example usage for org.springframework.dao DataIntegrityViolationException toString

List of usage examples for org.springframework.dao DataIntegrityViolationException toString

Introduction

In this page you can find the example usage for org.springframework.dao DataIntegrityViolationException toString.

Prototype

public String toString() 

Source Link

Document

Returns a short description of this throwable.

Usage

From source file:com.poscoict.license.web.controller.ExceptionControllerAdvice.java

@ExceptionHandler(DataIntegrityViolationException.class)
public ModelAndView handleDataIntegrityViolationException(DataIntegrityViolationException ex) {
    logger.error(ex.toString());
    ModelAndView mv = new ModelAndView(DEFAULT_ERROR_VIEW);
    mv.addObject("name", ex.getClass().getSimpleName());
    mv.addObject("message",
            "?  ?. ?? ? . ?  ? ? ? ?  .");
    return mv;/*from  ww  w.j av  a 2s .  c om*/
}

From source file:ispok.pres.bb.OfficeEdit.java

public void addOffice() {
    try {//from  w  w w. j ava2s.c  om
        OfficeDto newOffice = new OfficeDto(office);
        newOffice.setInfo(office.getInfo());
        newOffice.setId(officeService.addOffice(newOffice));
        offices.add(newOffice);
        if (filteredOffices != null) {
            filteredOffices.add(newOffice);
        }
    } catch (DataIntegrityViolationException dive) {
        FacesUtil.addMessage(
                new FacesMessage(FacesMessage.SEVERITY_FATAL, FacesUtil.getString("fail"), dive.toString()));
    }
    FacesUtil.addMessage(new FacesMessage(FacesMessage.SEVERITY_INFO, FacesUtil.getString("success"),
            FacesUtil.getString("success")));
    clearEdit();
}

From source file:net.fenyo.mail4hotspot.web.WebController.java

@RequestMapping(value = "/mobile-create-user", method = RequestMethod.POST)
public ModelAndView mobileCreateUserPost(
        @RequestParam(value = "username", required = false) final String username,
        @RequestParam(value = "password", required = false) final String password,
        @RequestParam(value = "info", required = false) final String info, final ModelMap model) {
    log.info("TRACE: mobile-create-user;post;" + username + ";" + password + ";" + info + ";");

    ModelAndView mav = new ModelAndView();
    mav.setViewName("mobile-action-createuser");

    String trace_uuid = "";

    try {//from ww  w. ja  v a 2s. c o m
        final String uuid = generalServices.createUser(username, password);
        log.info("TRACE: mobile-create-user;exec;" + username + ";" + password + ";" + info + ";" + trace_uuid
                + ";");
        trace_uuid = uuid;
        mav.addObject("statusCode", 0);
        mav.addObject("statusString", "OK");
        mav.addObject("uuid", uuid);

        final Account account = generalServices.getFirstAccount(username);
        generalServices.sendInternalMailByAccount(account, "Welcome at VPN-over-DNS !",
                "Dear new customer,\n\nIn order to use this service, do not forget to configure you mail account by clicking on 'Configure mail' in the Configuration tab.\n\n-- The VPN-over-DNS support team.");
        generalServices.sendInternalMailByAccount(account, "Important message from VPN-over-DNS",
                "Dear customer,\n\nThe full documentation of this application is available at:\n    www.vpnoverdns.com\n\nIn this web site, you will find every informations needed to know how to best configure and use VPN-over-DNS.\n\n-- The VPN-over-DNS support team.");
        log.info("TRACE: mobile-create-user;done;" + username + ";" + password + ";" + info + ";" + trace_uuid
                + ";");
    } catch (final DataIntegrityViolationException ex) {
        // compte existe dj
        log.info("TRACE: mobile-create-user;user already exists;" + username + ";" + password + ";" + info + ";"
                + trace_uuid + ";");
        log.warn(ex);
        mav.addObject("statusCode", 1);
        mav.addObject("statusString", "user already exists");
        mav.addObject("uuid", "");
    } catch (final TransactionSystemException ex) {
        // bdd down
        log.info("TRACE: mobile-create-user;bdd down;" + username + ";" + password + ";" + info + ";"
                + trace_uuid + ";");
        log.warn(ex);
        mav.addObject("statusCode", 2);
        mav.addObject("statusString", "bdd down");
        mav.addObject("uuid", "");
    } catch (final Exception ex) {
        // autre cause d'erreur
        log.info("TRACE: mobile-create-user;exception;" + username + ";" + password + ";" + info + ";"
                + trace_uuid + ";");
        log.warn(ex);
        mav.addObject("statusCode", 3);
        mav.addObject("statusString", ex.toString());
        mav.addObject("uuid", "");
    }

    return mav;
}