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