Search in sources :

Example 1 with NoSuchTemplateException

use of com.liferay.knowledgebase.NoSuchTemplateException 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 NoSuchTemplateException

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

the class KBTemplatePersistenceImpl method findByUuid_C_PrevAndNext.

/**
 * Returns the k b templates before and after the current k b template in the ordered set where uuid = ? and companyId = ?.
 *
 * @param kbTemplateId the primary key of the current k b template
 * @param uuid the uuid
 * @param companyId the company ID
 * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
 * @return the previous, current, and next k b template
 * @throws com.liferay.knowledgebase.NoSuchTemplateException if a k b template with the primary key could not be found
 * @throws SystemException if a system exception occurred
 */
@Override
public KBTemplate[] findByUuid_C_PrevAndNext(long kbTemplateId, String uuid, long companyId, OrderByComparator orderByComparator) throws NoSuchTemplateException, SystemException {
    KBTemplate kbTemplate = findByPrimaryKey(kbTemplateId);
    Session session = null;
    try {
        session = openSession();
        KBTemplate[] array = new KBTemplateImpl[3];
        array[0] = getByUuid_C_PrevAndNext(session, kbTemplate, uuid, companyId, orderByComparator, true);
        array[1] = kbTemplate;
        array[2] = getByUuid_C_PrevAndNext(session, kbTemplate, uuid, companyId, orderByComparator, false);
        return array;
    } catch (Exception e) {
        throw processException(e);
    } finally {
        closeSession(session);
    }
}
Also used : KBTemplateImpl(com.liferay.knowledgebase.model.impl.KBTemplateImpl) KBTemplate(com.liferay.knowledgebase.model.KBTemplate) NoSuchTemplateException(com.liferay.knowledgebase.NoSuchTemplateException) SystemException(com.liferay.portal.kernel.exception.SystemException) Session(com.liferay.portal.kernel.dao.orm.Session)

Example 3 with NoSuchTemplateException

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

the class KBTemplatePersistenceImpl method findByGroupId_Last.

/**
 * Returns the last k b template in the ordered set where groupId = &#63;.
 *
 * @param groupId the group ID
 * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
 * @return the last matching k b template
 * @throws com.liferay.knowledgebase.NoSuchTemplateException if a matching k b template could not be found
 * @throws SystemException if a system exception occurred
 */
@Override
public KBTemplate findByGroupId_Last(long groupId, OrderByComparator orderByComparator) throws NoSuchTemplateException, SystemException {
    KBTemplate kbTemplate = fetchByGroupId_Last(groupId, orderByComparator);
    if (kbTemplate != null) {
        return kbTemplate;
    }
    StringBundler msg = new StringBundler(4);
    msg.append(_NO_SUCH_ENTITY_WITH_KEY);
    msg.append("groupId=");
    msg.append(groupId);
    msg.append(StringPool.CLOSE_CURLY_BRACE);
    throw new NoSuchTemplateException(msg.toString());
}
Also used : NoSuchTemplateException(com.liferay.knowledgebase.NoSuchTemplateException) KBTemplate(com.liferay.knowledgebase.model.KBTemplate) StringBundler(com.liferay.portal.kernel.util.StringBundler)

Example 4 with NoSuchTemplateException

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

the class KBTemplatePersistenceImpl method remove.

/**
 * Removes the k b template with the primary key from the database. Also notifies the appropriate model listeners.
 *
 * @param primaryKey the primary key of the k b template
 * @return the k b template that was removed
 * @throws com.liferay.knowledgebase.NoSuchTemplateException if a k b template with the primary key could not be found
 * @throws SystemException if a system exception occurred
 */
@Override
public KBTemplate remove(Serializable primaryKey) throws NoSuchTemplateException, SystemException {
    Session session = null;
    try {
        session = openSession();
        KBTemplate kbTemplate = (KBTemplate) session.get(KBTemplateImpl.class, primaryKey);
        if (kbTemplate == null) {
            if (_log.isWarnEnabled()) {
                _log.warn(_NO_SUCH_ENTITY_WITH_PRIMARY_KEY + primaryKey);
            }
            throw new NoSuchTemplateException(_NO_SUCH_ENTITY_WITH_PRIMARY_KEY + primaryKey);
        }
        return remove(kbTemplate);
    } catch (NoSuchTemplateException nsee) {
        throw nsee;
    } catch (Exception e) {
        throw processException(e);
    } finally {
        closeSession(session);
    }
}
Also used : NoSuchTemplateException(com.liferay.knowledgebase.NoSuchTemplateException) KBTemplateImpl(com.liferay.knowledgebase.model.impl.KBTemplateImpl) KBTemplate(com.liferay.knowledgebase.model.KBTemplate) NoSuchTemplateException(com.liferay.knowledgebase.NoSuchTemplateException) SystemException(com.liferay.portal.kernel.exception.SystemException) Session(com.liferay.portal.kernel.dao.orm.Session)

Example 5 with NoSuchTemplateException

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

the class KBTemplatePersistenceImpl method findByUuid_Last.

/**
 * Returns the last k b template in the ordered set where uuid = &#63;.
 *
 * @param uuid the uuid
 * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
 * @return the last matching k b template
 * @throws com.liferay.knowledgebase.NoSuchTemplateException if a matching k b template could not be found
 * @throws SystemException if a system exception occurred
 */
@Override
public KBTemplate findByUuid_Last(String uuid, OrderByComparator orderByComparator) throws NoSuchTemplateException, SystemException {
    KBTemplate kbTemplate = fetchByUuid_Last(uuid, orderByComparator);
    if (kbTemplate != null) {
        return kbTemplate;
    }
    StringBundler msg = new StringBundler(4);
    msg.append(_NO_SUCH_ENTITY_WITH_KEY);
    msg.append("uuid=");
    msg.append(uuid);
    msg.append(StringPool.CLOSE_CURLY_BRACE);
    throw new NoSuchTemplateException(msg.toString());
}
Also used : NoSuchTemplateException(com.liferay.knowledgebase.NoSuchTemplateException) KBTemplate(com.liferay.knowledgebase.model.KBTemplate) StringBundler(com.liferay.portal.kernel.util.StringBundler)

Aggregations

NoSuchTemplateException (com.liferay.knowledgebase.NoSuchTemplateException)14 KBTemplate (com.liferay.knowledgebase.model.KBTemplate)14 StringBundler (com.liferay.portal.kernel.util.StringBundler)7 SystemException (com.liferay.portal.kernel.exception.SystemException)6 KBTemplateImpl (com.liferay.knowledgebase.model.impl.KBTemplateImpl)5 Session (com.liferay.portal.kernel.dao.orm.Session)5 KBArticleImportException (com.liferay.knowledgebase.KBArticleImportException)1 KBTemplateContentException (com.liferay.knowledgebase.KBTemplateContentException)1 KBTemplateTitleException (com.liferay.knowledgebase.KBTemplateTitleException)1 NoSuchArticleException (com.liferay.knowledgebase.NoSuchArticleException)1 NoSuchCommentException (com.liferay.knowledgebase.NoSuchCommentException)1 KBArticle (com.liferay.knowledgebase.model.KBArticle)1 NoSuchSubscriptionException (com.liferay.portal.NoSuchSubscriptionException)1 PortalException (com.liferay.portal.kernel.exception.PortalException)1 PrincipalException (com.liferay.portal.security.auth.PrincipalException)1 IOException (java.io.IOException)1 PortletException (javax.portlet.PortletException)1 WindowStateException (javax.portlet.WindowStateException)1