Search in sources :

Example 56 with NoSuchArticleException

use of com.liferay.knowledgebase.NoSuchArticleException in project liferay-ide by liferay.

the class KBArticlePersistenceImpl method findByR_M_PrevAndNext.

/**
 * Returns the k b articles before and after the current k b article in the ordered set where resourcePrimKey = ? and main = ?.
 *
 * @param kbArticleId the primary key of the current k b article
 * @param resourcePrimKey the resource prim key
 * @param main the main
 * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
 * @return the previous, current, and next k b article
 * @throws com.liferay.knowledgebase.NoSuchArticleException if a k b article with the primary key could not be found
 * @throws SystemException if a system exception occurred
 */
@Override
public KBArticle[] findByR_M_PrevAndNext(long kbArticleId, long resourcePrimKey, boolean main, OrderByComparator orderByComparator) throws NoSuchArticleException, SystemException {
    KBArticle kbArticle = findByPrimaryKey(kbArticleId);
    Session session = null;
    try {
        session = openSession();
        KBArticle[] array = new KBArticleImpl[3];
        array[0] = getByR_M_PrevAndNext(session, kbArticle, resourcePrimKey, main, orderByComparator, true);
        array[1] = kbArticle;
        array[2] = getByR_M_PrevAndNext(session, kbArticle, resourcePrimKey, main, orderByComparator, false);
        return array;
    } catch (Exception e) {
        throw processException(e);
    } finally {
        closeSession(session);
    }
}
Also used : KBArticle(com.liferay.knowledgebase.model.KBArticle) KBArticleImpl(com.liferay.knowledgebase.model.impl.KBArticleImpl) SystemException(com.liferay.portal.kernel.exception.SystemException) NoSuchArticleException(com.liferay.knowledgebase.NoSuchArticleException) Session(com.liferay.portal.kernel.dao.orm.Session)

Example 57 with NoSuchArticleException

use of com.liferay.knowledgebase.NoSuchArticleException in project liferay-ide by liferay.

the class KBArticlePersistenceImpl method findByC_M_PrevAndNext.

/**
 * Returns the k b articles before and after the current k b article in the ordered set where companyId = &#63; and main = &#63;.
 *
 * @param kbArticleId the primary key of the current k b article
 * @param companyId the company ID
 * @param main the main
 * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
 * @return the previous, current, and next k b article
 * @throws com.liferay.knowledgebase.NoSuchArticleException if a k b article with the primary key could not be found
 * @throws SystemException if a system exception occurred
 */
@Override
public KBArticle[] findByC_M_PrevAndNext(long kbArticleId, long companyId, boolean main, OrderByComparator orderByComparator) throws NoSuchArticleException, SystemException {
    KBArticle kbArticle = findByPrimaryKey(kbArticleId);
    Session session = null;
    try {
        session = openSession();
        KBArticle[] array = new KBArticleImpl[3];
        array[0] = getByC_M_PrevAndNext(session, kbArticle, companyId, main, orderByComparator, true);
        array[1] = kbArticle;
        array[2] = getByC_M_PrevAndNext(session, kbArticle, companyId, main, orderByComparator, false);
        return array;
    } catch (Exception e) {
        throw processException(e);
    } finally {
        closeSession(session);
    }
}
Also used : KBArticle(com.liferay.knowledgebase.model.KBArticle) KBArticleImpl(com.liferay.knowledgebase.model.impl.KBArticleImpl) SystemException(com.liferay.portal.kernel.exception.SystemException) NoSuchArticleException(com.liferay.knowledgebase.NoSuchArticleException) Session(com.liferay.portal.kernel.dao.orm.Session)

Example 58 with NoSuchArticleException

use of com.liferay.knowledgebase.NoSuchArticleException in project liferay-ide by liferay.

the class KBArticleLocalServiceImpl method getLatestKBArticleByUrlTitle.

@Override
public KBArticle getLatestKBArticleByUrlTitle(long groupId, long kbFolderId, String urlTitle, int status) throws PortalException, SystemException {
    urlTitle = StringUtil.replaceFirst(urlTitle, StringPool.SLASH, StringPool.BLANK);
    KBArticle latestKBArticle = fetchLatestKBArticleByUrlTitle(groupId, kbFolderId, urlTitle, status);
    if (latestKBArticle == null) {
        throw new NoSuchArticleException("No KBArticle exists with the key {groupId=" + groupId + ", kbFolderId=" + kbFolderId + ", urlTitle=" + urlTitle + ", status=" + status + "}");
    }
    return latestKBArticle;
}
Also used : KBArticle(com.liferay.knowledgebase.model.KBArticle) NoSuchArticleException(com.liferay.knowledgebase.NoSuchArticleException)

Example 59 with NoSuchArticleException

use of com.liferay.knowledgebase.NoSuchArticleException in project liferay-ide by liferay.

the class SectionPortlet method render.

