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);
}
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;
}
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);
}
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;
}
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());
}
Aggregations