Example usage for com.liferay.portal.kernel.util HtmlUtil escapeURL

List of usage examples for com.liferay.portal.kernel.util HtmlUtil escapeURL

Introduction

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

Prototype

public static String escapeURL(String url) 

Source Link

Document

Escapes the URL value so that it is safe to use as a URL.

Usage

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

License:Open Source License

public static BBBMeeting endMeeting(long bbbMeetingId) throws PortalException {

    BBBMeeting bbbMeeting = BBBMeetingLocalServiceUtil.getBBBMeeting(bbbMeetingId);

    StringBundler sb = new StringBundler(7);

    sb.append(BBBConstants.API_PARAMETER_MEETING_ID);
    sb.append(StringPool.EQUAL);//from   w  ww. j  a va 2s  . c om
    sb.append(bbbMeeting.getBbbMeetingId());
    sb.append(StringPool.AMPERSAND);
    sb.append(BBBConstants.API_PARAMETER_PASSWORD);
    sb.append(StringPool.EQUAL);
    sb.append(HtmlUtil.escapeURL(bbbMeeting.getModeratorPassword()));

    execute(bbbMeeting, BBBConstants.API_METHOD_END, sb.toString());

    BBBMeetingLocalServiceUtil.updateStatus(bbbMeetingId, BBBMeetingConstants.STATUS_COMPLETED);

    return bbbMeeting;
}

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

License:Open Source License

public static String getJoinURL(BBBParticipant bbbParticipant, String userName) throws PortalException {

    if (!userName.equals(bbbParticipant.getName())) {
        bbbParticipant = BBBParticipantLocalServiceUtil.addBBBParticipant(bbbParticipant.getUserId(),
                bbbParticipant.getGroupId(), bbbParticipant.getBbbMeetingId(), userName, null,
                bbbParticipant.getType(), BBBParticipantConstants.STATUS_INVITED, new ServiceContext());
    }//from w w w .  j a va  2s . c o m

    StringBundler sb = new StringBundler(11);

    sb.append(BBBConstants.API_PARAMETER_FULL_NAME);
    sb.append(StringPool.EQUAL);
    sb.append(HtmlUtil.escapeURL(bbbParticipant.getName()));
    sb.append(StringPool.AMPERSAND);
    sb.append(BBBConstants.API_PARAMETER_MEETING_ID);
    sb.append(StringPool.EQUAL);

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

    sb.append(bbbMeeting.getBbbMeetingId());

    sb.append(StringPool.AMPERSAND);
    sb.append(BBBConstants.API_PARAMETER_PASSWORD);
    sb.append(StringPool.EQUAL);

    if (bbbParticipant.getType() == BBBParticipantConstants.TYPE_MODERATOR) {

        sb.append(HtmlUtil.escapeURL(bbbMeeting.getModeratorPassword()));
    } else {
        sb.append(HtmlUtil.escapeURL(bbbMeeting.getAttendeePassword()));
    }

    BBBServer bbbServer = BBBServerLocalServiceUtil.getBBBServer(bbbMeeting.getBbbServerId());

    return getURL(bbbServer, BBBConstants.API_METHOD_JOIN, sb.toString());
}

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

License:Open Source License

public static BBBMeeting startMeeting(long bbbMeetingId, boolean recordMeeting) throws PortalException {

    BBBMeeting bbbMeeting = BBBMeetingLocalServiceUtil.getBBBMeeting(bbbMeetingId);

    if (bbbMeeting.getStatus() != BBBMeetingConstants.STATUS_SCHEDULED) {
        return bbbMeeting;
    }/*from  w w w .ja  v  a  2 s  . c  o  m*/

    StringBundler sb = new StringBundler(15);

    sb.append(BBBConstants.API_PARAMETER_MEETING_ID);
    sb.append(StringPool.EQUAL);
    sb.append(bbbMeeting.getBbbMeetingId());
    sb.append(StringPool.AMPERSAND);
    sb.append(BBBConstants.API_PARAMETER_NAME);
    sb.append(StringPool.EQUAL);
    sb.append(HtmlUtil.escapeURL(bbbMeeting.getName()));

    if (recordMeeting) {
        sb.append(StringPool.AMPERSAND);
        sb.append(BBBConstants.API_PARAMETER_RECORD);
        sb.append(StringPool.EQUAL);
        sb.append(StringPool.TRUE);
    }

    sb.append(StringPool.AMPERSAND);
    sb.append(BBBConstants.API_PARAMETER_WELCOME);
    sb.append(StringPool.EQUAL);

    String welcomeMessage = ContentUtil.get("com/liferay/bbb/dependencies/meeting_welcome_message.tmpl");

    sb.append(HtmlUtil.escapeURL(welcomeMessage));

    bbbMeeting.setBbbServerId(getBbbServerId());

    Document document = execute(bbbMeeting, BBBConstants.API_METHOD_CREATE, sb.toString());

    Element element = document.getRootElement();

    String returnCode = getText(element, BBBConstants.API_RESPONSE_RETURN_CODE);

    if (returnCode.equals(BBBConstants.API_RESPONSE_FAILED)) {
        throw new SystemException();
    }

    bbbMeeting.setAttendeePassword(getText(element, BBBConstants.API_PARAMETER_ATTENDEE_PW));
    bbbMeeting.setModeratorPassword(getText(element, BBBConstants.API_PARAMETER_MODERATOR_PW));
    bbbMeeting.setStatus(BBBMeetingConstants.STATUS_IN_PROGRESS);

    BBBMeetingLocalServiceUtil.updateBBBMeeting(bbbMeeting);

    return bbbMeeting;
}

