Search in sources :

Example 1 with NoSuchArticleException

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

the class AdminPortlet method render.

@Override
public void render(RenderRequest renderRequest, RenderResponse renderResponse) throws IOException, PortletException {
    try {
        int status = WorkflowConstants.STATUS_ANY;
        renderRequest.setAttribute(WebKeys.KNOWLEDGE_BASE_STATUS, status);
        KBArticle kbArticle = null;
        long kbArticleClassNameId = PortalUtil.getClassNameId(KBArticleConstants.getClassName());
        long resourceClassNameId = ParamUtil.getLong(renderRequest, "resourceClassNameId", kbArticleClassNameId);
        long resourcePrimKey = ParamUtil.getLong(renderRequest, "resourcePrimKey");
        if ((resourcePrimKey > 0) && (resourceClassNameId == kbArticleClassNameId)) {
            kbArticle = KBArticleServiceUtil.getLatestKBArticle(resourcePrimKey, status);
        }
        renderRequest.setAttribute(WebKeys.KNOWLEDGE_BASE_KB_ARTICLE, kbArticle);
        KBTemplate kbTemplate = null;
        long kbTemplateId = ParamUtil.getLong(renderRequest, "kbTemplateId");
        if (kbTemplateId > 0) {
            kbTemplate = KBTemplateServiceUtil.getKBTemplate(kbTemplateId);
        }
        renderRequest.setAttribute(WebKeys.KNOWLEDGE_BASE_KB_TEMPLATE, kbTemplate);
    } catch (Exception e) {
        if (e instanceof NoSuchArticleException || e instanceof NoSuchTemplateException || e instanceof PrincipalException) {
            SessionErrors.add(renderRequest, e.getClass());
        } else {
            throw new PortletException(e);
        }
    }
    super.render(renderRequest, renderResponse);
}
Also used : NoSuchTemplateException(com.liferay.knowledgebase.NoSuchTemplateException) KBArticle(com.liferay.knowledgebase.model.KBArticle) PortletException(javax.portlet.PortletException) PrincipalException(com.liferay.portal.security.auth.PrincipalException) NoSuchArticleException(com.liferay.knowledgebase.NoSuchArticleException) KBTemplate(com.liferay.knowledgebase.model.KBTemplate) NoSuchTemplateException(com.liferay.knowledgebase.NoSuchTemplateException) KBTemplateContentException(com.liferay.knowledgebase.KBTemplateContentException) 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) IOException(java.io.IOException) WindowStateException(javax.portlet.WindowStateException) NoSuchCommentException(com.liferay.knowledgebase.NoSuchCommentException) KBTemplateTitleException(com.liferay.knowledgebase.KBTemplateTitleException) KBArticleImportException(com.liferay.knowledgebase.KBArticleImportException) PortletException(javax.portlet.PortletException)

Example 2 with NoSuchArticleException

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

the class KBArticlePersistenceImpl method findByP_L_Last.

/**
 * Returns the last k b article in the ordered set where parentResourcePrimKey = ? and latest = ?.
 *
 * @param parentResourcePrimKey the parent resource prim key
 * @param latest the latest
 * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
 * @return the last matching k b article
 * @throws com.liferay.knowledgebase.NoSuchArticleException if a matching k b article could not be found
 * @throws SystemException if a system exception occurred
 */
@Override
public KBArticle findByP_L_Last(long parentResourcePrimKey, boolean latest, OrderByComparator orderByComparator) throws NoSuchArticleException, SystemException {
    KBArticle kbArticle = fetchByP_L_Last(parentResourcePrimKey, latest, orderByComparator);
    if (kbArticle != null) {
        return kbArticle;
    }
    StringBundler msg = new StringBundler(6);
    msg.append(_NO_SUCH_ENTITY_WITH_KEY);
    msg.append("parentResourcePrimKey=");
    msg.append(parentResourcePrimKey);
    msg.append(", latest=");
    msg.append(latest);
    msg.append(StringPool.CLOSE_CURLY_BRACE);
    throw new NoSuchArticleException(msg.toString());
}
Also used : KBArticle(com.liferay.knowledgebase.model.KBArticle) NoSuchArticleException(com.liferay.knowledgebase.NoSuchArticleException) StringBundler(com.liferay.portal.kernel.util.StringBundler)

