MBMVCResourceCommand.java 文件源码

java
阅读 15 收藏 0 点赞 0 评论 0

项目:liferay-dummy-factory 作者:
/**
 * Get Thread list
 * 
 * Depending on the passed site groupd id, fetch all pages in the site and return JSON object list.
 * 
 * @param resourceRequest
 * @param resourceResponse
 * @return
 * @throws PortalException 
 */
protected String getThreadList(ResourceRequest resourceRequest, ResourceResponse resourceResponse) 
        throws PortalException {
    ThemeDisplay themeDisplay = (ThemeDisplay) resourceRequest.getAttribute(WebKeys.THEME_DISPLAY);

    JSONArray jsonArray = JSONFactoryUtil.createJSONArray();
    long siteGroupId = ParamUtil.getLong(resourceRequest, "siteGroupId", themeDisplay.getSiteGroupId());

    if(_log.isDebugEnabled()) {
        _log.debug("SiteGroup Id <" + String.valueOf(siteGroupId) + ">");
    }

    List<MBThread> threads = _mbThreadLocalService.getThreads(
            siteGroupId, 
            MBCategoryConstants.DEFAULT_PARENT_CATEGORY_ID, 
            WorkflowConstants.STATUS_APPROVED, 
            QueryUtil.ALL_POS, 
            QueryUtil.ALL_POS);

    for(MBThread thread : threads ) {
        JSONObject curUserJSONObject = JSONFactoryUtil.createJSONObject();

        MBMessage message = _mbMessageLocalService.getMessage(thread.getRootMessageId());

        if(_log.isDebugEnabled()) {
            _log.debug("Root message <" + message.getSubject() + ">");
            _log.debug(thread.toString());
            _log.debug("----------");
        }

        curUserJSONObject.put("rootMessageSubject" , message.getSubject());
        curUserJSONObject.put("threadId" , thread.getThreadId());
        curUserJSONObject.put("rootMessageId" , thread.getRootMessageId());

        jsonArray.put(curUserJSONObject);
    }

    return jsonArray.toJSONString();
}
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号