List of usage examples for org.springframework.dao DataAccessException getMessage
@Override
@Nullable
public String getMessage()
From source file:org.uhp.portlets.news.service.BasicFeedService.java
/** * Get the attachment file to download./*from w ww . j a v a 2 s.c om*/ * * @param fileUid * @param itemId * @param isProtected * @return AttachmentD */ public AttachmentD getAttachmentToDownload(final String fileUid, final Long itemId, final boolean isProtected) { try { List<Attachment> attachments = attachmentDao.getAttachmentsListByItem(itemId); boolean found = false; Attachment attachement = null; for (Attachment att : attachments) { String cmisUid = att.getCmisUid(); if (cmisUid.equalsIgnoreCase(fileUid)) { found = true; attachement = att; break; } } if (found) { // retrieve entity Item item = itemDao.getItemById(itemId); Category c = categoryDao.getCategoryById(item.getCategoryId()); if (NewsConstants.S_N.equals(c.getRssAllowed()) || (NewsConstants.S_N.equals(c.getPublicView()) && !isProtected)) { return null; } Long entityId = c.getEntityId(); AttachmentD toDownload = cmisDao.getAttachmentById(fileUid, entityId); toDownload.setFileName(attachement.getFileName()); toDownload.setAttachmentId(attachement.getAttachmentId()); return toDownload; } return null; } catch (DataAccessException e) { LOG.error("DAE " + e.getMessage(), e.fillInStackTrace()); } catch (CmisException ce) { LOG.error(ce, ce.fillInStackTrace()); } return null; }
From source file:org.uhp.portlets.news.service.ItemManagerImpl.java
public List<Item> getArchivedItemListByTopic(Long topicId) { try {/*from w w w.ja v a 2 s.c o m*/ return this.itemDao.getExpiredItemListByTopic(topicId); } catch (DataAccessException e) { if (LOGGER.isWarnEnabled()) { LOGGER.warn("Data access error : " + e.getMessage()); } } return null; }
From source file:org.uhp.portlets.news.service.ItemManagerImpl.java
public Integer getPendingItemsCountByCategory(Long categoryId) { try {//from w w w .j av a 2 s .co m return this.itemDao.getPendingItemsCountByCategory(categoryId); } catch (DataAccessException e) { if (LOGGER.isWarnEnabled()) { LOGGER.warn("data access error : " + e.getMessage()); } } return null; }
From source file:org.uhp.portlets.news.service.ItemManagerImpl.java
public int countItemsWithAttachmentByTopic(Long topicId) { try {//w ww.j av a2 s .c om return this.itemDao.countItemsWithAttachmentByTopic(topicId); } catch (DataAccessException e) { if (LOGGER.isWarnEnabled()) { LOGGER.warn("data access error : " + e.getMessage()); } } return -1; }
From source file:org.uhp.portlets.news.service.NotificationServiceImpl.java
private void sendDailyEmailForCategory(final Category category) { Long cId = category.getCategoryId(); String n = ""; LOG.debug("sendDailyEmailForCategory " + category.getName()); List<Topic> topicsForToday = this.getPendingTopics(cId); if (topicsForToday.size() < 1) { LOG.debug("send Daily Email For Category [" + category.getName() + "] : nothing new, no notification sent"); return;// w w w. j a va 2s . c om } Set<IEscoUser> managers = this.getManagersForCategory(category); if (managers.isEmpty()) { return; } try { n = Integer.toString(this.itemDao.getPendingItemsCountByCategory(category.getCategoryId())); } catch (DataAccessException e1) { LOG.error("Notification error : " + e1.getMessage()); } SimpleMailMessage message = new SimpleMailMessage(templateMessage); LOG.debug("send Daily Email For Category [" + category.getName() + "] : status OK"); String[] recip = new String[managers.size()]; int nb = 0; for (IEscoUser user : managers) { if (user.getEmail() != null && user.getEmail().length() > 0) { recip[nb++] = user.getEmail(); } } message.setTo(recip); String text = message.getText(); text = StringUtils.replace(text, "%NB%", n); text = StringUtils.replace(text, "%CATEGORY%", category.getName()); text = StringUtils.replace(text, "%TOPICS%", this.getPendingTopicsForCategory(cId)); message.setText(text); try { LOG.info(message); mailSender.send(message); } catch (MailException e) { LOG.error("Notification Service:: An exception occured when sending mail," + " have you correctly configured your mail engine ?" + e); } }
From source file:org.uhp.portlets.news.service.NotificationServiceImpl.java
private List<IEscoUser> getOnlyTopicManagersForTopics(final Long cId, final List<Topic> topics) { List<IEscoUser> managers = null; String[] tIds = new String[topics.size()]; int i = 0;/*from w w w .jav a2s .com*/ for (final Topic t : topics) { tIds[i++] = String.valueOf(t.getTopicId()); } try { managers = this.userDao.getManagersForTopics(cId, toInteger(tIds)); } catch (DataAccessException e) { LOG.error("Erreur : pb de connexion de la base de donnees " + e.getMessage()); } return managers; }
From source file:org.unitedinternet.cosmo.acegisecurity.providers.ticket.TicketAuthenticationProvider.java
/** * Find tickets.//from www . j a v a 2 s.c o m * @param path The path. * @param key The key. * @return The ticket. */ private Ticket findTicket(String path, String key) { try { if (LOG.isDebugEnabled()) { LOG.debug("authenticating ticket " + key + " for resource at path " + path); } Item item = findItem(path); Ticket ticket = contentDao.getTicket(item, key); if (ticket == null) { return null; } if (ticket.hasTimedOut()) { if (LOG.isDebugEnabled()) { LOG.debug("removing timed out ticket " + ticket.getKey()); } contentDao.removeTicket(item, ticket); return null; } return ticket; } catch (DataAccessException e) { throw new AuthenticationServiceException(e.getMessage(), e); } }