Example usage for org.springframework.dao DataAccessException getLocalizedMessage

List of usage examples for org.springframework.dao DataAccessException getLocalizedMessage

Introduction

In this page you can find the example usage for org.springframework.dao DataAccessException getLocalizedMessage.

Prototype

public String getLocalizedMessage() 

Source Link

Document

Creates a localized description of this throwable.

Usage

From source file:org.uhp.portlets.news.service.CategoryManagerImpl.java

/**
 * @param categoryId//from  ww  w  .j av a 2s .co m
 * @return <code>Category</code>
 * @see org.uhp.portlets.news.service.CategoryManager#getCategoryById(java.lang.Long)
 */
public Category getCategoryById(final Long categoryId) {
    try {
        return this.categoryDao.getCategoryById(categoryId);
    } catch (DataAccessException e) {
        LOG.error("get category error : " + e.getLocalizedMessage());
    }
    return null;
}

From source file:org.uhp.portlets.news.service.CategoryManagerImpl.java

/**
 * @param uid/*from  w w w. j a va  2  s  .c  om*/
 * @return <code>List<Category></code>
 * @see org.uhp.portlets.news.service.CategoryManager#getListCategoryByUser(java.lang.String)
 */
public List<Category> getListCategoryByUser(final String uid) {
    List<Category> categories = null;
    try {
        if (this.userDao.isSuperAdmin(uid)) {
            categories = this.categoryDao.getAllCategory();
        } else {
            categories = this.categoryDao.getCategoriesByUser(uid);
        }
    } catch (DataAccessException e) {
        LOG.warn("Error msg : " + e.getLocalizedMessage());
    }
    return categories;
}

From source file:org.uhp.portlets.news.service.CategoryManagerImpl.java

/**
* Put to the first or the last position a category and in this case move other categories.
 * @param id/*from   w  ww  .  j a  v a 2s. c  o  m*/
 * @param up
 * @see org.uhp.portlets.news.service.CategoryManager#
 * updateCategoryOrderingToFirstOrLast(java.lang.Long, java.lang.Long, boolean)
 */
@Transactional(readOnly = false)
public void updateCategoryOrderingToFirstOrLast(final Long id, final Long entityId, final boolean up) {
    try {
        List<Category> categories = this.categoryDao.getAllCategoryOfEntity(entityId);
        for (int i = 0; i < categories.size(); i++) {
            this.updateCategoryOrdering(id, entityId, up);
        }
    } catch (DataAccessException e) {
        LOG.error("Update Category Ordering To First Or Last error : " + e.getLocalizedMessage());
        throw e;
    }
}

From source file:org.uhp.portlets.news.service.CategoryManagerImpl.java

/**
 * Retourne la liste des types associs  une catgorie.
 * @param categoryId//from  w  w w  . j a v a2s  . co m
 * @return <code>List<Type></code>
 */
public List<Type> getTypesOfCategory(final Long categoryId) {
    try {
        return this.categoryDao.getTypesOfCategory(categoryId);
    } catch (DataAccessException e) {
        LOG.error("Get Type Of Category error : " + e.getLocalizedMessage());
        throw e;
    }
}

From source file:org.uhp.portlets.news.service.CategoryManagerImpl.java

/**
 * Associer une liste de types  une catgorie.
 * @param typeIds//  www  . ja va2  s .  co  m
 * @param categoryId
 * @throws CategoryException 
 */
@Transactional(readOnly = false)
public void addAuthorizedTypeToCategory(final List<Long> typeIds, final Long categoryId)
        throws CategoryException {
    try {
        List<Type> types = this.entityDao
                .getAuthorizedTypesOfEntity(this.categoryDao.getCategoryById(categoryId).getEntityId());
        List<Long> tids = new ArrayList<Long>();
        for (Type t : types) {
            tids.add(t.getTypeId());
        }
        if (tids.containsAll(typeIds)) {
            this.categoryDao.addTypesToCategory(typeIds, categoryId);
        } else {
            throw new CategoryException(
                    "Certains des types spcifis ne sont pas autoriss pour la catgorie.");
        }
    } catch (DataAccessException e) {
        LOG.error("Add Authorized Type To Category error : " + e.getLocalizedMessage());
        throw e;
    }
}

