List of usage examples for java.sql SQLException getLocalizedMessage
public String getLocalizedMessage()
From source file:com.alkacon.opencms.comments.CmsCommentsAccess.java
/** * Approves the given comment entry.<p> * // ww w. j a va 2s . com * @param entryId the id of the comment entry to approve */ public void approve(int entryId) { if (!isUserCanManage()) { return; } try { CmsFormDataAccess.getInstance().updateState(entryId, STATE_APPROVED); } catch (SQLException e) { if (LOG.isErrorEnabled()) { LOG.error(e.getLocalizedMessage(), e); } } }
From source file:com.alkacon.opencms.comments.CmsCommentsAccess.java
/** * Blocks the given comment entry.<p> * /*from ww w. j ava2 s . c om*/ * @param entryId the id of the comment entry to block */ public void block(int entryId) { if (!isUserCanManage()) { return; } try { CmsFormDataAccess.getInstance().updateState(entryId, STATE_BLOCKED); } catch (SQLException e) { if (LOG.isErrorEnabled()) { LOG.error(e.getLocalizedMessage(), e); } } }
From source file:com.alkacon.opencms.comments.CmsCommentsAccess.java
/** * Deletes the given comment entry.<p> * /*from www .j av a 2s. c o m*/ * @param entryId the id of the comment entry to delete */ public void delete(int entryId) { if (!isUserCanManage()) { return; } try { CmsFormDataAccess.getInstance().deleteForm(entryId); } catch (SQLException e) { if (LOG.isErrorEnabled()) { LOG.error(e.getLocalizedMessage(), e); } } }
From source file:com.alkacon.opencms.comments.CmsCommentsAccess.java
/** * Returns the number of comments.<p> * // w w w . j ava 2 s. com * This depends of the moderation mode and your permissions.<p> * * @return the number of comments */ public int getCountComments() { if (m_countComments == null) { CmsFormDatabaseFilter filter = getCommentFilter(true, false); try { m_countComments = new Integer(CmsFormDataAccess.getInstance().countForms(filter)); } catch (SQLException e) { if (LOG.isErrorEnabled()) { LOG.error(e.getLocalizedMessage(), e); } m_countComments = new Integer(0); } } return m_countComments.intValue(); }
From source file:com.alkacon.opencms.comments.CmsCommentsAccess.java
/** * Returns the number of comments filtered by state.<p> * // w w w. j a v a 2 s .c om * This depends of the moderation mode and your permissions.<p> * * @return the number of comments */ public int getCountStateComments() { if (m_countStateComments == null) { CmsFormDatabaseFilter filter = getCommentFilter(true, true); try { m_countStateComments = new Integer(CmsFormDataAccess.getInstance().countForms(filter)); } catch (SQLException e) { if (LOG.isErrorEnabled()) { LOG.error(e.getLocalizedMessage(), e); } m_countStateComments = new Integer(0); } } return m_countStateComments.intValue(); }
From source file:com.alkacon.opencms.comments.CmsCommentsAccess.java
/** * Returns the number of approved comments.<p> * /*from w ww . ja v a2s. c o m*/ * @return the number of approved comments */ public int getCountApprovedComments() { if (m_countApprovedComments == null) { CmsFormDatabaseFilter filter = CmsFormDatabaseFilter.HEADERS; filter = filter.filterFormId(CmsCommentForm.FORM_ID); filter = filter.filterResourceId(m_resource.getStructureId()); filter = filter.filterState(STATE_APPROVED); try { m_countApprovedComments = new Integer(CmsFormDataAccess.getInstance().countForms(filter)); } catch (SQLException e) { if (LOG.isErrorEnabled()) { LOG.error(e.getLocalizedMessage(), e); } m_countApprovedComments = new Integer(0); } } return m_countApprovedComments.intValue(); }
From source file:com.alkacon.opencms.comments.CmsCommentsAccess.java
/** * Returns the number of blocked comments.<p> * /*from w w w . j a v a2s .co m*/ * Always zero if not moderated.<p> * * @return the number of blocked comments */ public int getCountBlockedComments() { if (!m_config.isModerated()) { return 0; } if (m_countBlockedComments == null) { CmsFormDatabaseFilter filter = CmsFormDatabaseFilter.HEADERS; filter = filter.filterFormId(CmsCommentForm.FORM_ID); filter = filter.filterResourceId(m_resource.getStructureId()); filter = filter.filterState(STATE_BLOCKED); try { m_countBlockedComments = new Integer(CmsFormDataAccess.getInstance().countForms(filter)); } catch (SQLException e) { if (LOG.isErrorEnabled()) { LOG.error(e.getLocalizedMessage(), e); } m_countBlockedComments = new Integer(0); } } return m_countBlockedComments.intValue(); }
From source file:com.alkacon.opencms.comments.CmsCommentsAccess.java
/** * Returns the number of new comments.<p> * //from w w w . ja v a 2 s .c o m * Always zero if not moderated.<p> * * @return the number of new comments */ public int getCountNewComments() { if (!m_config.isModerated()) { return 0; } if (m_countNewComments == null) { CmsFormDatabaseFilter filter = CmsFormDatabaseFilter.HEADERS; filter = filter.filterFormId(CmsCommentForm.FORM_ID); filter = filter.filterResourceId(m_resource.getStructureId()); filter = filter.filterState(STATE_NEW); try { m_countNewComments = new Integer(CmsFormDataAccess.getInstance().countForms(filter)); } catch (SQLException e) { if (LOG.isErrorEnabled()) { LOG.error(e.getLocalizedMessage(), e); } m_countNewComments = new Integer(0); } } return m_countNewComments.intValue(); }
From source file:com.alkacon.opencms.comments.CmsCommentsAccess.java
/** * Returns the number of comments a given author has written.<p> * /* ww w .j a v a 2s.c o m*/ * To use this method you have to define a field called {@link CmsCommentFormHandler#FIELD_USERNAME}.<p> * * @return a map where the key is the author name and the value the number of comments */ public Map getCountByAuthor() { if (m_countByAuthor == null) { m_countByAuthor = LazyMap.decorate(new HashMap(), new Transformer() { /** * @see org.apache.commons.collections.Transformer#transform(java.lang.Object) */ public Object transform(Object input) { String author = String.valueOf(input); CmsFormDatabaseFilter filter = CmsFormDatabaseFilter.HEADERS; filter = filter.filterFormId(CmsCommentForm.FORM_ID); filter = filter.filterField(CmsCommentFormHandler.FIELD_USERNAME, author); try { return new Integer(CmsFormDataAccess.getInstance().countForms(filter)); } catch (SQLException e) { if (LOG.isErrorEnabled()) { LOG.error(e.getLocalizedMessage(), e); } } return new Integer(0); } }); } return m_countByAuthor; }
From source file:com.alkacon.opencms.v8.comments.CmsCommentsAccess.java
/** * Returns the number of comments a given author has written.<p> * //from ww w . j av a 2s . com * To use this method you have to define a field called {@link CmsCommentFormHandler#FIELD_USERNAME}.<p> * * @return a map where the key is the author name and the value the number of comments */ @SuppressWarnings("unchecked") public Map<String, Integer> getCountByAuthor() { if (m_countByAuthor == null) { m_countByAuthor = LazyMap.decorate(new HashMap<String, Integer>(), new Transformer() { /** * @see org.apache.commons.collections.Transformer#transform(java.lang.Object) */ public Object transform(Object input) { String author = String.valueOf(input); CmsFormDatabaseFilter filter = CmsFormDatabaseFilter.HEADERS; filter = filter.filterFormId(CmsCommentForm.FORM_ID); filter = filter.filterResourceId(getResource().getStructureId()); filter = filter.filterField(CmsCommentFormHandler.FIELD_USERNAME, author); try { return new Integer(CmsFormDataAccess.getInstance().countForms(filter)); } catch (SQLException e) { if (LOG.isErrorEnabled()) { LOG.error(e.getLocalizedMessage(), e); } } return new Integer(0); } }); } return m_countByAuthor; }