@Override
public void render(RenderRequest renderRequest, RenderResponse renderResponse) throws IOException, PortletException {
    try {
        int status = getStatus(renderRequest);
        renderRequest.setAttribute(WebKeys.KNOWLEDGE_BASE_STATUS, status);
        KBArticle kbArticle = getKBArticle(renderRequest, status);
        renderRequest.setAttribute(WebKeys.KNOWLEDGE_BASE_KB_ARTICLE, kbArticle);
    } catch (Exception e) {
        if (e instanceof NoSuchArticleException || e instanceof PrincipalException) {
            SessionErrors.add(renderRequest, e.getClass());
        } else {
            throw new PortletException(e);
        }
    }
    super.render(renderRequest, renderResponse);
}
Also used : KBArticle(com.liferay.knowledgebase.model.KBArticle) PortletException(javax.portlet.PortletException) PrincipalException(com.liferay.portal.security.auth.PrincipalException) NoSuchArticleException(com.liferay.knowledgebase.NoSuchArticleException) NoSuchSubscriptionException(com.liferay.portal.NoSuchSubscriptionException) PrincipalException(com.liferay.portal.security.auth.PrincipalException) PortalException(com.liferay.portal.kernel.exception.PortalException) SystemException(com.liferay.portal.kernel.exception.SystemException) NoSuchArticleException(com.liferay.knowledgebase.NoSuchArticleException) IOException(java.io.IOException) NoSuchCommentException(com.liferay.knowledgebase.NoSuchCommentException) PortletException(javax.portlet.PortletException)

Example 60 with NoSuchArticleException

use of com.liferay.knowledgebase.NoSuchArticleException in project liferay-ide by liferay.

the class ArticlePortlet method render.

@Override
public void render(RenderRequest renderRequest, RenderResponse renderResponse) throws IOException, PortletException {
    try {
        int status = getStatus(renderRequest);
        renderRequest.setAttribute(WebKeys.KNOWLEDGE_BASE_STATUS, status);
        KBArticle kbArticle = null;
        long resourcePrimKey = getResourcePrimKey(renderRequest);
        if (resourcePrimKey > 0) {
            kbArticle = KBArticleServiceUtil.getLatestKBArticle(resourcePrimKey, status);
        }
        renderRequest.setAttribute(WebKeys.KNOWLEDGE_BASE_KB_ARTICLE, kbArticle);
    } catch (Exception e) {
        if (e instanceof NoSuchArticleException || e instanceof PrincipalException) {
            SessionErrors.add(renderRequest, e.getClass());
            SessionMessages.add(renderRequest, PortalUtil.getPortletId(renderRequest) + SessionMessages.KEY_SUFFIX_HIDE_DEFAULT_ERROR_MESSAGE);
        } else {
            throw new PortletException(e);
        }
    }
    super.render(renderRequest, renderResponse);
}
Also used : KBArticle(com.liferay.knowledgebase.model.KBArticle) PortletException(javax.portlet.PortletException) PrincipalException(com.liferay.portal.security.auth.PrincipalException) NoSuchArticleException(com.liferay.knowledgebase.NoSuchArticleException) NoSuchSubscriptionException(com.liferay.portal.NoSuchSubscriptionException) PrincipalException(com.liferay.portal.security.auth.PrincipalException) NoSuchArticleException(com.liferay.knowledgebase.NoSuchArticleException) IOException(java.io.IOException) NoSuchCommentException(com.liferay.knowledgebase.NoSuchCommentException) PortletException(javax.portlet.PortletException)

Aggregations

NoSuchArticleException (com.liferay.knowledgebase.NoSuchArticleException)111 KBArticle (com.liferay.knowledgebase.model.KBArticle)111 StringBundler (com.liferay.portal.kernel.util.StringBundler)58 SystemException (com.liferay.portal.kernel.exception.SystemException)48 KBArticleImpl (com.liferay.knowledgebase.model.impl.KBArticleImpl)45 Session (com.liferay.portal.kernel.dao.orm.Session)45 NoSuchCommentException (com.liferay.knowledgebase.NoSuchCommentException)5 NoSuchSubscriptionException (com.liferay.portal.NoSuchSubscriptionException)5 PrincipalException (com.liferay.portal.security.auth.PrincipalException)5 IOException (java.io.IOException)5 PortletException (javax.portlet.PortletException)5 PortalException (com.liferay.portal.kernel.exception.PortalException)3 KBArticleImportException (com.liferay.knowledgebase.KBArticleImportException)1 KBTemplateContentException (com.liferay.knowledgebase.KBTemplateContentException)1 KBTemplateTitleException (com.liferay.knowledgebase.KBTemplateTitleException)1 NoSuchTemplateException (com.liferay.knowledgebase.NoSuchTemplateException)1 KBTemplate (com.liferay.knowledgebase.model.KBTemplate)1 WindowStateException (javax.portlet.WindowStateException)1