From source file:com.liferay.portlet.calendar.social.CalendarActivityInterpreter.java

License:Open Source License

@Override
protected SocialActivityFeedEntry doInterpret(SocialActivity activity, ThemeDisplay themeDisplay)
        throws Exception {

    PermissionChecker permissionChecker = themeDisplay.getPermissionChecker();

    if (!CalEventPermission.contains(permissionChecker, activity.getClassPK(), ActionKeys.VIEW)) {

        return null;
    }/*from ww w.  j  a va  2s .com*/

    String groupName = StringPool.BLANK;

    if (activity.getGroupId() != themeDisplay.getScopeGroupId()) {
        groupName = getGroupName(activity.getGroupId(), themeDisplay);
    }

    String creatorUserName = getUserName(activity.getUserId(), themeDisplay);

    int activityType = activity.getType();

    // Link

    CalEvent event = CalEventLocalServiceUtil.getEvent(activity.getClassPK());

    String link = themeDisplay.getPortalURL() + themeDisplay.getPathMain() + "/calendar/find_event?redirect="
            + HtmlUtil.escapeURL(themeDisplay.getURLCurrent()) + "&eventId=" + activity.getClassPK();

    // Title

    String titlePattern = null;

    if (activityType == CalendarActivityKeys.ADD_EVENT) {
        titlePattern = "activity-calendar-add-event";
    } else if (activityType == CalendarActivityKeys.UPDATE_EVENT) {
        titlePattern = "activity-calendar-update-event";
    }

    if (Validator.isNotNull(groupName)) {
        titlePattern += "-in";
    }

    String eventTitle = wrapLink(link, HtmlUtil.escape(cleanContent(event.getTitle())));

    Object[] titleArguments = new Object[] { groupName, creatorUserName, eventTitle };

    String title = themeDisplay.translate(titlePattern, titleArguments);

    // Body

    String body = StringPool.BLANK;

    return new SocialActivityFeedEntry(link, title, body);
}

From source file:com.liferay.so.hook.events.SOUserDefaultLandingPageAction.java

License:Open Source License

protected void doRun(HttpServletRequest request, HttpServletResponse response) throws Exception {

    String path = PortletPropsValues.SO_USER_DEFAULT_LANDING_PAGE_PATH;

    if (Validator.isNull(path)) {
        return;//  w w  w.j  a  v a  2 s.  c  o  m
    }

    HttpSession session = request.getSession();

    User user = (User) session.getAttribute(WebKeys.USER);

    if ((user == null) || !SocialOfficeServiceUtil.isSocialOfficeGroup(user.getGroupId())) {

        return;
    }

    if (path.contains("${liferay:screenName}") || path.contains("${liferay:userId}")) {

        path = StringUtil.replace(path, new String[] { "${liferay:screenName}", "${liferay:userId}" },
                new String[] { HtmlUtil.escapeURL(user.getScreenName()), String.valueOf(user.getUserId()) });
    }

    LastPath lastPath = new LastPath(StringPool.BLANK, path);

    session.setAttribute(WebKeys.LAST_PATH, lastPath);
}

From source file:com.liferay.socialnetworking.members.social.MembersActivityInterpreter.java

License:Open Source License

