Search in sources :

Example 36 with ThemeDisplay

use of com.liferay.portal.theme.ThemeDisplay in project sw360portal by sw360.

the class CustomFieldHelper method getLiferayUser.

private static com.liferay.portal.model.User getLiferayUser(PortletRequest request, User user) throws PortalException, SystemException {
    ThemeDisplay themeDisplay = (ThemeDisplay) request.getAttribute(WebKeys.THEME_DISPLAY);
    long companyId = themeDisplay.getCompanyId();
    return UserLocalServiceUtil.getUserByEmailAddress(companyId, user.email);
}
Also used : ThemeDisplay(com.liferay.portal.theme.ThemeDisplay)

Example 37 with ThemeDisplay

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

the class BaseKBPortlet method deleteTempAttachment.

public void deleteTempAttachment(ActionRequest actionRequest, ActionResponse actionResponse) throws Exception {
    ThemeDisplay themeDisplay = (ThemeDisplay) actionRequest.getAttribute(WebKeys.THEME_DISPLAY);
    long resourcePrimKey = ParamUtil.getLong(actionRequest, "resourcePrimKey");
    String fileName = ParamUtil.getString(actionRequest, "fileName");
    JSONObject jsonObject = JSONFactoryUtil.createJSONObject();
    try {
        KBArticleServiceUtil.deleteTempAttachment(themeDisplay.getScopeGroupId(), resourcePrimKey, fileName, KnowledgeBaseConstants.TEMP_FOLDER_NAME);
        jsonObject.put("deleted", Boolean.TRUE);
    } catch (Exception e) {
        String errorMessage = themeDisplay.translate("an-unexpected-error-occurred-while-deleting-the-file");
        jsonObject.put("deleted", Boolean.FALSE);
        jsonObject.put("errorMessage", errorMessage);
    }
    writeJSON(actionRequest, actionResponse, jsonObject);
}
Also used : JSONObject(com.liferay.portal.kernel.json.JSONObject) ThemeDisplay(com.liferay.portal.theme.ThemeDisplay) AssetCategoryException(com.liferay.portlet.asset.AssetCategoryException) KBCommentContentException(com.liferay.knowledgebase.KBCommentContentException) FileNameException(com.liferay.portlet.documentlibrary.FileNameException) NoSuchArticleException(com.liferay.knowledgebase.NoSuchArticleException) KBArticlePriorityException(com.liferay.knowledgebase.KBArticlePriorityException) KBArticleTitleException(com.liferay.knowledgebase.KBArticleTitleException) PrincipalException(com.liferay.portal.security.auth.PrincipalException) PortalException(com.liferay.portal.kernel.exception.PortalException) SystemException(com.liferay.portal.kernel.exception.SystemException) NoSuchFileException(com.liferay.portlet.documentlibrary.NoSuchFileException) FileSizeException(com.liferay.portlet.documentlibrary.FileSizeException) KBArticleContentException(com.liferay.knowledgebase.KBArticleContentException) DuplicateFileException(com.liferay.portlet.documentlibrary.DuplicateFileException) IOException(java.io.IOException) UploadException(com.liferay.portal.kernel.upload.UploadException) NoSuchCommentException(com.liferay.knowledgebase.NoSuchCommentException) AssetTagException(com.liferay.portlet.asset.AssetTagException) PortletException(javax.portlet.PortletException)

Example 38 with ThemeDisplay

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

the class BaseKBPortlet method serveKBArticleRSS.

public void serveKBArticleRSS(ResourceRequest resourceRequest, ResourceResponse resourceResponse) throws Exception {
    if (!PortalUtil.isRSSFeedsEnabled()) {
        PortalUtil.sendRSSFeedsDisabledError(resourceRequest, resourceResponse);
        return;
    }
    ThemeDisplay themeDisplay = (ThemeDisplay) resourceRequest.getAttribute(WebKeys.THEME_DISPLAY);
    long resourcePrimKey = ParamUtil.getLong(resourceRequest, "resourcePrimKey");
    int rssDelta = ParamUtil.getInteger(resourceRequest, "rssDelta");
    String rssDisplayStyle = ParamUtil.getString(resourceRequest, "rssDisplayStyle");
    String rssFormat = ParamUtil.getString(resourceRequest, "rssFormat");
    String rss = KBArticleServiceUtil.getKBArticleRSS(resourcePrimKey, WorkflowConstants.STATUS_APPROVED, rssDelta, rssDisplayStyle, rssFormat, themeDisplay);
    PortletResponseUtil.sendFile(resourceRequest, resourceResponse, null, rss.getBytes(StringPool.UTF8), ContentTypes.TEXT_XML_UTF8);
}
Also used : ThemeDisplay(com.liferay.portal.theme.ThemeDisplay)

Example 39 with ThemeDisplay

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

the class BaseKBPortlet method buildEditURL.

protected String buildEditURL(ActionRequest actionRequest, ActionResponse actionResponse, KBArticle kbArticle) throws PortalException, SystemException {
    ThemeDisplay themeDisplay = (ThemeDisplay) actionRequest.getAttribute(WebKeys.THEME_DISPLAY);
    PortletDisplay portletDisplay = themeDisplay.getPortletDisplay();
    String editURL = PortalUtil.getLayoutFullURL(themeDisplay);
    editURL = HttpUtil.setParameter(editURL, "p_p_id", portletDisplay.getId());
    editURL = HttpUtil.setParameter(editURL, actionResponse.getNamespace() + "mvcPath", templatePath + "edit_article.jsp");
    editURL = HttpUtil.setParameter(editURL, actionResponse.getNamespace() + "redirect", getRedirect(actionRequest, actionResponse));
    editURL = HttpUtil.setParameter(editURL, actionResponse.getNamespace() + "resourcePrimKey", kbArticle.getResourcePrimKey());
    editURL = HttpUtil.setParameter(editURL, actionResponse.getNamespace() + "status", WorkflowConstants.STATUS_ANY);
    return editURL;
}
Also used : PortletDisplay(com.liferay.portal.theme.PortletDisplay) ThemeDisplay(com.liferay.portal.theme.ThemeDisplay)

Example 40 with ThemeDisplay

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

the class LiferayPortlet method translate.

protected String translate(PortletRequest portletRequest, String key) {
    PortletConfig portletConfig = (PortletConfig) portletRequest.getAttribute(JavaConstants.JAVAX_PORTLET_CONFIG);
    ThemeDisplay themeDisplay = (ThemeDisplay) portletRequest.getAttribute(WebKeys.THEME_DISPLAY);
    return LanguageUtil.get(portletConfig, themeDisplay.getLocale(), key);
}
Also used : PortletConfig(javax.portlet.PortletConfig) 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