use of com.liferay.knowledgebase.model.KBFolder in project liferay-ide by liferay.
the class KBFolderKBArticleSelector method findByUrlTitle.
@Override
public KBArticle findByUrlTitle(long groupId, String preferredKBFolderUrlTitle, long ancestorResourcePrimKey, String kbFolderUrlTitle, String urlTitle) throws PortalException, SystemException {
KBFolder ancestorKBFolder = _rootKBFolder;
if (ancestorResourcePrimKey != KBFolderConstants.DEFAULT_PARENT_FOLDER_ID) {
ancestorKBFolder = KBFolderLocalServiceUtil.fetchKBFolder(ancestorResourcePrimKey);
if (ancestorKBFolder == null) {
return null;
}
}
KBFolder kbFolder = _rootKBFolder;
if (Validator.isNotNull(kbFolderUrlTitle)) {
if (kbFolderUrlTitle.equals(ancestorKBFolder.getUrlTitle())) {
kbFolder = ancestorKBFolder;
} else {
kbFolder = KBFolderLocalServiceUtil.fetchKBFolderByUrlTitle(groupId, ancestorKBFolder.getKbFolderId(), kbFolderUrlTitle);
}
}
KBArticle kbArticle = KBArticleLocalServiceUtil.fetchKBArticleByUrlTitle(groupId, kbFolder.getKbFolderId(), urlTitle);
if ((kbArticle == null) || !isDescendant(kbArticle, ancestorKBFolder)) {
return findClosestMatchingKBArticle(groupId, ancestorKBFolder, preferredKBFolderUrlTitle, kbFolderUrlTitle, urlTitle);
}
return kbArticle;
}
use of com.liferay.knowledgebase.model.KBFolder in project liferay-ide by liferay.
the class FindKBArticleAction method isParentFolder.
protected boolean isParentFolder(long resourcePrimKey, long kbFolderId) throws PortalException, SystemException {
while (kbFolderId != KBFolderConstants.DEFAULT_PARENT_FOLDER_ID) {
if (resourcePrimKey == kbFolderId) {
return true;
}
KBFolder kbFolder = KBFolderLocalServiceUtil.getKBFolder(kbFolderId);
kbFolderId = kbFolder.getParentKBFolderId();
}
return false;
}
use of com.liferay.knowledgebase.model.KBFolder in project liferay-ide by liferay.
the class FindKBArticleAction method getKBArticleURL.
protected PortletURL getKBArticleURL(long plid, String portletId, KBArticle kbArticle, HttpServletRequest request) throws Exception {
long resourcePrimKey = ParamUtil.getLong(request, "resourcePrimKey");
String mvcPath = null;
String rootPortletId = PortletConstants.getRootPortletId(portletId);
if (rootPortletId.equals(PortletKeys.KNOWLEDGE_BASE_ARTICLE)) {
mvcPath = "/article/view_article.jsp";
} else if (rootPortletId.equals(PortletKeys.KNOWLEDGE_BASE_SECTION)) {
mvcPath = "/section/view_article.jsp";
}
PortletURL portletURL = PortletURLFactoryUtil.create(request, portletId, plid, PortletRequest.RENDER_PHASE);
if (mvcPath != null) {
portletURL.setParameter("mvcPath", mvcPath);
}
if ((kbArticle == null) || Validator.isNull(kbArticle.getUrlTitle())) {
portletURL.setParameter("resourcePrimKey", String.valueOf(resourcePrimKey));
} else {
portletURL.setParameter("urlTitle", kbArticle.getUrlTitle());
if (kbArticle.getKbFolderId() != KBFolderConstants.DEFAULT_PARENT_FOLDER_ID) {
KBFolder kbFolder = KBFolderLocalServiceUtil.getKBFolder(kbArticle.getKbFolderId());
portletURL.setParameter("kbFolderUrlTitle", String.valueOf(kbFolder.getUrlTitle()));
}
}
portletURL.setPortletMode(PortletMode.VIEW);
portletURL.setWindowState(LiferayWindowState.NORMAL);
if (rootPortletId.equals(PortletKeys.KNOWLEDGE_BASE_SECTION)) {
portletURL.setWindowState(LiferayWindowState.MAXIMIZED);
}
return portletURL;
}
use of com.liferay.knowledgebase.model.KBFolder in project liferay-ide by liferay.
the class KBFolderStagedModelDataHandler method doExportStagedModel.
@Override
protected void doExportStagedModel(PortletDataContext portletDataContext, KBFolder kbFolder) throws Exception {
if (kbFolder.getParentKBFolderId() != KBFolderConstants.DEFAULT_PARENT_FOLDER_ID) {
KBFolder parentKBFolder = KBFolderLocalServiceUtil.getKBFolder(kbFolder.getParentKBFolderId());
StagedModelDataHandlerUtil.exportReferenceStagedModel(portletDataContext, kbFolder, parentKBFolder, PortletDataContext.REFERENCE_TYPE_PARENT);
}
Element kbFolderElement = portletDataContext.getExportDataElement(kbFolder);
portletDataContext.addClassedModel(kbFolderElement, ExportImportPathUtil.getModelPath(kbFolder), kbFolder);
}
use of com.liferay.knowledgebase.model.KBFolder in project liferay-ide by liferay.
the class KBFolderExportActionableDynamicQuery method performAction.
@Override
@SuppressWarnings("unused")
protected void performAction(Object object) throws PortalException, SystemException {
KBFolder stagedModel = (KBFolder) object;
StagedModelDataHandlerUtil.exportStagedModel(_portletDataContext, stagedModel);
}
Aggregations