Search in sources :

Example 51 with ThemeDisplay

use of com.liferay.portal.theme.ThemeDisplay in project liferay-ide by liferay.

the class ArticlePortlet method getResourcePrimKey.

protected long getResourcePrimKey(RenderRequest renderRequest) throws Exception {
    ThemeDisplay themeDisplay = (ThemeDisplay) renderRequest.getAttribute(WebKeys.THEME_DISPLAY);
    PortletPreferences preferences = renderRequest.getPreferences();
    long defaultValue = GetterUtil.getLong(preferences.getValue("resourcePrimKey", null));
    String mvcPath = ParamUtil.getString(renderRequest, "mvcPath");
    if (((defaultValue == 0) && mvcPath.equals(viewTemplate)) || mvcPath.equals("/article/select_configuration_article.jsp")) {
        return 0;
    }
    long resourcePrimKey = ParamUtil.getLong(renderRequest, "resourcePrimKey", defaultValue);
    if ((resourcePrimKey == 0) || (resourcePrimKey != defaultValue)) {
        return resourcePrimKey;
    }
    PermissionChecker permissionChecker = themeDisplay.getPermissionChecker();
    if (!KBArticlePermission.contains(permissionChecker, defaultValue, ActionKeys.VIEW)) {
        return 0;
    }
    return defaultValue;
}
Also used : PermissionChecker(com.liferay.portal.security.permission.PermissionChecker) PortletPreferences(javax.portlet.PortletPreferences) ThemeDisplay(com.liferay.portal.theme.ThemeDisplay)

Example 52 with ThemeDisplay

use of com.liferay.portal.theme.ThemeDisplay in project liferay-ide by liferay.

the class AdminPortlet method deleteKBTemplates.

public void deleteKBTemplates(ActionRequest actionRequest, ActionResponse actionResponse) throws Exception {
    ThemeDisplay themeDisplay = (ThemeDisplay) actionRequest.getAttribute(WebKeys.THEME_DISPLAY);
    long[] kbTemplateIds = StringUtil.split(ParamUtil.getString(actionRequest, "kbTemplateIds"), 0L);
    KBTemplateServiceUtil.deleteKBTemplates(themeDisplay.getScopeGroupId(), kbTemplateIds);
}
Also used : ThemeDisplay(com.liferay.portal.theme.ThemeDisplay)

Example 53 with ThemeDisplay

use of com.liferay.portal.theme.ThemeDisplay 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);
    }
}
Also used : WindowStateException(javax.portlet.WindowStateException) PortalException(com.liferay.portal.kernel.exception.PortalException) ThemeDisplay(com.liferay.portal.theme.ThemeDisplay) PortletURL(javax.portlet.PortletURL)

Example 54 with ThemeDisplay

use of com.liferay.portal.theme.ThemeDisplay in project liferay-ide by liferay.

the class AdminPortlet method updateKBFolder.

public void updateKBFolder(ActionRequest actionRequest, ActionResponse actionResponse) throws PortalException, SystemException {
    ThemeDisplay themeDisplay = (ThemeDisplay) actionRequest.getAttribute(WebKeys.THEME_DISPLAY);
    String cmd = ParamUtil.getString(actionRequest, Constants.CMD);
    long kbFolderId = ParamUtil.getLong(actionRequest, "kbFolderId");
    long parentResourceClassNameId = ParamUtil.getLong(actionRequest, "parentResourceClassNameId");
    long parentResourcePrimKey = ParamUtil.getLong(actionRequest, "parentResourcePrimKey");
    String name = ParamUtil.getString(actionRequest, "name");
    String description = ParamUtil.getString(actionRequest, "description");
    ServiceContext serviceContext = ServiceContextFactory.getInstance(KBFolder.class.getName(), actionRequest);
    if (cmd.equals(Constants.ADD)) {
        KBFolderServiceUtil.addKBFolder(themeDisplay.getScopeGroupId(), parentResourceClassNameId, parentResourcePrimKey, name, description, serviceContext);
    } else if (cmd.equals(Constants.UPDATE)) {
        KBFolderServiceUtil.updateKBFolder(parentResourceClassNameId, parentResourcePrimKey, kbFolderId, name, description);
    }
}
Also used : KBFolder(com.liferay.knowledgebase.model.KBFolder) ServiceContext(com.liferay.portal.service.ServiceContext) ThemeDisplay(com.liferay.portal.theme.ThemeDisplay)

Example 55 with ThemeDisplay

use of com.liferay.portal.theme.ThemeDisplay in project liferay-ide by liferay.

the class AdminPortlet method updateKBArticlesPriorities.

public void updateKBArticlesPriorities(ActionRequest actionRequest, ActionResponse actionResponse) throws Exception {
    ThemeDisplay themeDisplay = (ThemeDisplay) actionRequest.getAttribute(WebKeys.THEME_DISPLAY);
    Enumeration<String> enu = actionRequest.getParameterNames();
    Map<Long, Double> resourcePrimKeyToPriorityMap = new HashMap<Long, Double>();
    while (enu.hasMoreElements()) {
        String name = enu.nextElement();
        if (!name.startsWith("priority")) {
            continue;
        }
        double priority = ParamUtil.getDouble(actionRequest, name);
        long resourcePrimKey = GetterUtil.getLong(name.substring(8));
        resourcePrimKeyToPriorityMap.put(resourcePrimKey, priority);
    }
    KBArticleServiceUtil.updateKBArticlesPriorities(themeDisplay.getScopeGroupId(), resourcePrimKeyToPriorityMap);
}
Also used : HashMap(java.util.HashMap) ThemeDisplay(com.liferay.portal.theme.ThemeDisplay)

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