Example usage for com.liferay.portal.kernel.util WebKeys THEME_DISPLAY

List of usage examples for com.liferay.portal.kernel.util WebKeys THEME_DISPLAY

Introduction

In this page you can find the example usage for com.liferay.portal.kernel.util WebKeys THEME_DISPLAY.

Prototype

String THEME_DISPLAY

To view the source code for com.liferay.portal.kernel.util WebKeys THEME_DISPLAY.

Click Source Link

Usage

From source file:com.liferay.asset.tags.selector.web.internal.display.context.AssetTagsSelectorDisplayContext.java

License:Open Source License

public long[] getGroupIds() {
    if (ArrayUtil.isNotEmpty(_groupIds)) {
        return _groupIds;
    }//  w  w  w .  j a  v  a  2s. c  om

    ThemeDisplay themeDisplay = (ThemeDisplay) _request.getAttribute(WebKeys.THEME_DISPLAY);

    _groupIds = StringUtil.split(ParamUtil.getString(_request, "groupIds"), 0L);

    if (ArrayUtil.isEmpty(_groupIds)) {
        _groupIds = new long[] { themeDisplay.getScopeGroupId() };
    }

    return _groupIds;
}

From source file:com.liferay.asset.tags.selector.web.internal.display.context.AssetTagsSelectorDisplayContext.java

License:Open Source License

public SearchContainer getTagsSearchContainer() {
    if (_tagsSearchContainer != null) {
        return _tagsSearchContainer;
    }//from  w w  w. j a v a  2s. c  om

    ThemeDisplay themeDisplay = (ThemeDisplay) _request.getAttribute(WebKeys.THEME_DISPLAY);

    SearchContainer tagsSearchContainer = new SearchContainer(_renderRequest, getPortletURL(), null,
            "there-are-no-tags");

    String keywords = getKeywords();

    if (Validator.isNotNull(keywords)) {
        tagsSearchContainer.setSearch(true);
    }

    String orderByCol = getOrderByCol();

    tagsSearchContainer.setOrderByCol(orderByCol);

    boolean orderByAsc = false;

    String orderByType = getOrderByType();

    if (orderByType.equals("asc")) {
        orderByAsc = true;
    }

    tagsSearchContainer.setOrderByComparator(new AssetTagNameComparator(orderByAsc));

    tagsSearchContainer.setOrderByType(orderByType);

    tagsSearchContainer.setRowChecker(new EntriesChecker(_renderRequest, _renderResponse));

    int tagsCount = AssetTagServiceUtil.getTagsCount(themeDisplay.getScopeGroupId(), keywords);

    tagsSearchContainer.setTotal(tagsCount);

    List<AssetTag> tags = AssetTagServiceUtil.getTags(getGroupIds(), keywords, tagsSearchContainer.getStart(),
            tagsSearchContainer.getEnd(), tagsSearchContainer.getOrderByComparator());

    tagsSearchContainer.setResults(tags);

    _tagsSearchContainer = tagsSearchContainer;

    return _tagsSearchContainer;
}

From source file:com.liferay.assetlayouts.asset.LayoutAssetRenderer.java

License:Open Source License

@Override
public String getURLViewInContext(LiferayPortletRequest liferayPortletRequest,
        LiferayPortletResponse liferayPortletResponse, String noSuchEntryRedirect) {

    try {//ww w.  j  av a 2 s  . c o  m
        ThemeDisplay themeDisplay = (ThemeDisplay) liferayPortletRequest.getAttribute(WebKeys.THEME_DISPLAY);

        Layout layout = LayoutLocalServiceUtil.getLayout(_layout.getPlid());

        return PortalUtil.getLayoutFriendlyURL(layout, themeDisplay);
    } catch (Exception e) {
        return StringPool.BLANK;
    }
}

From source file:com.liferay.bbb.admin.portlet.AdminPortlet.java

License:Open Source License

public void updateBBBServer(ActionRequest actionRequest, ActionResponse actionResponse) throws Exception {

    ThemeDisplay themeDisplay = (ThemeDisplay) actionRequest.getAttribute(WebKeys.THEME_DISPLAY);

    long bbbServerId = ParamUtil.getLong(actionRequest, "bbbServerId");

    String name = ParamUtil.getString(actionRequest, "name");
    String url = ParamUtil.getString(actionRequest, "url");
    String secret = ParamUtil.getString(actionRequest, "secret");

    ServiceContext serviceContext = ServiceContextFactory.getInstance(BBBServer.class.getName(), actionRequest);

    if (bbbServerId <= 0) {
        BBBServerLocalServiceUtil.addBBBServer(themeDisplay.getUserId(), name, url, secret, serviceContext);
    } else {//  w w  w  .  j a  va2 s .  c  o m
        BBBServerLocalServiceUtil.updateBBBServer(bbbServerId, name, url, secret, serviceContext);
    }
}