@Override
protected String getLink(SocialActivity activity, ServiceContext serviceContext) throws Exception {

    int activityType = activity.getType();

    if (activityType != MembersActivityKeys.ADD_MEMBER) {
        return StringPool.BLANK;
    }//from  w ww. j a v a  2 s .co  m

    StringBundler sb = new StringBundler(5);

    sb.append(serviceContext.getPortalURL());
    sb.append(serviceContext.getPathFriendlyURLPublic());
    sb.append(StringPool.SLASH);

    User creatorUser = UserLocalServiceUtil.getUserById(activity.getUserId());

    sb.append(HtmlUtil.escapeURL(creatorUser.getScreenName()));

    sb.append("/profile");

    return sb.toString();
}

From source file:com.liferay.socialnetworking.util.WallUtil.java

License:Open Source License

public static String getWallLink(User user, String wallLayoutFriendlyURL, String screenNameOrUserId,
        ThemeDisplay themeDisplay) throws Exception {

    if (Validator.isNull(wallLayoutFriendlyURL)) {
        return null;
    }//  w  w w .j a va  2s . com

    StringBundler sb = new StringBundler(7);

    sb.append(themeDisplay.getPortalURL());
    sb.append(themeDisplay.getPathFriendlyURLPublic());
    sb.append(StringPool.SLASH);
    sb.append(HtmlUtil.escapeURL(user.getScreenName()));
    sb.append(wallLayoutFriendlyURL);
    sb.append("/-/wall/");
    sb.append(screenNameOrUserId);

    return sb.toString();
}

From source file:com.liferay.twitter.social.TwitterActivityInterpreter.java

License:Open Source License

@Override
protected String getBody(SocialActivity activity, ServiceContext serviceContext) throws Exception {

    StringBundler sb = new StringBundler(4);

    sb.append("http://twitter.com/");

    User creatorUser = UserLocalServiceUtil.getUserById(activity.getUserId());

    Contact creatorContact = creatorUser.getContact();

    sb.append(HtmlUtil.escapeURL(creatorContact.getTwitterSn()));

    sb.append("/statuses/");
    sb.append(activity.getClassPK());/*from  w w w .ja va 2s .c om*/

    String text = getJSONValue(activity.getExtraData(), "text");

    return wrapLink(sb.toString(), text);
}

From source file:org.opencps.hook.events.DefaultLandingPageAction.java

License:Open Source License

protected void doRun(HttpServletRequest request, HttpServletResponse response) throws Exception {
    HttpSession session = request.getSession();

    User user = (User) session.getAttribute(org.opencps.util.WebKeys.USER);

    long companyId = PortalUtil.getCompanyId(request);

    String path = StringPool.BLANK;

    for (UserGroup userGroup : user.getUserGroups()) {
        if (userGroup.getName().equalsIgnoreCase(PortletPropsValues.USERMGT_USERGROUP_NAME_CITIZEN)) {
            path = com.liferay.portal.kernel.util.PrefsPropsUtil.getString(companyId,
                    "default.landing.page.path.citizen");
        } else if (userGroup.getName().equalsIgnoreCase(PortletPropsValues.USERMGT_USERGROUP_NAME_BUSINESS)) {
            path = com.liferay.portal.kernel.util.PrefsPropsUtil.getString(companyId,
                    "default.landing.page.path.business");
        } else if (userGroup.getName().equalsIgnoreCase(PortletPropsValues.USERMGT_USERGROUP_NAME_EMPLOYEE)) {
            path = com.liferay.portal.kernel.util.PrefsPropsUtil.getString(companyId,
                    "default.landing.page.path.employee");
        } else {//www. j a va  2s.  co m
            path = com.liferay.portal.kernel.util.PrefsPropsUtil.getString(companyId,
                    PropsKeys.DEFAULT_LANDING_PAGE_PATH);
        }
    }

    if (_log.isInfoEnabled()) {
        _log.info("Pathhh" + PropsKeys.DEFAULT_LANDING_PAGE_PATH + StringPool.EQUAL + path);
    }

    if (Validator.isNull(path)) {
        return;
    }

    if (path.contains("${liferay:screenName}") || path.contains("${liferay:userId}")) {

        if (user == null) {
            return;
        }

        path = StringUtil.replace(path, new String[] { "${liferay:screenName}", "${liferay:userId}" },
                new String[] { HtmlUtil.escapeURL(user.getScreenName()), String.valueOf(user.getUserId()) });
    }

    LastPath lastPath = new LastPath(StringPool.BLANK, path);

    session.setAttribute(org.opencps.util.WebKeys.LAST_PATH, lastPath);
}