use of com.liferay.knowledgebase.model.KBFolder in project liferay-ide by liferay.
the class KBFolderServiceImpl method fetchKBFolderByUrlTitle.
public KBFolder fetchKBFolderByUrlTitle(long groupId, long parentKbFolderId, String urlTitle) throws PortalException, SystemException {
KBFolder kbFolder = kbFolderLocalService.fetchKBFolderByUrlTitle(groupId, parentKbFolderId, urlTitle);
if (kbFolder == null) {
return null;
}
KBFolderPermission.check(getPermissionChecker(), kbFolder, ActionKeys.VIEW);
return kbFolder;
}
use of com.liferay.knowledgebase.model.KBFolder in project liferay-ide by liferay.
the class KBArticleLocalServiceImpl method getUniqueUrlTitle.
protected String getUniqueUrlTitle(long groupId, long kbFolderId, long kbArticleId, String title) throws PortalException, SystemException {
String urlTitle = KnowledgeBaseUtil.getUrlTitle(kbArticleId, title);
String uniqueUrlTitle = urlTitle;
if (kbFolderId == KBFolderConstants.DEFAULT_PARENT_FOLDER_ID) {
int kbArticlesCount = kbArticlePersistence.countByG_KBFI_UT_ST(groupId, kbFolderId, uniqueUrlTitle, _STATUSES);
for (int i = 1; kbArticlesCount > 0; i++) {
uniqueUrlTitle = urlTitle + StringPool.DASH + i;
kbArticlesCount = kbArticlePersistence.countByG_KBFI_UT_ST(groupId, kbFolderId, uniqueUrlTitle, _STATUSES);
}
return uniqueUrlTitle;
}
KBFolder kbFolder = kbFolderPersistence.findByPrimaryKey(kbFolderId);
int kbArticlesCount = kbArticleFinder.countByUrlTitle(groupId, kbFolder.getUrlTitle(), uniqueUrlTitle, _STATUSES);
for (int i = 1; kbArticlesCount > 0; i++) {
uniqueUrlTitle = urlTitle + StringPool.DASH + i;
kbArticlesCount = kbArticleFinder.countByUrlTitle(groupId, kbFolder.getUrlTitle(), uniqueUrlTitle, _STATUSES);
}
return uniqueUrlTitle;
}
use of com.liferay.knowledgebase.model.KBFolder in project liferay-ide by liferay.
the class DisplayPortlet method updateRootKBFolderId.
public void updateRootKBFolderId(ActionRequest actionRequest, ActionResponse actionResponse) throws IOException, PortalException, SystemException {
long kbFolderId = ParamUtil.getLong(actionRequest, "rootKBFolderId");
if (kbFolderId == KBFolderConstants.DEFAULT_PARENT_FOLDER_ID) {
return;
}
KBFolder kbFolder = KBFolderServiceUtil.getKBFolder(kbFolderId);
PortalPreferences portalPreferences = PortletPreferencesFactoryUtil.getPortalPreferences(PortalUtil.getLiferayPortletRequest(actionRequest));
PortletPreferences portletPreferences = actionRequest.getPreferences();
String contentRootPrefix = GetterUtil.getString(portletPreferences.getValue("contentRootPrefix", null));
String previousPreferredKBFolderURLTitle = KnowledgeBaseUtil.getPreferredKBFolderURLTitle(portalPreferences, contentRootPrefix);
KnowledgeBaseUtil.setPreferredKBFolderURLTitle(portalPreferences, contentRootPrefix, kbFolder.getUrlTitle());
String urlTitle = ParamUtil.getString(actionRequest, "urlTitle");
if (Validator.isNull(urlTitle)) {
return;
}
KBArticle kbArticle = KBArticleLocalServiceUtil.fetchKBArticleByUrlTitle(kbFolder.getGroupId(), kbFolder.getUrlTitle(), urlTitle);
if (kbArticle == null) {
if (Validator.isNull(previousPreferredKBFolderURLTitle)) {
return;
}
kbArticle = findClosestMatchingKBArticle(kbFolder.getGroupId(), previousPreferredKBFolderURLTitle, kbFolder.getKbFolderId(), urlTitle);
if (kbArticle == null) {
return;
}
}
ThemeDisplay themeDisplay = (ThemeDisplay) actionRequest.getAttribute(WebKeys.THEME_DISPLAY);
if (!KBArticlePermission.contains(themeDisplay.getPermissionChecker(), kbArticle, ActionKeys.VIEW)) {
return;
}
PortletURL redirectURL = PortletURLFactoryUtil.create(actionRequest, PortletKeys.KNOWLEDGE_BASE_DISPLAY, themeDisplay.getPlid(), PortletRequest.RENDER_PHASE);
redirectURL.setParameter("kbFolderUrlTitle", kbFolder.getUrlTitle());
redirectURL.setParameter("urlTitle", kbArticle.getUrlTitle());
actionResponse.sendRedirect(redirectURL.toString());
}
use of com.liferay.knowledgebase.model.KBFolder in project liferay-ide by liferay.
the class KBFolderModelImpl method equals.
@Override
public boolean equals(Object obj) {
if (this == obj) {
return true;
}
if (!(obj instanceof KBFolder)) {
return false;
}
KBFolder kbFolder = (KBFolder) obj;
long primaryKey = kbFolder.getPrimaryKey();
if (getPrimaryKey() == primaryKey) {
return true;
} else {
return false;
}
}
use of com.liferay.knowledgebase.model.KBFolder in project liferay-ide by liferay.
the class KBFolderModelImpl method toModel.
/**
* Converts the soap model instance into a normal model instance.
*
* @param soapModel the soap model instance to convert
* @return the normal model instance
*/
public static KBFolder toModel(KBFolderSoap soapModel) {
if (soapModel == null) {
return null;
}
KBFolder model = new KBFolderImpl();
model.setUuid(soapModel.getUuid());
model.setKbFolderId(soapModel.getKbFolderId());
model.setGroupId(soapModel.getGroupId());
model.setCompanyId(soapModel.getCompanyId());
model.setUserId(soapModel.getUserId());
model.setUserName(soapModel.getUserName());
model.setCreateDate(soapModel.getCreateDate());
model.setModifiedDate(soapModel.getModifiedDate());
model.setParentKBFolderId(soapModel.getParentKBFolderId());
model.setName(soapModel.getName());
model.setUrlTitle(soapModel.getUrlTitle());
model.setDescription(soapModel.getDescription());
return model;
}
Aggregations