From source file:com.liferay.bbb.meetings.portlet.MeetingsPortlet.java

License:Open Source License

public void joinBBBMeeting(ActionRequest actionRequest, ActionResponse actionResponse) throws Exception {

    long bbbMeetingId = ParamUtil.getLong(actionRequest, "bbbMeetingId");

    if (bbbMeetingId > 0) {
        ThemeDisplay themeDisplay = (ThemeDisplay) actionRequest.getAttribute(WebKeys.THEME_DISPLAY);

        User user = themeDisplay.getUser();

        BBBParticipant bbbParticipant = BBBParticipantLocalServiceUtil.fetchBBBParticipant(bbbMeetingId,
                user.getEmailAddress());

        ServiceContext serviceContext = ServiceContextFactory.getInstance(BBBMeeting.class.getName(),
                actionRequest);//from ww w  .  j a  va2 s.  c  o  m

        if (bbbParticipant == null) {
            bbbParticipant = BBBParticipantLocalServiceUtil.addBBBParticipant(user.getUserId(),
                    themeDisplay.getScopeGroupId(), bbbMeetingId, user.getFirstName(), user.getEmailAddress(),
                    BBBParticipantConstants.TYPE_MODERATOR, BBBParticipantConstants.STATUS_INVITED,
                    serviceContext);
        }

        actionResponse.sendRedirect(BBBUtil.getInvitationURL(bbbParticipant, serviceContext.getRequest()));
    } else {
        long bbbParticipantId = ParamUtil.getLong(actionRequest, "bbbParticipantId");
        String hash = ParamUtil.getString(actionRequest, "hash");
        String name = ParamUtil.getString(actionRequest, "name");
        boolean recordMeeting = ParamUtil.getBoolean(actionRequest, "recordMeeting");

        JSONObject jsonObject = JSONFactoryUtil.createJSONObject();

        BBBParticipant bbbParticipant = BBBParticipantLocalServiceUtil.getBBBParticipant(bbbParticipantId);

        if (!hash.equals(BBBUtil.getHash(bbbParticipant))) {
            jsonObject.put("success", Boolean.FALSE);

            writeJSON(actionRequest, actionResponse, jsonObject);

            return;
        }

        BBBMeeting bbbMeeting = BBBMeetingLocalServiceUtil.getBBBMeeting(bbbParticipant.getBbbMeetingId());

        try {
            if ((bbbMeeting.getBbbServerId() == BBBMeetingConstants.BBB_SERVER_ID_DEFAULT)
                    && (bbbParticipant.getType() != BBBParticipantConstants.TYPE_MODERATOR)) {

                jsonObject.put("retry", Boolean.TRUE);
            } else {
                if ((bbbParticipant.getType() == BBBParticipantConstants.TYPE_MODERATOR)
                        && !BBBAPIUtil.isMeetingRunning(bbbParticipant.getBbbMeetingId())) {

                    BBBAPIUtil.startMeeting(bbbParticipant.getBbbMeetingId(), recordMeeting);
                }

                String joinURL = BBBAPIUtil.getJoinURL(bbbParticipant, name);

                jsonObject.put("joinURL", joinURL);
                jsonObject.put("success", Boolean.TRUE);
            }
        } catch (Exception e) {
            jsonObject.putException(e);
        }

        writeJSON(actionRequest, actionResponse, jsonObject);
    }
}

From source file:com.liferay.bbb.meetings.portlet.MeetingsPortlet.java

License:Open Source License

