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.DeploymentServiceImpl.java

@Override
public Deployment find(Deployment deployment) throws ServiceException {
    try {/*  w w  w  .ja  va2  s .  com*/
        return deploymentDAO.findOne(deployment.getId());
    } catch (PersistenceException e) {
        throw new ServiceException(e.getLocalizedMessage(), e);
    }
}

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

@Override
public List<Deployment> findByApp(Application application) throws ServiceException {
    try {//from   ww w  .ja  v  a2  s.  com
        return deploymentDAO.findAllByApplication(application);
    } catch (PersistenceException e) {
        throw new ServiceException(e.getLocalizedMessage() + application.getName(), e);
    }
}

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

@Override
@Transactional//  ww  w  .  jav  a  2  s .  co  m
public Deployment create(Application application, Type deploymentType) throws ServiceException, CheckException {
    try {
        Deployment deployment = new Deployment();
        deployment.setApplication(application);
        deployment.setType(deploymentType);
        deployment.setDate(new Date());
        application = applicationService.findByNameAndUser(application.getUser(), application.getName());
        application.setDeploymentStatus(Application.ALREADY_DEPLOYED);
        application = applicationService.saveInDB(application);
        return deploymentDAO.save(deployment);
    } catch (PersistenceException e) {
        throw new ServiceException(e.getLocalizedMessage(), e);
    }
}

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

@Override
@Transactional//from  ww w .j  a  v  a 2s  . c o  m
public Deployment create(Application application, DeploymentType deploymentType, String contextPath)
        throws ServiceException, CheckException {
    try {
        Deployment deployment = new Deployment();
        deployment.setApplication(application);
        deployment.setType(deploymentType);
        deployment.setDate(new Date());
        application = applicationService.findByNameAndUser(application.getUser(), application.getName());
        application.setDeploymentStatus(Application.ALREADY_DEPLOYED);
        application.setContextPath(contextPath);
        applicationService.saveInDB(application);
        return deploymentDAO.save(deployment);
    } catch (PersistenceException e) {
        throw new ServiceException(e.getLocalizedMessage(), e);
    }
}

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

@Override
@Transactional(propagation = Propagation.REQUIRES_NEW)
public Message create(Message message) throws ServiceException {
    try {//from  w w w  . j a v  a2 s .com
        return messageDAO.save(message);
    } catch (PersistenceException e) {
        throw new ServiceException(e.getLocalizedMessage(), e);
    }
}

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

@Override
public List<Message> listByUser(User user, int nbRows) throws ServiceException {
    try {/*  ww w . ja va  2 s. com*/
        Pageable pageable = new PageRequest(0, nbRows, sortByLastNameAsc());
        Page<Message> requestedPage = messageDAO.listByUser(user, pageable);
        return requestedPage.getContent();
    } catch (PersistenceException e) {
        throw new ServiceException(e.getLocalizedMessage(), e);
    }
}

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

@Override
public List<Message> listByApp(User user, String applicationName, int nbMessages) throws ServiceException {
    try {/*from  w w w  .ja  va  2s. c o m*/
        Pageable pageable = new PageRequest(0, nbMessages, sortByLastNameAsc());
        Page<Message> requestedPage = messageDAO.listByApp(user, applicationName, 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
@Transactional(propagation = Propagation.REQUIRES_NEW)
public void delete(Message message) throws ServiceException {
    try {/*from   ww  w  . j  a  va  2  s. c om*/
        messageDAO.delete(message);
    } catch (PersistenceException e) {
        throw new ServiceException(e.getLocalizedMessage(), e);
    }
}

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

@Override
@Transactional(propagation = Propagation.REQUIRES_NEW)
public Message create(Message message) throws ServiceException {
    try {/*  ww  w  . j  a  v  a 2  s . com*/
        message.setCuInstanceName(cuInstanceName);
        return messageDAO.save(message);
    } catch (PersistenceException e) {
        throw new ServiceException(e.getLocalizedMessage(), e);
    }
}

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

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