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);
}
}
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 = ? and main = ?.
*
* @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);
}
}
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;
}
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);
}
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);
}
Aggregations