public void updateBBBMeeting(ActionRequest actionRequest, ActionResponse actionResponse) throws Exception {

    ThemeDisplay themeDisplay = (ThemeDisplay) actionRequest.getAttribute(WebKeys.THEME_DISPLAY);

    long bbbMeetingId = ParamUtil.getLong(actionRequest, "bbbMeetingId");

    String name = ParamUtil.getString(actionRequest, "name");
    String description = ParamUtil.getString(actionRequest, "description");

    List<BBBParticipant> bbbParticipants = BBBUtil.getBBBParticipants(actionRequest);

    ServiceContext serviceContext = ServiceContextFactory.getInstance(BBBMeeting.class.getName(),
            actionRequest);/*from  w ww . j  a  v a  2 s .co  m*/

    if (bbbMeetingId <= 0) {
        String portletId = PortalUtil.getPortletId(actionRequest);

        BBBMeetingServiceUtil.addBBBMeeting(themeDisplay.getScopeGroupId(), portletId,
                BBBMeetingConstants.BBB_SERVER_ID_DEFAULT, name, description, null, null,
                BBBMeetingConstants.STATUS_SCHEDULED, bbbParticipants, serviceContext);
    } else {
        BBBMeeting bbbMeeting = BBBMeetingServiceUtil.getBBBMeeting(bbbMeetingId);

        BBBMeetingServiceUtil.updateBBBMeeting(bbbMeetingId, bbbMeeting.getBbbServerId(), name, description,
                bbbMeeting.getAttendeePassword(), bbbMeeting.getModeratorPassword(), bbbParticipants,
                serviceContext);
    }
}

From source file:com.liferay.bbb.util.BBBUtil.java

License:Open Source License

public static String getInvitationURL(BBBParticipant bbbParticipant, HttpServletRequest request)
        throws Exception {

    StringBundler sb = new StringBundler(7);

    Group group = GroupLocalServiceUtil.getGroup(bbbParticipant.getCompanyId(), GroupConstants.GUEST);

    Layout layout = LayoutLocalServiceUtil.getLayout(group.getDefaultPublicPlid());

    ThemeDisplay themeDisplay = (ThemeDisplay) request.getAttribute(WebKeys.THEME_DISPLAY);

    sb.append(PortalUtil.getLayoutURL(layout, themeDisplay));

    sb.append(Portal.FRIENDLY_URL_SEPARATOR);
    sb.append("meetings");
    sb.append(StringPool.SLASH);/*from   ww w .  j av  a2 s  .c o  m*/
    sb.append(bbbParticipant.getBbbParticipantId());
    sb.append(StringPool.SLASH);
    sb.append(getHash(bbbParticipant));

    return sb.toString();
}

From source file:com.liferay.blade.samples.portlet.toolbar.contributor.BladePortletToolbarContributor.java

License:Apache License

protected Locale getLocale(PortletRequest portletRequest) {
    ThemeDisplay themeDisplay = (ThemeDisplay) portletRequest.getAttribute(WebKeys.THEME_DISPLAY);

    return themeDisplay.getLocale();
}

From source file:com.liferay.blade.samples.strutsportletaction.BladePortletAction.java

License:Open Source License

@Override
public void processAction(StrutsPortletAction originalStrutsPortletAction, PortletConfig portletConfig,
        ActionRequest actionRequest, ActionResponse actionResponse) throws Exception {

    if (_log.isDebugEnabled()) {
        _log.debug("BladePortletAction - procesAction");
    }/*from w  w w .j a  va2s.  com*/

    ThemeDisplay themeDisplay = (ThemeDisplay) actionRequest.getAttribute(WebKeys.THEME_DISPLAY);

    User loggedinUser = themeDisplay.getUser();

    if ((loggedinUser != null) && _log.isInfoEnabled()) {
        _log.info("Logging in with user:[" + loggedinUser.getFirstName() + " " + loggedinUser.getLastName()
                + "]");

        _log.info("Logged in user: Current Greetings[" + loggedinUser.getGreeting() + "]");
    }

    originalStrutsPortletAction.processAction(originalStrutsPortletAction, portletConfig, actionRequest,
            actionResponse);
}

From source file:com.liferay.blade.samples.strutsportletaction.BladePortletAction.java

License:Open Source License

@Override
public String render(StrutsPortletAction originalStrutsPortletAction, PortletConfig portletConfig,
        RenderRequest renderRequest, RenderResponse renderResponse) throws Exception {

    if (_log.isDebugEnabled()) {
        _log.debug("BladePortletAction - render");
    }// ww w . ja  v a  2  s  .  c o m

    ThemeDisplay themeDisplay = (ThemeDisplay) renderRequest.getAttribute(WebKeys.THEME_DISPLAY);

    User loggedinUser = themeDisplay.getUser();

    if (loggedinUser != null) {
        loggedinUser.setLastName("BLADE");

        loggedinUser.setGreeting("Hello," + loggedinUser.getFirstName() + " from BLADE!");

        _userLocalService.updateUser(loggedinUser);
    }

    return originalStrutsPortletAction.render(originalStrutsPortletAction, portletConfig, renderRequest,
            renderResponse);
}