Example usage for com.liferay.portal.kernel.util StringPool AT

List of usage examples for com.liferay.portal.kernel.util StringPool AT

Introduction

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

Prototype

String AT

To view the source code for com.liferay.portal.kernel.util StringPool AT.

Click Source Link

Usage

From source file:com.cd.learning.hook.MBUtil.java

License:Open Source License

public static String getReplyToAddress(long categoryId, long messageId, String mx,
        String defaultMailingListAddress) {

    if (PropsUtil.get(PropsKeys.POP_SERVER_SUBDOMAIN).length() <= 0) {
        return defaultMailingListAddress;
    }/* w ww .j  av a  2  s.  c o  m*/

    StringBundler sb = new StringBundler(8);

    sb.append(MESSAGE_POP_PORTLET_PREFIX);
    sb.append(categoryId);
    sb.append(StringPool.PERIOD);
    sb.append(messageId);
    sb.append(StringPool.AT);
    sb.append(PropsUtil.get(PropsKeys.POP_SERVER_SUBDOMAIN));
    sb.append(StringPool.PERIOD);
    sb.append(mx);

    return sb.toString();
}

From source file:com.fb.action.EditEntryAction.java

License:Open Source License

protected void addOpenGraphProperties(PortletRequest request, PortletResponse response, BlogsEntry entry)
        throws PortalException, SystemException {

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

    Map<String, String> opengraphAttributes = (Map<String, String>) request.getAttribute(OPENGRAPH_ATTRIBUTE);

    if (opengraphAttributes == null) {
        opengraphAttributes = new HashMap<String, String>();

        request.setAttribute(OPENGRAPH_ATTRIBUTE, opengraphAttributes);
    }/*www .j  av a 2s  .  c  o m*/

    Map<String, String> twitterAttributes = (Map<String, String>) request.getAttribute(TWITTER_ATTRIBUTE);

    if (twitterAttributes == null) {
        twitterAttributes = new HashMap<String, String>();

        request.setAttribute(TWITTER_ATTRIBUTE, twitterAttributes);
    }

    opengraphAttributes.put("type", "website");

    PortletURL portletURL = ((LiferayPortletResponse) response).createRenderURL();

    portletURL.setParameter("struts_action", "/blogs/view_entry");
    portletURL.setParameter("urlTitle", entry.getUrlTitle());

    String url = PortalUtil.getCanonicalURL(portletURL.toString(), themeDisplay, themeDisplay.getLayout());

    opengraphAttributes.put("url", url);
    twitterAttributes.put("url", url);

    String title = entry.getTitle();

    opengraphAttributes.put("title", title);
    twitterAttributes.put("title", title);

    String description = entry.getDescription();

    if (Validator.isNotNull(description)) {
        opengraphAttributes.put("description", description);
        twitterAttributes.put("description", description);
    }

    Group group = GroupLocalServiceUtil.getGroup(entry.getGroupId());

    opengraphAttributes.put("site_name", group.getDescriptiveName());

    opengraphAttributes.put("locale", themeDisplay.getLanguageId());

    String smallImage = null;

    if (entry.isSmallImage()) {
        smallImage = entry.getEntryImageURL(themeDisplay);
    }

    if (Validator.isNotNull(smallImage)) {
        opengraphAttributes.put("image", smallImage);
        twitterAttributes.put("image", smallImage);
    }

    String twCard = "summary";

    if (Validator.isNotNull(smallImage)) {
        twCard = "photo";
    }

    twitterAttributes.put("card", twCard);

    /*
            
    // TODO: Site Setting for twitter account
            
    String twSite = "";
            
    if (Validator.isNotNull(twSite)) {
       twitterAttributes.put("site", StringPool.AT + twSite);
    }
            
    */

    User user = UserLocalServiceUtil.getUser(entry.getUserId());

    Contact contact = user.getContact();

    if (Validator.isNotNull(contact.getTwitterSn())) {
        twitterAttributes.put("creator", StringPool.AT + contact.getTwitterSn());
    }

}

