Search in sources :

Example 61 with NoSuchArticleException

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

the class DisplayPortlet method render.

@Override
public void render(RenderRequest renderRequest, RenderResponse renderResponse) throws IOException, PortletException {
    try {
        KBArticle kbArticle = getKBArticle(renderRequest);
        int status = getStatus(renderRequest, kbArticle);
        renderRequest.setAttribute(WebKeys.KNOWLEDGE_BASE_STATUS, status);
        if ((kbArticle != null) && (kbArticle.getStatus() != status)) {
            kbArticle = KBArticleLocalServiceUtil.fetchLatestKBArticle(kbArticle.getResourcePrimKey(), 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) 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 62 with NoSuchArticleException

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

the class KBArticleLocalServiceImpl method getKBArticleByUrlTitle.

@Override
public KBArticle getKBArticleByUrlTitle(long groupId, String kbFolderUrlTitle, String urlTitle) throws PortalException {
    urlTitle = StringUtil.replaceFirst(urlTitle, StringPool.SLASH, StringPool.BLANK);
    KBArticle kbArticle = fetchKBArticleByUrlTitle(groupId, kbFolderUrlTitle, urlTitle);
    if (kbArticle == null) {
        throw new NoSuchArticleException("No KBArticle with the key {groupId=" + groupId + ", urlTitle=" + urlTitle + "} found in a folder with URL " + "title " + kbFolderUrlTitle);
    }
    return kbArticle;
}
Also used : KBArticle(com.liferay.knowledgebase.model.KBArticle) NoSuchArticleException(com.liferay.knowledgebase.NoSuchArticleException)

Example 63 with NoSuchArticleException

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

the class SearchPortlet 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 = ParamUtil.getLong(renderRequest, "resourcePrimKey");
        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());
        } 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) NoSuchArticleException(com.liferay.knowledgebase.NoSuchArticleException) IOException(java.io.IOException) NoSuchSubscriptionException(com.liferay.portal.NoSuchSubscriptionException) PrincipalException(com.liferay.portal.security.auth.PrincipalException) NoSuchCommentException(com.liferay.knowledgebase.NoSuchCommentException) PortletException(javax.portlet.PortletException)

Example 64 with NoSuchArticleException

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

the class KBArticleAssetRendererFactory method getAssetRenderer.

@Override
public AssetRenderer getAssetRenderer(long classPK, int type) throws PortalException, SystemException {
    KBArticle kbArticle = null;
    if (type == TYPE_LATEST_APPROVED) {
        kbArticle = KBArticleLocalServiceUtil.getLatestKBArticle(classPK, WorkflowConstants.STATUS_APPROVED);
    } else {
        try {
            kbArticle = KBArticleLocalServiceUtil.getKBArticle(classPK);
        } catch (NoSuchArticleException nsae) {
            kbArticle = KBArticleLocalServiceUtil.getLatestKBArticle(classPK, WorkflowConstants.STATUS_ANY);
        }
    }
    KBArticleAssetRenderer kbArticleAssetRenderer = new KBArticleAssetRenderer(kbArticle);
    kbArticleAssetRenderer.setAssetRendererType(type);
    return kbArticleAssetRenderer;
}
Also used : KBArticle(com.liferay.knowledgebase.model.KBArticle) NoSuchArticleException(com.liferay.knowledgebase.NoSuchArticleException)

Example 65 with NoSuchArticleException

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

the class KBArticlePersistenceImpl method findByR_G_L_First.

/**
 * Returns the first k b article in the ordered set where resourcePrimKey = ? and groupId = ? and latest = ?.
 *
 * @param resourcePrimKey the resource prim key
 * @param groupId the group ID
 * @param latest the latest
 * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
 * @return the first 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 findByR_G_L_First(long resourcePrimKey, long groupId, boolean latest, OrderByComparator orderByComparator) throws NoSuchArticleException, SystemException {
    KBArticle kbArticle = fetchByR_G_L_First(resourcePrimKey, groupId, latest, orderByComparator);
    if (kbArticle != null) {
        return kbArticle;
    }
    StringBundler msg = new StringBundler(8);
    msg.append(_NO_SUCH_ENTITY_WITH_KEY);
    msg.append("resourcePrimKey=");
    msg.append(resourcePrimKey);
    msg.append(", groupId=");
    msg.append(groupId);
    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)

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