Search in sources :

Example 1 with WikiPage

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();
}
Also used : KBArticle(com.liferay.knowledgebase.model.KBArticle) WikiPage(com.liferay.portlet.wiki.model.WikiPage) PortletURL(javax.portlet.PortletURL) BlogsEntry(com.liferay.portlet.blogs.model.BlogsEntry) JournalArticle(com.liferay.portlet.journal.model.JournalArticle)

Example 2 with WikiPage

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);
    }
}
Also used : NoSuchPageException(com.liferay.portlet.wiki.NoSuchPageException) ServiceContext(com.liferay.portal.service.ServiceContext) WikiPage(com.liferay.portlet.wiki.model.WikiPage) PortalException(com.liferay.portal.kernel.exception.PortalException) NoSuchPageException(com.liferay.portlet.wiki.NoSuchPageException) ImportFilesException(com.liferay.portlet.wiki.ImportFilesException) PortalException(com.liferay.portal.kernel.exception.PortalException) SystemException(com.liferay.portal.kernel.exception.SystemException) DocumentException(com.liferay.portal.kernel.xml.DocumentException) IOException(java.io.IOException) NoSuchTagException(com.liferay.portlet.asset.NoSuchTagException)

Aggregations

WikiPage (com.liferay.portlet.wiki.model.WikiPage)2 KBArticle (com.liferay.knowledgebase.model.KBArticle)1 PortalException (com.liferay.portal.kernel.exception.PortalException)1 SystemException (com.liferay.portal.kernel.exception.SystemException)1 DocumentException (com.liferay.portal.kernel.xml.DocumentException)1 ServiceContext (com.liferay.portal.service.ServiceContext)1 NoSuchTagException (com.liferay.portlet.asset.NoSuchTagException)1 BlogsEntry (com.liferay.portlet.blogs.model.BlogsEntry)1 JournalArticle (com.liferay.portlet.journal.model.JournalArticle)1 ImportFilesException (com.liferay.portlet.wiki.ImportFilesException)1 NoSuchPageException (com.liferay.portlet.wiki.NoSuchPageException)1 IOException (java.io.IOException)1 PortletURL (javax.portlet.PortletURL)1