From source file:com.liferay.chat.jabber.JabberImpl.java

License:Open Source License

@Override
public String getResource(String jabberId) {
    String resource = StringUtil.extractLast(jabberId, StringPool.AT);

    resource = StringUtil.extractLast(resource, StringPool.SLASH);

    if (resource == null) {
        return StringPool.BLANK;
    }//from  w w w. j  a v  a2  s  . c  o  m

    return resource;
}

From source file:com.liferay.chat.jabber.JabberImpl.java

License:Open Source License

@Override
public String getScreenName(String jabberId) {
    return StringUtil.extractFirst(jabberId, StringPool.AT);
}

From source file:com.liferay.chat.jabber.JabberImpl.java

License:Open Source License

protected String getJabberId(String screenName) {
    return screenName.concat(StringPool.AT).concat(PortletPropsValues.JABBER_SERVICE_NAME);
}

From source file:com.liferay.google.apps.connector.GAuthenticator.java

License:Open Source License

protected void doInit() throws Exception {
    if (_companyId > 0) {
        Company company = CompanyLocalServiceUtil.getCompany(_companyId);

        _domain = company.getMx();/*ww w  .  j  a va  2  s . c  om*/
        _userName = PrefsPropsUtil.getString(_companyId, "google.apps.username");
        _password = PrefsPropsUtil.getString(_companyId, "google.apps.password");
    }

    Http.Options options = new Http.Options();

    options.addPart("accountType", "HOSTED");

    String emailAddress = _userName;

    if (!emailAddress.contains(StringPool.AT)) {
        emailAddress = _userName.concat(StringPool.AT).concat(_domain);
    }

    options.addPart("Email", emailAddress);

    options.addPart("Passwd", _password);
    options.addPart("service", "apps");
    options.setLocation("https://www.google.com/accounts/ClientLogin");
    options.setPost(true);

    String content = HttpUtil.URLtoString(options);

    Properties properties = PropertiesUtil.load(content);

    _error = properties.getProperty("Error");

    if ((_error != null) && _log.isInfoEnabled()) {
        _log.info("Unable to initialize authentication token: " + _error);
    }

    _authenticationToken = properties.getProperty("Auth");

    if ((_authenticationToken != null) && _log.isInfoEnabled()) {
        _log.info("Authentication token " + _authenticationToken);
    }

    _initTime = System.currentTimeMillis();
}

From source file:com.liferay.google.mail.groups.util.GoogleMailGroupsUtil.java

License:Open Source License

public static String getGroupEmailAddress(Group group) throws PortalException {

    StringBundler sb = new StringBundler(4);

    sb.append(PortletPropsValues.EMAIL_PREFIX);

    String friendlyURL = group.getFriendlyURL();

    sb.append(friendlyURL.substring(1));

    sb.append(StringPool.AT);

    Company company = CompanyLocalServiceUtil.getCompany(group.getCompanyId());

    sb.append(company.getMx());/* www.  j av a  2  s.  c om*/

    return sb.toString();
}

From source file:com.liferay.google.mail.groups.util.GoogleMailGroupsUtil.java

License:Open Source License

public static String getUserEmailAddress(User user) throws PortalException {
    return user.getUserId() + StringPool.AT + user.getCompanyMx();
}

From source file:com.liferay.journal.internal.util.impl.JournalConverterImpl.java

License:Open Source License

