Search in sources :

Example 6 with PortletURL

use of javax.portlet.PortletURL in project liferay-ide by liferay.

the class ArtistAssetRenderer method getURLEdit.

@Override
public PortletURL getURLEdit(LiferayPortletRequest liferayPortletRequest, LiferayPortletResponse liferayPortletResponse) throws Exception {
    PortletURL portletURL = liferayPortletResponse.createLiferayPortletURL(getControlPanelPlid(liferayPortletRequest), ArtistsPortlet.PORTLET_ID, PortletRequest.RENDER_PHASE);
    portletURL.setParameter("jspPage", "/html/artists/edit_artist.jsp");
    portletURL.setParameter("artistId", String.valueOf(_artist.getArtistId()));
    return portletURL;
}
Also used : PortletURL(javax.portlet.PortletURL)

Example 7 with PortletURL

use of javax.portlet.PortletURL 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 8 with PortletURL

use of javax.portlet.PortletURL 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());
}
Also used : KBFolder(com.liferay.knowledgebase.model.KBFolder) KBArticle(com.liferay.knowledgebase.model.KBArticle) PortalPreferences(com.liferay.portlet.PortalPreferences) PortletPreferences(javax.portlet.PortletPreferences) ThemeDisplay(com.liferay.portal.theme.ThemeDisplay) PortletURL(javax.portlet.PortletURL)

Example 9 with PortletURL

use of javax.portlet.PortletURL in project liferay-ide by liferay.

the class FindKBArticleAction method getDynamicPortletURL.

protected PortletURL getDynamicPortletURL(long plid, int status, HttpServletRequest request) throws Exception {
    String portletId = getPortletId(plid);
    PortletURL portletURL = getKBArticleURL(plid, portletId, null, request);
    if (status != WorkflowConstants.STATUS_APPROVED) {
        portletURL.setParameter("status", String.valueOf(status));
    }
    if (_PORTLET_ADD_DEFAULT_RESOURCE_CHECK_ENABLED) {
        String token = AuthTokenUtil.getToken(request, plid, portletId);
        portletURL.setParameter("p_p_auth", token);
    }
    portletURL.setPortletMode(PortletMode.VIEW);
    if (Validator.equals(portletId, PortletKeys.KNOWLEDGE_BASE_ARTICLE_DEFAULT_INSTANCE)) {
        portletURL.setWindowState(LiferayWindowState.MAXIMIZED);
    }
    return portletURL;
}
Also used : PortletURL(javax.portlet.PortletURL)

Example 10 with PortletURL

use of javax.portlet.PortletURL in project liferay-ide by liferay.

the class FindKBArticleAction method execute.

@Override
public String execute(StrutsAction originalStrutsAction, HttpServletRequest request, HttpServletResponse response) throws Exception {
    ThemeDisplay themeDisplay = (ThemeDisplay) request.getAttribute(WebKeys.THEME_DISPLAY);
    long plid = ParamUtil.getLong(request, "plid");
    long resourcePrimKey = ParamUtil.getLong(request, "resourcePrimKey");
    int status = ParamUtil.getInteger(request, "status", WorkflowConstants.STATUS_APPROVED);
    boolean maximized = ParamUtil.getBoolean(request, "maximized");
    KBArticle kbArticle = getKBArticle(resourcePrimKey, status);
    if (!isValidPlid(plid)) {
        plid = themeDisplay.getPlid();
    }
    PortletURL portletURL = null;
    if (kbArticle == null) {
        portletURL = getDynamicPortletURL(plid, status, request);
    }
    if (status != WorkflowConstants.STATUS_APPROVED) {
        portletURL = getDynamicPortletURL(plid, status, request);
    }
    if (portletURL == null) {
        portletURL = getKBArticleURL(plid, false, kbArticle, request);
    }
    if (portletURL == null) {
        portletURL = getKBArticleURL(plid, true, kbArticle, request);
    }
    if (portletURL == null) {
        portletURL = getDynamicPortletURL(plid, status, request);
    }
    if (maximized) {
        portletURL.setWindowState(LiferayWindowState.MAXIMIZED);
        portletURL.setPortletMode(PortletMode.VIEW);
    }
    response.sendRedirect(portletURL.toString());
    return null;
}
Also used : KBArticle(com.liferay.knowledgebase.model.KBArticle) ThemeDisplay(com.liferay.portal.theme.ThemeDisplay) PortletURL(javax.portlet.PortletURL)

Aggregations

PortletURL (javax.portlet.PortletURL)26 ThemeDisplay (com.liferay.portal.theme.ThemeDisplay)6 KBArticle (com.liferay.knowledgebase.model.KBArticle)5 PortalException (com.liferay.portal.kernel.exception.PortalException)5 KBFolder (com.liferay.knowledgebase.model.KBFolder)4 SystemException (com.liferay.portal.kernel.exception.SystemException)3 WindowStateException (javax.portlet.WindowStateException)3 PortletPreferences (javax.portlet.PortletPreferences)2 Album (org.liferay.jukebox.model.Album)2 Song (org.liferay.jukebox.model.Song)2 JSONObject (com.liferay.portal.kernel.json.JSONObject)1 LiferayPortletURL (com.liferay.portal.kernel.portlet.LiferayPortletURL)1 FileEntry (com.liferay.portal.kernel.repository.model.FileEntry)1 FileVersion (com.liferay.portal.kernel.repository.model.FileVersion)1 ThemeDisplay (com.liferay.portal.kernel.theme.ThemeDisplay)1 Layout (com.liferay.portal.model.Layout)1 LayoutTypePortlet (com.liferay.portal.model.LayoutTypePortlet)1 Portlet (com.liferay.portal.model.Portlet)1 PortalPreferences (com.liferay.portlet.PortalPreferences)1 BlogsEntry (com.liferay.portlet.blogs.model.BlogsEntry)1