From source file:org.uhp.portlets.news.service.CategoryManagerImpl.java

/**
 * Supprime les associations d'une catgorie.
 * @param typeIds/*  w  ww  .  j a  v  a2  s  .com*/
 * @param categoryId
 */
@Transactional(readOnly = false)
public void deleteTypeOfCategory(final List<Long> typeIds, final Long categoryId) {
    try {
        Type defaultType = this.typeDao.getTypeByName(NewsConstants.DEFAULT_TYPE);
        List<Long> type = new ArrayList<Long>();
        type.add(defaultType.getTypeId());

        this.categoryDao.deleteTypesOfCategory(typeIds, categoryId);
        List<Type> types = this.categoryDao.getTypesOfCategory(categoryId);
        if (types == null || types.isEmpty()) {
            this.categoryDao.addTypesToCategory(type, categoryId);
        }

    } catch (DataAccessException e) {
        LOG.error("Delete Types Of Category error : " + e.getLocalizedMessage());
        throw e;
    }
}

From source file:org.uhp.portlets.news.service.CategoryManagerImpl.java

/**
 * Liste les catgories d'une entit pour un utilisateur.
 * @param uid//ww w .  j a v a2 s . c  o m
 * @param entityId
 * @return <code>List<Category></code>
 * @see org.uhp.portlets.news.service.CategoryManager#getListCategoryByUser(java.lang.String)
 */
public List<Category> getListCategoryOfEntityByUser(final String uid, final Long entityId) {
    List<Category> categories = null;
    try {
        if (this.userDao.isSuperAdmin(uid)) {
            categories = this.categoryDao.getAllCategoryOfEntity(entityId);
        } else {
            categories = this.categoryDao.getCategoriesOfEntityByUser(uid, entityId);
        }
    } catch (DataAccessException e) {
        LOG.warn("Error msg : " + e.getLocalizedMessage());
    }
    return categories;
}

From source file:org.uhp.portlets.news.service.TopicManagerImpl.java

public Topic getTopicById(final Long topicId) throws NoSuchTopicException {
    try {//ww w .  j av  a2  s  .  c  om
        Topic t = this.topicDao.getTopicById(topicId);
        if (t != null) {
            t = this.setTopicCounts(t);
            return t;
        }

    } catch (DataAccessException e) {
        LOGGER.error(" get Topic error : " + e.getLocalizedMessage());
    }
    return null;
}

From source file:org.uhp.portlets.news.service.TopicManagerImpl.java

@Transactional(propagation = Propagation.REQUIRED)
public boolean deleteTopic(final Long topicId) {
    try {/*from  w w  w .  j a  v a2s.c o m*/
        if (this.topicDao.delete(topicId)) {
            this.userDao.removeUsersRoleForCtx(topicId, NewsConstants.CTX_T);
            this.subDao.deleteAllSubscribersByCtxId(topicId, NewsConstants.CTX_T);
            return true;
        }

    } catch (DataAccessException e1) {
        LOGGER.error("delete Topic error:" + e1.getLocalizedMessage());
    }
    return false;
}

From source file:org.uhp.portlets.news.service.TopicManagerImpl.java

/**
 * Put to the first or the last position a topic and in this case move other topic.
  * @param topicId// w  w w .j  av  a  2s .  c  o  m
  * @param categoryId
  * @param up Go to the top if true else to the bottom.
  * @see org.uhp.portlets.news.service.TopicManager#
  * updateTopicOrderingToFirstOrLast(java.lang.Long, java.lang.Long, boolean)
  */
@Transactional(propagation = Propagation.REQUIRED)
public void updateTopicOrderingToFirstOrLast(Long topicId, Long categoryId, boolean up) {
    try {
        List<Topic> topics = this.topicDao.getTopicListByCategory(categoryId);
        for (int i = 0; i < topics.size(); i++) {
            updateTopicOrdering(topicId, categoryId, up);
        }
    } catch (DataAccessException e) {
        LOGGER.error("Update Topic Ordering To First Or Last error : " + e.getLocalizedMessage());
        throw e;
    }
}