protected void updateDynamicContentValue(Element dynamicContentElement, String fieldType, boolean multiple,
        String fieldValue) throws Exception {

    if (DDMFormFieldType.CHECKBOX.equals(fieldType)) {
        if (fieldValue.equals(Boolean.FALSE.toString())) {
            fieldValue = StringPool.BLANK;
        }//from  w ww.ja  v  a2s .c om

        dynamicContentElement.addCDATA(fieldValue);
    } else if (DDMFormFieldType.LINK_TO_PAGE.equals(fieldType) && Validator.isNotNull(fieldValue)) {

        JSONObject jsonObject = JSONFactoryUtil.createJSONObject(fieldValue);

        long groupId = jsonObject.getLong("groupId");

        long layoutId = jsonObject.getLong("layoutId");

        boolean privateLayout = jsonObject.getBoolean("privateLayout");

        StringBundler sb = new StringBundler((groupId > 0) ? 5 : 3);

        sb.append(layoutId);
        sb.append(StringPool.AT);

        if (privateLayout) {
            Group group = _groupLocalService.fetchGroup(groupId);

            if (group == null) {
                sb.append("private");
            } else if (group.isUser()) {
                sb.append("private-user");
            } else {
                sb.append("private-group");
            }
        } else {
            sb.append("public");
        }

        if (groupId > 0) {
            sb.append(StringPool.AT);
            sb.append(groupId);
        }

        dynamicContentElement.addCDATA(sb.toString());
    } else if (DDMFormFieldType.SELECT.equals(fieldType) && Validator.isNotNull(fieldValue)) {

        JSONArray jsonArray = null;

        try {
            jsonArray = JSONFactoryUtil.createJSONArray(fieldValue);
        } catch (JSONException jsone) {
            return;
        }

        if (multiple) {
            for (int i = 0; i < jsonArray.length(); i++) {
                Element optionElement = dynamicContentElement.addElement("option");

                optionElement.addCDATA(jsonArray.getString(i));
            }
        } else {
            dynamicContentElement.addCDATA(jsonArray.getString(0));
        }
    } else {
        dynamicContentElement.addCDATA(fieldValue);
    }
}

From source file:com.liferay.journal.transformer.TokensTransformerListener.java

License:Open Source License

/**
 * Replace the standard tokens in a given string with their values.
 *
 * @return the processed string//  w  ww  .j a v  a  2 s  .c  o  m
 */
protected String replace(String s, Map<String, String> tokens) {
    if (tokens.isEmpty()) {
        return s;
    }

    List<String> escapedKeysList = null;
    List<String> escapedValuesList = null;

    List<String> keysList = null;
    List<String> valuesList = null;

    List<String> tempEscapedKeysList = null;
    List<String> tempEscapedValuesList = null;

    boolean hasKey = false;

    for (Map.Entry<String, String> entry : tokens.entrySet()) {
        String key = entry.getKey();

        if (Validator.isNotNull(key) && s.contains(key)) {
            if (!hasKey) {
                escapedKeysList = new ArrayList<>();
                escapedValuesList = new ArrayList<>();
                keysList = new ArrayList<>();
                valuesList = new ArrayList<>();
                tempEscapedKeysList = new ArrayList<>();
                tempEscapedValuesList = new ArrayList<>();

                hasKey = true;
            }

            String actualKey = StringPool.AT.concat(key).concat(StringPool.AT);

            String escapedKey = StringPool.AT.concat(actualKey).concat(StringPool.AT);

            String tempEscapedKey = TEMP_ESCAPED_AT_OPEN.concat(key).concat(TEMP_ESCAPED_AT_CLOSE);

            escapedKeysList.add(escapedKey);
            escapedValuesList.add(tempEscapedKey);

            keysList.add(actualKey);
            valuesList.add(GetterUtil.getString(entry.getValue()));

            tempEscapedKeysList.add(tempEscapedKey);
            tempEscapedValuesList.add(actualKey);
        }
    }

    if (!hasKey) {
        return s;
    }

    s = StringUtil.replace(s, escapedKeysList.toArray(new String[escapedKeysList.size()]),
            escapedValuesList.toArray(new String[escapedValuesList.size()]));

    s = StringUtil.replace(s, keysList.toArray(new String[keysList.size()]),
            valuesList.toArray(new String[valuesList.size()]));

    s = StringUtil.replace(s, tempEscapedKeysList.toArray(new String[tempEscapedKeysList.size()]),
            tempEscapedValuesList.toArray(new String[tempEscapedValuesList.size()]));

    return s;
}