Example usage for javax.persistence PersistenceException getLocalizedMessage

List of usage examples for javax.persistence PersistenceException getLocalizedMessage

Introduction

In this page you can find the example usage for javax.persistence PersistenceException getLocalizedMessage.

Prototype

public String getLocalizedMessage() 

Source Link

Document

Creates a localized description of this throwable.

Usage

From source file:cn.org.once.cstack.service.impl.MessageServiceImpl.java

@Override
public List<Message> listByUserNoLimitRows(User user) throws ServiceException {
    try {//from www  . ja v a 2  s .c  om
        Pageable pageable = new PageRequest(0, 500, sortByLastNameAsc());
        Page<Message> requestedPage = messageDAO.listByUserAndCuInstance(user, cuInstanceName, pageable);
        return requestedPage.getContent();
    } catch (PersistenceException e) {
        throw new ServiceException(e.getLocalizedMessage(), e);
    }
}

From source file:cn.org.once.cstack.service.impl.MessageServiceImpl.java

@Override
public List<Message> listByApp(User user, String applicationName, int nbMessages) throws ServiceException {
    try {/*  w  w  w.  ja v a  2 s .c om*/
        Pageable pageable = new PageRequest(0, nbMessages, sortByLastNameAsc());
        Page<Message> requestedPage = messageDAO.listByApp(user, applicationName, cuInstanceName, pageable);
        return requestedPage.getContent();
    } catch (PersistenceException e) {
        throw new ServiceException(e.getLocalizedMessage(), e);
    }
}

From source file:cn.org.once.cstack.service.impl.ImageServiceImpl.java

@Override
@Transactional/*  w w w.  j a v a2 s .  co  m*/
public Image create(Image image) throws ServiceException {

    logger.debug("create : Methods parameters : " + image.toString());
    logger.info("ImageService : Starting creating image " + image.getName());

    try {
        imageDAO.save(image);
    } catch (PersistenceException e) {
        logger.error("ImageService Error : Create Image" + e);
        throw new ServiceException(e.getLocalizedMessage(), e);
    }

    logger.info("ImageService : Image " + image.getName() + "successfully created.");

    return image;
}

From source file:cn.org.once.cstack.service.impl.ImageServiceImpl.java

@Override
@Transactional/*  ww  w . jav a  2 s . c  om*/
public Image update(Image image) throws ServiceException {

    logger.debug("update : Methods parameters : " + image.toString());
    logger.info("ImageService : Starting updating image " + image.getName());

    try {
        imageDAO.saveAndFlush(image);
    } catch (PersistenceException e) {
        logger.error("ImageService Error : update Image" + e);
        throw new ServiceException(e.getLocalizedMessage(), e);
    }

    logger.info("ImageService : Image " + image.getName() + "successfully updated.");

    return image;
}

From source file:cn.org.once.cstack.service.impl.ImageServiceImpl.java

@Override
public Image findById(Integer id) throws ServiceException {
    try {//w  ww .j  a va 2s .  c o m
        logger.debug("findById : Methods parameters : " + id);
        Image image = imageDAO.findOne(id);
        logger.info("image with id " + id + " found!");
        return image;
    } catch (PersistenceException e) {
        logger.error("Error ImageService : error findById Method : " + e);
        throw new ServiceException(e.getLocalizedMessage(), e);

    }
}

From source file:cn.org.once.cstack.service.impl.ImageServiceImpl.java

@Override
public List<Image> findAll() throws ServiceException {
    try {//  ww  w.j  a  v a2 s .  c o m
        logger.debug("start findAll");
        List<Image> images = imageDAO.findAll();
        logger.info("ImageService : All Images found ");
        return images;
    } catch (PersistenceException e) {
        logger.error("Error ImageService : error findById Method : " + e);
        throw new ServiceException(e.getLocalizedMessage(), e);

    }
}

From source file:fr.treeptik.cloudunit.service.impl.ImageServiceImpl.java

@Override
public Image findByName(String name) throws ServiceException {
    try {/* www.  j  av  a2  s  . c om*/
        logger.debug("findById : Methods parameters : " + name);
        Image image = imageDAO.findByName(name);
        logger.info("image with id " + image.getName() + " found!");
        return image;
    } catch (PersistenceException e) {
        logger.error("Error ImageService : error findById Method : " + e);
        throw new ServiceException(e.getLocalizedMessage(), e);

    }
}

From source file:cn.org.once.cstack.service.impl.ImageServiceImpl.java

@Override
public List<Image> findEnabledImages() throws ServiceException {
    try {//from w ww.  jav  a  2  s .  c  o m
        logger.debug("start find enabled images");
        List<Image> images = imageDAO.findAllEnabledImages();
        logger.info("ImageService : enabled found ");
        return images;
    } catch (PersistenceException e) {
        logger.error("Error ImageService : error find enabled images Method : " + e);
        throw new ServiceException(e.getLocalizedMessage(), e);
    }
}

From source file:cn.org.once.cstack.service.impl.ImageServiceImpl.java

@Override
public Long countNumberOfInstances(String moduleName, String applicationName, String userLogin,
        String cuInstanceName) throws ServiceException {
    try {/*from w  ww .jav a2s.  c o m*/
        return imageDAO.countNumberOfInstances(moduleName, applicationName, userLogin, cuInstanceName);
    } catch (PersistenceException e) {
        logger.error("Error ImageService : error find number of images Method : " + e);
        throw new ServiceException(e.getLocalizedMessage(), e);

    }
}

From source file:cn.org.once.cstack.service.impl.ImageServiceImpl.java

@Override
public List<Image> findEnabledImagesByType(String type) throws ServiceException {
    try {//from w  w w  .ja  v a 2s  .  co m
        if (logger.isDebugEnabled()) {
            logger.debug("start find enabled '" + type + "' images");
        }
        List<Image> images = imageDAO.findAllEnabledImagesByType(type);
        logger.info("ImageService : enabled found ");
        return images;
    } catch (PersistenceException e) {
        logger.error("Error ImageService : error find enabled images Method : " + e);
        throw new ServiceException(e.getLocalizedMessage(), e);
    }
}