List of usage examples for org.springframework.dao DataAccessException getMessage
@Override
@Nullable
public String getMessage()
From source file:org.sakaiproject.tool.assessment.facade.QuestionPoolFacadeQueries.java
/** * DOCUMENTATION PENDING/*w w w .j a v a 2 s .c om*/ * * @param pool DOCUMENTATION PENDING */ public QuestionPoolFacade savePool(QuestionPoolFacade pool) { boolean insert = false; try { QuestionPoolData qpp = (QuestionPoolData) pool.getData(); qpp.setLastModified(new Date()); qpp.setLastModifiedById(AgentFacade.getAgentString()); int retryCount = PersistenceService.getInstance().getPersistenceHelper().getRetryCount().intValue(); if (qpp.getQuestionPoolId() == null || qpp.getQuestionPoolId().equals(new Long("0"))) { // indicate a new pool insert = true; } while (retryCount > 0) { try { getHibernateTemplate().saveOrUpdate(qpp); retryCount = 0; } catch (DataAccessException e) { log.warn("problem saving Or Update pool: " + e.getMessage()); retryCount = PersistenceService.getInstance().getPersistenceHelper().retryDeadlock(e, retryCount); } } if (insert) { // add a QuestionPoolAccessData record for the owner who should have ADMIN access to the pool QuestionPoolAccessData qpa = new QuestionPoolAccessData(qpp.getQuestionPoolId(), qpp.getOwnerId(), QuestionPoolData.ADMIN); retryCount = PersistenceService.getInstance().getPersistenceHelper().getRetryCount().intValue(); while (retryCount > 0) { try { getHibernateTemplate().save(qpa); retryCount = 0; } catch (DataAccessException e) { log.warn("problem saving pool: " + e.getMessage()); retryCount = PersistenceService.getInstance().getPersistenceHelper().retryDeadlock(e, retryCount); } } // add a QuestionPoolAccessData record for all users who are sharing the subpool final long parentPoolId = qpp.getParentPoolId(); final String ownerId = qpp.getOwnerId(); if (parentPoolId != 0) { List<QuestionPoolAccessData> listSubpool = new ArrayList(); try { listSubpool = (List<QuestionPoolAccessData>) getHibernateTemplate().find( "from QuestionPoolAccessData as qpa where qpa.questionPoolId=? and qpa.agentId<>?", new Object[] { Long.valueOf(parentPoolId), ownerId }); } catch (Exception e1) { log.warn("problem finding pool: " + e1.getMessage()); } for (QuestionPoolAccessData questioPoolData : listSubpool) { qpa = new QuestionPoolAccessData(qpp.getQuestionPoolId(), questioPoolData.getAgentId(), QuestionPoolData.READ_COPY); retryCount = PersistenceService.getInstance().getPersistenceHelper().getRetryCount() .intValue(); while (retryCount > 0) { try { getHibernateTemplate().save(qpa); retryCount = 0; } catch (DataAccessException e) { log.warn("problem saving pool: " + e.getMessage()); retryCount = PersistenceService.getInstance().getPersistenceHelper() .retryDeadlock(e, retryCount); } } } } } return pool; } catch (RuntimeException e) { log.warn(e.getMessage()); return null; } }
From source file:org.sipfoundry.sipxconfig.phonebook.PhonebookManagerImpl.java
@SuppressWarnings("deprecation") public void removeTableColumns() { try {/* www .j av a 2 s . c o m*/ m_jdbcTemplate.execute("alter table phonebook drop column members_csv_filename"); m_jdbcTemplate.execute("alter table phonebook drop column members_vcard_filename"); LOG.info("Columns members_csv_filename and members_vcard_filename were removed from phonebook table."); } catch (DataAccessException e) { LOG.error("failed to remove columns members_csv_filename and members_vcard_filename" + e.getMessage()); } }
From source file:org.sipfoundry.sipxconfig.security.DaoAuthenticationProvider.java
@Override protected final UserDetails retrieveUser(String username, UsernamePasswordAuthenticationToken authentication) throws AuthenticationException { UserDetailsImpl loadedUser;/*from ww w.j av a 2 s . c o m*/ LdapSystemSettings settings = m_ldapManager.getSystemSettings(); if (settings.isConfigured() && settings.isLdapOnly() && !StringUtils.equals(username, AbstractUser.SUPERADMIN)) { throw new AuthenticationServiceException("Only LDAP authentication is permitted"); } String userLoginName = retrieveUsername(username); String domain = retrieveDomain(username); try { loadedUser = (UserDetailsImpl) getUserDetailsService().loadUserByUsername(userLoginName); } catch (DataAccessException repositoryProblem) { throw new AuthenticationServiceException(repositoryProblem.getMessage(), repositoryProblem); } if (loadedUser == null) { throw new AuthenticationServiceException( "UserDetailsService returned null, which is an interface contract violation"); } if (domain != null && !StringUtils.equals(loadedUser.getUserDomain(), domain)) { throw new AuthenticationServiceException("The following domain does not belong to the actual user: " + domain + " in the system - is an interface contract violation"); } return loadedUser; }
From source file:org.uhp.portlets.news.dao.iBatis.SqlMapClientCategoryDaoImpl.java
private void updateCategoryOrder(final Category cat, final int order) throws DataAccessException { Map<String, Object> params = new HashMap<String, Object>(); params.put(NewsConstants.C_ID, cat.getCategoryId()); params.put(Constants.DISPLAY_ORDER, Integer.valueOf(order)); try {//from w w w . jav a 2 s . co m getSqlMapClientTemplate().update("updateCategoryOrderById", params); } catch (DataAccessException e) { LOGGER.warn("SqlMapClientCategoryDaoImpl:: updateCategoryOrder : Error : " + e.getMessage()); } }
From source file:org.uhp.portlets.news.dao.iBatis.SqlMapClientCategoryDaoImpl.java
/** * Join a Category with a list of Type. * @param typeIds//from www . ja va 2 s . co m * @param categoryId * @throws DataAccessException * @see org.uhp.portlets.news.dao.CategoryDao#addTypesToCategory(java.util.List, Long) */ public void addTypesToCategory(final List<Long> typeIds, final Long categoryId) throws DataAccessException { for (Long tId : typeIds) { Map<String, Object> params = new HashMap<String, Object>(); params.put(NewsConstants.TYPE_ID, tId); params.put(NewsConstants.C_ID, categoryId); try { getSqlMapClientTemplate().insert("insertOneTypeOfCategory", params); } catch (DataAccessException e) { LOGGER.warn("SqlMapClientCategoryDaoImpl:: insertOneTypeOfCategory : Error : " + e.getMessage()); throw e; } } }
From source file:org.uhp.portlets.news.dao.iBatis.SqlMapClientCategoryDaoImpl.java
/** * Delete the link between a Category and a list of Type. * @param typeIds/*from www.j a v a 2 s . c om*/ * @param categoryId * @throws DataAccessException * @see org.uhp.portlets.news.dao.CategoryDao#deleteTypesOfCategory(java.util.List, java.lang.Long) */ public void deleteTypesOfCategory(final List<Long> typeIds, final Long categoryId) throws DataAccessException { for (Long tId : typeIds) { Map<String, Object> params = new HashMap<String, Object>(); params.put(NewsConstants.TYPE_ID, tId); params.put(NewsConstants.C_ID, categoryId); try { getSqlMapClientTemplate().delete("deleteOneTypeOfCategory", params); } catch (DataAccessException e) { LOGGER.warn("SqlMapClientCategoryDaoImpl:: insertOneTypeOfCategory : Error : " + e.getMessage()); throw e; } } }
From source file:org.uhp.portlets.news.dao.iBatis.SqlMapClientItemDaoImpl.java
private void updateItemOrder(Item item, Long topicId, Integer order) { Map<String, Object> params = new HashMap<String, Object>(3); params.put(NewsConstants.I_ID, item.getItemId()); params.put(NewsConstants.T_ID, topicId); params.put(Constants.DISPLAY_ORDER, order); try {/*from w w w. jav a 2s . co m*/ getSqlMapClientTemplate().update("updateItemOrderInTopic", params); } catch (DataAccessException e) { LOGGER.error("SqlMapClientItemDaoImpl:: updateItemOrder : Error : " + e.getMessage()); } }
From source file:org.uhp.portlets.news.dao.iBatis.SqlMapClientTopicDaoImpl.java
@SuppressWarnings("unchecked") /*public List<Topic> getMostRecentByCategory(final Integer dayCount, final Long categoryId) throws DataAccessException { Map<String, Object> params = new HashMap<String, Object>(); params.put(Constants.DAY_COUNT, dayCount); params.put(NewsConstants.C_ID, categoryId); return getSqlMapClientTemplate().queryForList("getMostRecentByCategory", params); }*//*w ww . j a v a 2 s. c o m*/ private void updateTopicOrder(Topic topic, int order) throws DataAccessException { Map<String, Object> params = new HashMap<String, Object>(); params.put(NewsConstants.T_ID, topic.getTopicId()); params.put(Constants.DISPLAY_ORDER, Integer.valueOf(order)); try { getSqlMapClientTemplate().update("updateTopicOrderById", params); } catch (DataAccessException e) { LOGGER.warn("SqlMapClientTopicDaoImpl:: updateTopicOrder : Error : " + e.getMessage()); } }
From source file:org.uhp.portlets.news.service.BasicFeedService.java
/** * @param id//ww w. j a va 2 s. com * @param status * @param uid * @return ItemsView * @see org.uhp.portlets.news.service.FeedService#getItems(java.lang.Long, int, java.lang.String) */ public ItemsView getItems(final Long id, final int status, final String uid) { try { if (um.isUserRoleExistForContext(id, NewsConstants.CTX_T, uid)) { final Topic t = topicDao.getTopicById(id); return getItems(categoryDao.getCategoryById(t.getCategoryId()), t, status); } LOG.warn("user " + uid + " has no permission to view the topic list with id=" + id); } catch (DataAccessException e) { LOG.error("DAE " + e.getMessage()); } return null; }
From source file:org.uhp.portlets.news.service.BasicFeedService.java
/** * @param id/*from w w w. j a va 2s. c om*/ * @param isProtected * @return ItemV * @see org.uhp.portlets.news.service.FeedService#getItem(java.lang.Long, boolean) */ public ItemV getItem(final Long id, final boolean isProtected) { try { final Item item = itemDao.getItemById(id); Category c = categoryDao.getCategoryById(item.getCategoryId()); ItemV iv = new ItemV(); iv.setItem(item); if (NewsConstants.S_N.equals(c.getRssAllowed()) || (NewsConstants.S_N.equals(c.getPublicView()) && !isProtected)) { return null; } iv.setCatName(c.getName()); List<Attachment> attachments = attachmentDao.getAttachmentsListByItem(id); iv.setAttachments(attachments); return iv; } catch (DataAccessException e) { LOG.error("DAE " + e.getMessage()); } catch (NoSuchItemException nsie) { LOG.error("No Item found with id " + id); } return null; }