use of com.liferay.portal.theme.ThemeDisplay in project liferay-ide by liferay.
the class SearchPortlet method getStatus.
protected int getStatus(RenderRequest renderRequest) throws Exception {
ThemeDisplay themeDisplay = (ThemeDisplay) renderRequest.getAttribute(WebKeys.THEME_DISPLAY);
if (!themeDisplay.isSignedIn()) {
return WorkflowConstants.STATUS_APPROVED;
}
String value = renderRequest.getParameter("status");
int status = GetterUtil.getInteger(value);
if ((value != null) && (status == WorkflowConstants.STATUS_APPROVED)) {
return WorkflowConstants.STATUS_APPROVED;
}
long resourcePrimKey = ParamUtil.getLong(renderRequest, "resourcePrimKey");
if (resourcePrimKey == 0) {
return WorkflowConstants.STATUS_APPROVED;
}
PermissionChecker permissionChecker = themeDisplay.getPermissionChecker();
if (KBArticlePermission.contains(permissionChecker, resourcePrimKey, ActionKeys.UPDATE)) {
return ParamUtil.getInteger(renderRequest, "status", WorkflowConstants.STATUS_ANY);
}
return WorkflowConstants.STATUS_APPROVED;
}
use of com.liferay.portal.theme.ThemeDisplay in project liferay-ide by liferay.
the class SectionPortlet method getStatus.
protected int getStatus(RenderRequest renderRequest) throws Exception {
ThemeDisplay themeDisplay = (ThemeDisplay) renderRequest.getAttribute(WebKeys.THEME_DISPLAY);
if (!themeDisplay.isSignedIn()) {
return WorkflowConstants.STATUS_APPROVED;
}
String value = renderRequest.getParameter("status");
int status = GetterUtil.getInteger(value);
if ((value != null) && (status == WorkflowConstants.STATUS_APPROVED)) {
return WorkflowConstants.STATUS_APPROVED;
}
long resourcePrimKey = ParamUtil.getLong(renderRequest, "resourcePrimKey");
if (resourcePrimKey == 0) {
return WorkflowConstants.STATUS_APPROVED;
}
PermissionChecker permissionChecker = themeDisplay.getPermissionChecker();
if (KBArticlePermission.contains(permissionChecker, resourcePrimKey, ActionKeys.UPDATE)) {
return ParamUtil.getInteger(renderRequest, "status", WorkflowConstants.STATUS_ANY);
}
return WorkflowConstants.STATUS_APPROVED;
}
use of com.liferay.portal.theme.ThemeDisplay in project liferay-ide by liferay.
the class ArticlePortlet method getStatus.
protected int getStatus(RenderRequest renderRequest) throws Exception {
ThemeDisplay themeDisplay = (ThemeDisplay) renderRequest.getAttribute(WebKeys.THEME_DISPLAY);
if (!themeDisplay.isSignedIn()) {
return WorkflowConstants.STATUS_APPROVED;
}
String value = renderRequest.getParameter("status");
int status = GetterUtil.getInteger(value);
if ((value != null) && (status == WorkflowConstants.STATUS_APPROVED)) {
return WorkflowConstants.STATUS_APPROVED;
}
long resourcePrimKey = getResourcePrimKey(renderRequest);
if (resourcePrimKey == 0) {
return WorkflowConstants.STATUS_APPROVED;
}
PermissionChecker permissionChecker = themeDisplay.getPermissionChecker();
if (KBArticlePermission.contains(permissionChecker, resourcePrimKey, ActionKeys.UPDATE)) {
return ParamUtil.getInteger(renderRequest, "status", WorkflowConstants.STATUS_ANY);
}
return WorkflowConstants.STATUS_APPROVED;
}
use of com.liferay.portal.theme.ThemeDisplay 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 com.liferay.portal.theme.ThemeDisplay 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