use of com.liferay.portlet.wiki.model.WikiPage in project liferay-ide by liferay.
the class KBArticleAssetEntriesUtil method getURL.
public static String getURL(HttpServletRequest request, ThemeDisplay themeDisplay, AssetRendererFactory assetRendererFactory, AssetRenderer assetRenderer) throws Exception {
long classPK = assetRenderer.getClassPK();
String className = assetRendererFactory.getClassName();
PortletURL portletURL = null;
if (className.equals(BlogsEntry.class.getName())) {
portletURL = PortletURLFactoryUtil.create(request, PortletKeys.BLOGS, themeDisplay.getPlid(), PortletRequest.RENDER_PHASE);
portletURL.setParameter("struts_action", "/blogs/view_entry");
portletURL.setParameter("entryId", String.valueOf(classPK));
} else if (className.equals(JournalArticle.class.getName())) {
JournalArticle journalArticle = JournalArticleLocalServiceUtil.getLatestArticle(classPK);
portletURL = PortletURLFactoryUtil.create(request, PortletKeys.JOURNAL_CONTENT, themeDisplay.getPlid(), PortletRequest.RENDER_PHASE);
portletURL.setParameter("struts_action", "/journal_content/view");
portletURL.setParameter("groupId", String.valueOf(journalArticle.getGroupId()));
portletURL.setParameter("articleId", journalArticle.getArticleId());
} else if (className.equals(KBArticle.class.getName())) {
portletURL = PortletURLFactoryUtil.create(request, PortletKeys.KNOWLEDGE_BASE_ARTICLE_DEFAULT_INSTANCE, themeDisplay.getPlid(), PortletRequest.RENDER_PHASE);
portletURL.setParameter("mvcPath", "/article/view_article.jsp");
portletURL.setParameter("resourcePrimKey", String.valueOf(classPK));
} else if (className.equals(MBMessage.class.getName())) {
portletURL = PortletURLFactoryUtil.create(request, PortletKeys.MESSAGE_BOARDS, themeDisplay.getPlid(), PortletRequest.RENDER_PHASE);
portletURL.setParameter("struts_action", "/message_boards/view_message");
portletURL.setParameter("messageId", String.valueOf(classPK));
} else if (className.equals(WikiPage.class.getName())) {
WikiPage wikiPage = WikiPageLocalServiceUtil.getPage(classPK);
portletURL = PortletURLFactoryUtil.create(request, PortletKeys.WIKI, themeDisplay.getPlid(), PortletRequest.RENDER_PHASE);
portletURL.setParameter("struts_action", "/wiki/view");
portletURL.setParameter("nodeId", String.valueOf(wikiPage.getNodeId()));
portletURL.setParameter("title", wikiPage.getTitle());
}
String currentURL = PortalUtil.getCurrentURL(request);
if (portletURL == null) {
return currentURL;
}
portletURL.setWindowState(WindowState.MAXIMIZED);
portletURL.setPortletMode(PortletMode.VIEW);
portletURL.setParameter("returnToFullPageURL", currentURL);
return portletURL.toString();
}
use of com.liferay.portlet.wiki.model.WikiPage in project liferay-ide by liferay.
the class MediaWikiImporter method importPage.
protected void importPage(long userId, String author, WikiNode node, String title, String content, String summary, Map<String, String> usersMap, boolean strictImportMode) throws PortalException {
try {
long authorUserId = getUserId(userId, node, author, usersMap);
String parentTitle = readParentTitle(content);
String redirectTitle = readRedirectTitle(content);
ServiceContext serviceContext = new ServiceContext();
serviceContext.setAddGroupPermissions(true);
serviceContext.setAddGuestPermissions(true);
serviceContext.setAssetTagNames(readAssetTagNames(userId, node, content));
if (Validator.isNull(redirectTitle)) {
_translator.setStrictImportMode(strictImportMode);
content = _translator.translate(content);
} else {
content = StringPool.DOUBLE_OPEN_BRACKET + redirectTitle + StringPool.DOUBLE_CLOSE_BRACKET;
}
WikiPage page = null;
try {
page = WikiPageLocalServiceUtil.getPage(node.getNodeId(), title);
} catch (NoSuchPageException nspe) {
page = WikiPageLocalServiceUtil.addPage(authorUserId, node.getNodeId(), title, WikiPageConstants.NEW, null, true, serviceContext);
}
WikiPageLocalServiceUtil.updatePage(authorUserId, node.getNodeId(), title, page.getVersion(), content, summary, true, "creole", parentTitle, redirectTitle, serviceContext);
} catch (Exception e) {
throw new PortalException("Error importing page " + title, e);
}
}
Aggregations