use of javax.portlet.PortletURL in project liferay-ide by liferay.
the class FindKBArticleAction method getKBArticleURL.
protected PortletURL getKBArticleURL(long plid, boolean privateLayout, KBArticle kbArticle, HttpServletRequest request) throws Exception {
PortletURL firstMatchPortletURL = null;
List<Layout> layouts = getCandidateLayouts(plid, privateLayout, kbArticle);
for (Layout layout : layouts) {
LayoutTypePortlet layoutTypePortlet = (LayoutTypePortlet) layout.getLayoutType();
List<Portlet> portlets = layoutTypePortlet.getAllPortlets();
for (Portlet portlet : portlets) {
String rootPortletId = PortletConstants.getRootPortletId(portlet.getPortletId());
if (rootPortletId.equals(PortletKeys.KNOWLEDGE_BASE_DISPLAY)) {
PortletPreferences portletPreferences = PortletPreferencesFactoryUtil.getPortletSetup(layout, portlet.getPortletId(), StringPool.BLANK);
long kbFolderClassNameId = PortalUtil.getClassNameId(KBFolderConstants.getClassName());
long resourceClassNameId = GetterUtil.getLong(portletPreferences.getValue("resourceClassNameId", null), kbFolderClassNameId);
long resourcePrimKey = GetterUtil.getLong(portletPreferences.getValue("resourcePrimKey", null), KBFolderConstants.DEFAULT_PARENT_FOLDER_ID);
if (resourceClassNameId == kbFolderClassNameId) {
if (isParentFolder(resourcePrimKey, kbArticle.getKbFolderId())) {
return getKBArticleURL(layout.getPlid(), portlet.getPortletId(), kbArticle, request);
}
} else if (resourcePrimKey == kbArticle.getResourcePrimKey()) {
return getKBArticleURL(layout.getPlid(), portlet.getPortletId(), kbArticle, request);
}
if (firstMatchPortletURL == null) {
firstMatchPortletURL = getKBArticleURL(layout.getPlid(), portlet.getPortletId(), kbArticle, request);
}
}
if (rootPortletId.equals(PortletKeys.KNOWLEDGE_BASE_SECTION)) {
PortletPreferences portletPreferences = PortletPreferencesFactoryUtil.getPortletSetup(layout, portlet.getPortletId(), StringPool.BLANK);
String[] kbArticlesSections = portletPreferences.getValues("kbArticlesSections", new String[0]);
KBArticle rootKBArticle = KBArticleLocalServiceUtil.fetchLatestKBArticle(kbArticle.getRootResourcePrimKey(), WorkflowConstants.STATUS_APPROVED);
if (rootKBArticle == null) {
continue;
}
String[] sections = AdminUtil.unescapeSections(rootKBArticle.getSections());
for (String section : sections) {
if (!ArrayUtil.contains(kbArticlesSections, section)) {
continue;
}
return getKBArticleURL(layout.getPlid(), portlet.getPortletId(), kbArticle, request);
}
}
if (rootPortletId.equals(PortletKeys.KNOWLEDGE_BASE_ARTICLE)) {
PortletPreferences portletPreferences = PortletPreferencesFactoryUtil.getPortletSetup(layout, portlet.getPortletId(), StringPool.BLANK);
long resourcePrimKey = GetterUtil.getLong(portletPreferences.getValue("resourcePrimKey", null));
KBArticle selKBArticle = KBArticleLocalServiceUtil.fetchLatestKBArticle(resourcePrimKey, WorkflowConstants.STATUS_APPROVED);
if (selKBArticle == null) {
continue;
}
long rootResourcePrimKey = kbArticle.getRootResourcePrimKey();
long selRootResourcePrimKey = selKBArticle.getRootResourcePrimKey();
if (rootResourcePrimKey == selRootResourcePrimKey) {
return getKBArticleURL(layout.getPlid(), portlet.getPortletId(), kbArticle, request);
}
if (firstMatchPortletURL == null) {
firstMatchPortletURL = getKBArticleURL(layout.getPlid(), portlet.getPortletId(), kbArticle, request);
}
}
}
}
return firstMatchPortletURL;
}
use of javax.portlet.PortletURL in project liferay-ide by liferay.
the class FindKBArticleAction method getKBArticleURL.
protected PortletURL getKBArticleURL(long plid, String portletId, KBArticle kbArticle, HttpServletRequest request) throws Exception {
long resourcePrimKey = ParamUtil.getLong(request, "resourcePrimKey");
String mvcPath = null;
String rootPortletId = PortletConstants.getRootPortletId(portletId);
if (rootPortletId.equals(PortletKeys.KNOWLEDGE_BASE_ARTICLE)) {
mvcPath = "/article/view_article.jsp";
} else if (rootPortletId.equals(PortletKeys.KNOWLEDGE_BASE_SECTION)) {
mvcPath = "/section/view_article.jsp";
}
PortletURL portletURL = PortletURLFactoryUtil.create(request, portletId, plid, PortletRequest.RENDER_PHASE);
if (mvcPath != null) {
portletURL.setParameter("mvcPath", mvcPath);
}
if ((kbArticle == null) || Validator.isNull(kbArticle.getUrlTitle())) {
portletURL.setParameter("resourcePrimKey", String.valueOf(resourcePrimKey));
} else {
portletURL.setParameter("urlTitle", kbArticle.getUrlTitle());
if (kbArticle.getKbFolderId() != KBFolderConstants.DEFAULT_PARENT_FOLDER_ID) {
KBFolder kbFolder = KBFolderLocalServiceUtil.getKBFolder(kbArticle.getKbFolderId());
portletURL.setParameter("kbFolderUrlTitle", String.valueOf(kbFolder.getUrlTitle()));
}
}
portletURL.setPortletMode(PortletMode.VIEW);
portletURL.setWindowState(LiferayWindowState.NORMAL);
if (rootPortletId.equals(PortletKeys.KNOWLEDGE_BASE_SECTION)) {
portletURL.setWindowState(LiferayWindowState.MAXIMIZED);
}
return portletURL;
}
use of javax.portlet.PortletURL in project liferay-ide by liferay.
the class AdminPortlet method buildEditURL.
@Override
protected String buildEditURL(ActionRequest actionRequest, ActionResponse actionResponse, KBArticle kbArticle) throws PortalException, SystemException {
try {
ThemeDisplay themeDisplay = (ThemeDisplay) actionRequest.getAttribute(WebKeys.THEME_DISPLAY);
PortletURL portletURL = PortletURLFactoryUtil.create(actionRequest, PortletKeys.KNOWLEDGE_BASE_ADMIN, themeDisplay.getPlid(), PortletRequest.RENDER_PHASE);
portletURL.setParameter("mvcPath", templatePath + "edit_article.jsp");
portletURL.setParameter("redirect", getRedirect(actionRequest, actionResponse));
portletURL.setParameter("resourcePrimKey", String.valueOf(kbArticle.getResourcePrimKey()));
portletURL.setWindowState(actionRequest.getWindowState());
return portletURL.toString();
} catch (WindowStateException wse) {
throw new PortalException(wse);
}
}
use of javax.portlet.PortletURL in project liferay-ide by liferay.
the class KnowledgeBaseUtil method addPortletBreadcrumbEntries.
protected static void addPortletBreadcrumbEntries(Map<String, Object> parameters, HttpServletRequest request, RenderResponse renderResponse) throws PortalException, SystemException {
PortletURL portletURL = renderResponse.createRenderURL();
for (Map.Entry<String, Object> entry : parameters.entrySet()) {
Object value = entry.getValue();
portletURL.setParameter(entry.getKey(), value.toString());
}
long kbFolderClassNameId = PortalUtil.getClassNameId(KBFolderConstants.getClassName());
long parentResourceClassNameId = (Long) parameters.get("parentResourceClassNameId");
long parentResourcePrimKey = (Long) parameters.get("parentResourcePrimKey");
String mvcPath = (String) parameters.get("mvcPath");
if (parentResourcePrimKey == KBFolderConstants.DEFAULT_PARENT_FOLDER_ID) {
ThemeDisplay themeDisplay = (ThemeDisplay) request.getAttribute(WebKeys.THEME_DISPLAY);
PortalUtil.addPortletBreadcrumbEntry(request, themeDisplay.translate("home"), portletURL.toString());
} else if (parentResourceClassNameId == kbFolderClassNameId) {
KBFolder kbFolder = KBFolderServiceUtil.getKBFolder(parentResourcePrimKey);
addPortletBreadcrumbEntries(kbFolder.getClassNameId(), kbFolder.getParentKBFolderId(), mvcPath, request, renderResponse);
PortalUtil.addPortletBreadcrumbEntry(request, kbFolder.getName(), portletURL.toString());
} else {
KBArticle kbArticle = KBArticleServiceUtil.getLatestKBArticle(parentResourcePrimKey, WorkflowConstants.STATUS_ANY);
addPortletBreadcrumbEntries(kbArticle.getParentResourceClassNameId(), kbArticle.getParentResourcePrimKey(), mvcPath, request, renderResponse);
PortalUtil.addPortletBreadcrumbEntry(request, kbArticle.getTitle(), portletURL.toString());
}
}
use of javax.portlet.PortletURL in project liferay-ide by liferay.
the class JournalArticleAssetRendererFactory method getURLAdd.
@Override
public PortletURL getURLAdd(LiferayPortletRequest liferayPortletRequest, LiferayPortletResponse liferayPortletResponse) throws PortalException, SystemException {
ThemeDisplay themeDisplay = (ThemeDisplay) liferayPortletRequest.getAttribute(WebKeys.THEME_DISPLAY);
if (!JournalPermission.contains(themeDisplay.getPermissionChecker(), themeDisplay.getScopeGroupId(), ActionKeys.ADD_ARTICLE)) {
return null;
}
long classTypeId = GetterUtil.getLong(liferayPortletRequest.getAttribute(WebKeys.ASSET_RENDERER_FACTORY_CLASS_TYPE_ID));
if ((classTypeId > 0) && !DDMStructurePermission.contains(themeDisplay.getPermissionChecker(), classTypeId, ActionKeys.VIEW)) {
return null;
}
PortletURL portletURL = liferayPortletResponse.createRenderURL(PortletKeys.JOURNAL);
portletURL.setParameter("struts_action", "/journal/edit_article");
return portletURL;
}
Aggregations