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;
}
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();
}
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());
}
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;
}
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;
}
Aggregations