Search in sources :

Example 1 with ThemeDisplay

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

the class KBArticleAssetRendererFactory method getURLAdd.

@Override
public PortletURL getURLAdd(LiferayPortletRequest liferayPortletRequest, LiferayPortletResponse liferayPortletResponse) throws PortalException, SystemException {
    ThemeDisplay themeDisplay = (ThemeDisplay) liferayPortletRequest.getAttribute(WebKeys.THEME_DISPLAY);
    if (!AdminPermission.contains(themeDisplay.getPermissionChecker(), themeDisplay.getScopeGroupId(), ActionKeys.ADD_KB_ARTICLE)) {
        return null;
    }
    PortletURL portletURL = PortletURLFactoryUtil.create(liferayPortletRequest, PortletKeys.KNOWLEDGE_BASE_ADMIN, getControlPanelPlid(themeDisplay), PortletRequest.RENDER_PHASE);
    portletURL.setParameter("mvcPath", "/admin/edit_article.jsp");
    return portletURL;
}
Also used : ThemeDisplay(com.liferay.portal.theme.ThemeDisplay) PortletURL(javax.portlet.PortletURL)

Example 2 with ThemeDisplay

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

the class AdminPortlet method unsubscribeGroupKBArticles.

public void unsubscribeGroupKBArticles(ActionRequest actionRequest, ActionResponse actionResponse) throws Exception {
    ThemeDisplay themeDisplay = (ThemeDisplay) actionRequest.getAttribute(WebKeys.THEME_DISPLAY);
    String portletId = PortalUtil.getPortletId(actionRequest);
    KBArticleServiceUtil.unsubscribeGroupKBArticles(themeDisplay.getScopeGroupId(), portletId);
}
Also used : ThemeDisplay(com.liferay.portal.theme.ThemeDisplay)

Example 3 with ThemeDisplay

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

the class AdminPortlet method importFile.

public void importFile(ActionRequest actionRequest, ActionResponse actionResponse) throws Exception {
    InputStream inputStream = null;
    try {
        ThemeDisplay themeDisplay = (ThemeDisplay) actionRequest.getAttribute(WebKeys.THEME_DISPLAY);
        UploadPortletRequest uploadPortletRequest = PortalUtil.getUploadPortletRequest(actionRequest);
        long parentKBFolderId = ParamUtil.getLong(uploadPortletRequest, "parentKBFolderId", KBFolderConstants.DEFAULT_PARENT_FOLDER_ID);
        String fileName = uploadPortletRequest.getFileName("file");
        if (Validator.isNull(fileName)) {
            throw new KBArticleImportException("File name is null");
        }
        boolean prioritizeByNumericalPrefix = ParamUtil.getBoolean(uploadPortletRequest, "prioritizeByNumericalPrefix");
        inputStream = uploadPortletRequest.getFileAsStream("file");
        ServiceContext serviceContext = ServiceContextFactory.getInstance(AdminPortlet.class.getName(), actionRequest);
        serviceContext.setGuestPermissions(new String[] { ActionKeys.VIEW });
        int kbArticleCount = KBArticleServiceUtil.addKBArticlesMarkdown(themeDisplay.getScopeGroupId(), parentKBFolderId, fileName, prioritizeByNumericalPrefix, inputStream, serviceContext);
        SessionMessages.add(actionRequest, "importedKBArticlesCount", kbArticleCount);
    } catch (KBArticleImportException kbaie) {
        SessionErrors.add(actionRequest, kbaie.getClass(), kbaie);
    } finally {
        StreamUtil.cleanUp(inputStream);
    }
}
Also used : InputStream(java.io.InputStream) ServiceContext(com.liferay.portal.service.ServiceContext) KBArticleImportException(com.liferay.knowledgebase.KBArticleImportException) ThemeDisplay(com.liferay.portal.theme.ThemeDisplay) UploadPortletRequest(com.liferay.portal.kernel.upload.UploadPortletRequest)

Example 4 with ThemeDisplay

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

the class AdminPortlet method subscribeGroupKBArticles.

public void subscribeGroupKBArticles(ActionRequest actionRequest, ActionResponse actionResponse) throws Exception {
    ThemeDisplay themeDisplay = (ThemeDisplay) actionRequest.getAttribute(WebKeys.THEME_DISPLAY);
    String portletId = PortalUtil.getPortletId(actionRequest);
    KBArticleServiceUtil.subscribeGroupKBArticles(themeDisplay.getScopeGroupId(), portletId);
}
Also used : ThemeDisplay(com.liferay.portal.theme.ThemeDisplay)

Example 5 with ThemeDisplay

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

the class AdminPortlet method deleteKBArticles.

public void deleteKBArticles(ActionRequest actionRequest, ActionResponse actionResponse) throws Exception {
    ThemeDisplay themeDisplay = (ThemeDisplay) actionRequest.getAttribute(WebKeys.THEME_DISPLAY);
    long[] resourcePrimKeys = StringUtil.split(ParamUtil.getString(actionRequest, "resourcePrimKeys"), 0L);
    KBArticleServiceUtil.deleteKBArticles(themeDisplay.getScopeGroupId(), resourcePrimKeys);
}
Also used : 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