Example 3 with NoSuchArticleException

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

the class KBArticlePersistenceImpl method findByG_P_S_S_PrevAndNext.

/**
 * Returns the k b articles before and after the current k b article in the ordered set where groupId = &#63; and parentResourcePrimKey = &#63; and sections LIKE &#63; and status = &#63;.
 *
 * @param kbArticleId the primary key of the current k b article
 * @param groupId the group ID
 * @param parentResourcePrimKey the parent resource prim key
 * @param sections the sections
 * @param status the status
 * @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[] findByG_P_S_S_PrevAndNext(long kbArticleId, long groupId, long parentResourcePrimKey, String sections, int status, OrderByComparator orderByComparator) throws NoSuchArticleException, SystemException {
    KBArticle kbArticle = findByPrimaryKey(kbArticleId);
    Session session = null;
    try {
        session = openSession();
        KBArticle[] array = new KBArticleImpl[3];
        array[0] = getByG_P_S_S_PrevAndNext(session, kbArticle, groupId, parentResourcePrimKey, sections, status, orderByComparator, true);
        array[1] = kbArticle;
        array[2] = getByG_P_S_S_PrevAndNext(session, kbArticle, groupId, parentResourcePrimKey, sections, status, 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 4 with NoSuchArticleException

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

the class KBArticlePersistenceImpl method findByG_P_L_Last.

/**
 * Returns the last k b article in the ordered set where groupId = &#63; and parentResourcePrimKey = &#63; and latest = &#63;.
 *
 * @param groupId the group ID
 * @param parentResourcePrimKey the parent resource prim key
 * @param latest the latest
 * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
 * @return the last matching k b article
 * @throws com.liferay.knowledgebase.NoSuchArticleException if a matching k b article could not be found
 * @throws SystemException if a system exception occurred
 */
@Override
public KBArticle findByG_P_L_Last(long groupId, long parentResourcePrimKey, boolean latest, OrderByComparator orderByComparator) throws NoSuchArticleException, SystemException {
    KBArticle kbArticle = fetchByG_P_L_Last(groupId, parentResourcePrimKey, latest, orderByComparator);
    if (kbArticle != null) {
        return kbArticle;
    }
    StringBundler msg = new StringBundler(8);
    msg.append(_NO_SUCH_ENTITY_WITH_KEY);
    msg.append("groupId=");
    msg.append(groupId);
    msg.append(", parentResourcePrimKey=");
    msg.append(parentResourcePrimKey);
    msg.append(", latest=");
    msg.append(latest);
    msg.append(StringPool.CLOSE_CURLY_BRACE);
    throw new NoSuchArticleException(msg.toString());
}
Also used : KBArticle(com.liferay.knowledgebase.model.KBArticle) NoSuchArticleException(com.liferay.knowledgebase.NoSuchArticleException) StringBundler(com.liferay.portal.kernel.util.StringBundler)

Example 5 with NoSuchArticleException

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

the class KBArticlePersistenceImpl method findByP_M_PrevAndNext.

/**
 * Returns the k b articles before and after the current k b article in the ordered set where parentResourcePrimKey = &#63; and main = &#63;.
 *
 * @param kbArticleId the primary key of the current k b article
 * @param parentResourcePrimKey the parent 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[] findByP_M_PrevAndNext(long kbArticleId, long parentResourcePrimKey, boolean main, OrderByComparator orderByComparator) throws NoSuchArticleException, SystemException {
    KBArticle kbArticle = findByPrimaryKey(kbArticleId);
    Session session = null;
    try {
        session = openSession();
        KBArticle[] array = new KBArticleImpl[3];
        array[0] = getByP_M_PrevAndNext(session, kbArticle, parentResourcePrimKey, main, orderByComparator, true);
        array[1] = kbArticle;
        array[2] = getByP_M_PrevAndNext(session, kbArticle, parentResourcePrimKey, 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)

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