Search in sources :

Example 21 with ThemeDisplay

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

the class SongAssetRenderer method getThumbnailPath.

@Override
public String getThumbnailPath(PortletRequest portletRequest) throws Exception {
    ThemeDisplay themeDisplay = (ThemeDisplay) portletRequest.getAttribute(WebKeys.THEME_DISPLAY);
    String thumbnailSrc = _song.getImageURL(themeDisplay);
    if (Validator.isNotNull(thumbnailSrc)) {
        return thumbnailSrc;
    }
    return themeDisplay.getPortalURL() + "/jukebox-portlet/icons/songs.png";
}
Also used : ThemeDisplay(com.liferay.portal.theme.ThemeDisplay)

Example 22 with ThemeDisplay

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

the class BaseKBPortlet method updateKBComment.

public void updateKBComment(ActionRequest actionRequest, ActionResponse actionResponse) throws Exception {
    ThemeDisplay themeDisplay = (ThemeDisplay) actionRequest.getAttribute(WebKeys.THEME_DISPLAY);
    if (!themeDisplay.isSignedIn()) {
        return;
    }
    String cmd = ParamUtil.getString(actionRequest, Constants.CMD);
    long kbCommentId = ParamUtil.getLong(actionRequest, "kbCommentId");
    long classNameId = ParamUtil.getLong(actionRequest, "classNameId");
    long classPK = ParamUtil.getLong(actionRequest, "classPK");
    String content = ParamUtil.getString(actionRequest, "content");
    int status = ParamUtil.getInteger(actionRequest, "status", KBCommentConstants.STATUS_ANY);
    ServiceContext serviceContext = ServiceContextFactory.getInstance(KBComment.class.getName(), actionRequest);
    if (cmd.equals(Constants.ADD)) {
        KBCommentLocalServiceUtil.addKBComment(themeDisplay.getUserId(), classNameId, classPK, content, serviceContext);
    } else if (cmd.equals(Constants.UPDATE)) {
        if (status == KBCommentConstants.STATUS_ANY) {
            KBComment kbComment = KBCommentServiceUtil.getKBComment(kbCommentId);
            status = kbComment.getStatus();
        }
        KBCommentServiceUtil.updateKBComment(kbCommentId, classNameId, classPK, content, status, serviceContext);
    }
    SessionMessages.add(actionRequest, "suggestionSaved");
}
Also used : KBComment(com.liferay.knowledgebase.model.KBComment) ServiceContext(com.liferay.portal.service.ServiceContext) ThemeDisplay(com.liferay.portal.theme.ThemeDisplay)

Example 23 with ThemeDisplay

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

the class BaseKBPortlet method subscribeKBArticle.

public void subscribeKBArticle(ActionRequest actionRequest, ActionResponse actionResponse) throws Exception {
    ThemeDisplay themeDisplay = (ThemeDisplay) actionRequest.getAttribute(WebKeys.THEME_DISPLAY);
    long resourcePrimKey = ParamUtil.getLong(actionRequest, "resourcePrimKey");
    KBArticleServiceUtil.subscribeKBArticle(themeDisplay.getScopeGroupId(), resourcePrimKey);
}
Also used : ThemeDisplay(com.liferay.portal.theme.ThemeDisplay)

Example 24 with ThemeDisplay

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

the class BaseKBPortlet method deleteKBComment.

public void deleteKBComment(ActionRequest actionRequest, ActionResponse actionResponse) throws Exception {
    ThemeDisplay themeDisplay = (ThemeDisplay) actionRequest.getAttribute(WebKeys.THEME_DISPLAY);
    if (!themeDisplay.isSignedIn()) {
        return;
    }
    long kbCommentId = ParamUtil.getLong(actionRequest, "kbCommentId");
    KBCommentServiceUtil.deleteKBComment(kbCommentId);
    SessionMessages.add(actionRequest, "suggestionDeleted");
}
Also used : ThemeDisplay(com.liferay.portal.theme.ThemeDisplay)

Example 25 with ThemeDisplay

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

the class BaseKBPortlet method addTempAttachment.

public void addTempAttachment(ActionRequest actionRequest, ActionResponse actionResponse) throws Exception {
    UploadPortletRequest uploadPortletRequest = PortalUtil.getUploadPortletRequest(actionRequest);
    ThemeDisplay themeDisplay = (ThemeDisplay) actionRequest.getAttribute(WebKeys.THEME_DISPLAY);
    long resourcePrimKey = ParamUtil.getLong(actionRequest, "resourcePrimKey");
    String sourceFileName = uploadPortletRequest.getFileName("file");
    InputStream inputStream = null;
    try {
        inputStream = uploadPortletRequest.getFileAsStream("file");
        String mimeType = uploadPortletRequest.getContentType("file");
        KBArticleServiceUtil.addTempAttachment(themeDisplay.getScopeGroupId(), resourcePrimKey, sourceFileName, KnowledgeBaseConstants.TEMP_FOLDER_NAME, inputStream, mimeType);
    } finally {
        StreamUtil.cleanUp(inputStream);
    }
}
Also used : InputStream(java.io.InputStream) UploadPortletRequest(com.liferay.portal.kernel.upload.UploadPortletRequest) 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