Search in sources :

Example 26 with ThemeDisplay

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;
}
Also used : PermissionChecker(com.liferay.portal.security.permission.PermissionChecker) ThemeDisplay(com.liferay.portal.theme.ThemeDisplay)

Example 27 with ThemeDisplay

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;
}
Also used : PermissionChecker(com.liferay.portal.security.permission.PermissionChecker) ThemeDisplay(com.liferay.portal.theme.ThemeDisplay)

Example 28 with ThemeDisplay

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;
}
Also used : PermissionChecker(com.liferay.portal.security.permission.PermissionChecker) ThemeDisplay(com.liferay.portal.theme.ThemeDisplay)

Example 29 with ThemeDisplay

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());
}
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 30 with ThemeDisplay

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

Aggregations

ThemeDisplay (com.liferay.portal.theme.ThemeDisplay)63 PermissionChecker (com.liferay.portal.security.permission.PermissionChecker)10 ServiceContext (com.liferay.portal.service.ServiceContext)7 JSONObject (com.liferay.portal.kernel.json.JSONObject)6 PortletURL (javax.portlet.PortletURL)6 PortalException (com.liferay.portal.kernel.exception.PortalException)5 User (com.liferay.portal.model.User)5 Gadget (com.liferay.opensocial.model.Gadget)4 SystemException (com.liferay.portal.kernel.exception.SystemException)4 UploadPortletRequest (com.liferay.portal.kernel.upload.UploadPortletRequest)4 PortletConfig (javax.portlet.PortletConfig)4 KBArticle (com.liferay.knowledgebase.model.KBArticle)3 KBFolder (com.liferay.knowledgebase.model.KBFolder)3 Role (com.liferay.portal.model.Role)3 HashMap (java.util.HashMap)3 LiferayPortletURL (com.liferay.portal.kernel.portlet.LiferayPortletURL)2 FileEntry (com.liferay.portal.kernel.repository.model.FileEntry)2 Folder (com.liferay.portal.kernel.repository.model.Folder)2 Layout (com.liferay.portal.model.Layout)2 SocialActivity (com.liferay.portlet.social.model.SocialActivity)2