Example usage for com.liferay.portal.kernel.util Http HTTP_WITH_SLASH

List of usage examples for com.liferay.portal.kernel.util Http HTTP_WITH_SLASH

Introduction

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

Prototype

String HTTP_WITH_SLASH

To view the source code for com.liferay.portal.kernel.util Http HTTP_WITH_SLASH.

Click Source Link

Usage

From source file:com.liferay.akismet.util.AkismetUtil.java

License:Open Source License

public static boolean isSpam(long userId, String content, AkismetData akismetData) throws PortalException {

    User user = UserLocalServiceUtil.getUser(userId);

    StringBundler sb = new StringBundler(5);

    sb.append(Http.HTTP_WITH_SLASH);
    sb.append(PrefsPortletPropsUtil.getString(user.getCompanyId(), PortletPropsKeys.AKISMET_API_KEY));
    sb.append(StringPool.PERIOD);//from   www  . ja  v  a  2s  . c  o  m
    sb.append(AkismetConstants.URL_REST);
    sb.append(AkismetConstants.PATH_CHECK_SPAM);

    String location = sb.toString();

    String response = _sendRequest(location, user.getCompanyId(), akismetData.getUserIP(),
            akismetData.getUserAgent(), akismetData.getReferrer(), akismetData.getPermalink(),
            akismetData.getType(), user.getFullName(), user.getEmailAddress(), content);

    if (Validator.isNull(response) || response.equals("invalid")) {
        _log.error("There was an issue with Akismet comment validation");

        return false;
    } else if (response.equals("true")) {
        if (_log.isDebugEnabled()) {
            _log.debug("Spam detected: " + akismetData.getPermalink());
        }

        return true;
    }

    if (_log.isDebugEnabled()) {
        _log.debug("Passed: " + akismetData.getPermalink());
    }

    return false;
}

From source file:com.liferay.akismet.util.AkismetUtil.java

License:Open Source License

public static void submitHam(long companyId, String ipAddress, String userAgent, String referrer,
        String permalink, String commentType, String userName, String emailAddress, String content)
        throws PortalException {

    if (_log.isDebugEnabled()) {
        _log.debug("Submitting message as ham: " + permalink);
    }/*from  w w  w  . j a v  a2 s  . c o  m*/

    StringBundler sb = new StringBundler(5);

    sb.append(Http.HTTP_WITH_SLASH);
    sb.append(PrefsPortletPropsUtil.getString(companyId, PortletPropsKeys.AKISMET_API_KEY));
    sb.append(StringPool.PERIOD);
    sb.append(AkismetConstants.URL_REST);
    sb.append(AkismetConstants.PATH_SUBMIT_HAM);

    String location = sb.toString();

    String response = _sendRequest(location, companyId, ipAddress, userAgent, referrer, permalink, commentType,
            userName, emailAddress, content);

    if (Validator.isNull(response)) {
        _log.error("There was an issue submitting message as ham");
    }
}

From source file:com.liferay.akismet.util.AkismetUtil.java

License:Open Source License

public static void submitSpam(long companyId, String ipAddress, String userAgent, String referrer,
        String permalink, String commentType, String userName, String emailAddress, String content)
        throws PortalException {

    if (_log.isDebugEnabled()) {
        _log.debug("Submitting message as spam: " + permalink);
    }/* www.j  av  a 2  s .  c  o  m*/

    StringBundler sb = new StringBundler(5);

    sb.append(Http.HTTP_WITH_SLASH);
    sb.append(PrefsPortletPropsUtil.getString(companyId, PortletPropsKeys.AKISMET_API_KEY));
    sb.append(StringPool.PERIOD);
    sb.append(AkismetConstants.URL_REST);
    sb.append(AkismetConstants.PATH_SUBMIT_SPAM);

    String location = sb.toString();

    String response = _sendRequest(location, companyId, ipAddress, userAgent, referrer, permalink, commentType,
            userName, emailAddress, content);

    if (Validator.isNull(response)) {
        _log.error("There was an issue submitting message as spam");
    }
}

From source file:com.liferay.akismet.util.AkismetUtil.java

License:Open Source License

public static boolean verifyApiKey(long companyId, String apiKey) throws PortalException {

    String location = Http.HTTP_WITH_SLASH + AkismetConstants.URL_REST + AkismetConstants.PATH_VERIFY;

    Map<String, String> parts = new HashMap<String, String>();

    parts.put("blog", _getPortalURL(companyId));
    parts.put("key", apiKey);

    String response = _sendRequest(location, parts);

    if (response.equals("valid")) {
        return true;
    } else {//from   w  ww  . j  a  v  a 2s .  c o  m
        return false;
    }
}

From source file:com.liferay.asset.publisher.web.util.AssetRSSUtil.java

License:Open Source License

protected static String getAssetPublisherURL(PortletRequest portletRequest) throws Exception {

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

    Layout layout = themeDisplay.getLayout();

    PortletDisplay portletDisplay = themeDisplay.getPortletDisplay();

    StringBundler sb = new StringBundler(6);

    String layoutFriendlyURL = GetterUtil.getString(PortalUtil.getLayoutFriendlyURL(layout, themeDisplay));

    if (!layoutFriendlyURL.startsWith(Http.HTTP_WITH_SLASH)
            && !layoutFriendlyURL.startsWith(Http.HTTPS_WITH_SLASH)) {

        sb.append(themeDisplay.getPortalURL());
    }//www  . ja v  a 2 s. c  o m

    sb.append(layoutFriendlyURL);
    sb.append(Portal.FRIENDLY_URL_SEPARATOR);
    sb.append("asset_publisher/");
    sb.append(portletDisplay.getInstanceId());
    sb.append(StringPool.SLASH);

    return sb.toString();
}

From source file:com.liferay.asset.publisher.web.util.AssetRSSUtil.java

License:Open Source License

protected static String getEntryURLViewInContext(PortletRequest portletRequest, PortletResponse portletResponse,
        AssetEntry assetEntry) throws Exception {

    String assetViewURL = AssetPublisherHelper.getAssetViewURL(
            PortalUtil.getLiferayPortletRequest(portletRequest),
            PortalUtil.getLiferayPortletResponse(portletResponse), assetEntry, true);

    if (Validator.isNotNull(assetViewURL) && !assetViewURL.startsWith(Http.HTTP_WITH_SLASH)
            && !assetViewURL.startsWith(Http.HTTPS_WITH_SLASH)) {

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

        assetViewURL = themeDisplay.getPortalURL() + assetViewURL;
    }/*from   w w w .j  a  va  2  s.c  o m*/

    return assetViewURL;
}

From source file:com.liferay.content.targeting.analytics.hook.filter.YoutubeVideoHtmlFilter.java

License:Open Source License

private String sanitizeURL(String url, boolean secure) {
    if (url.startsWith(StringPool.DOUBLE_SLASH)) {
        url = url.replace(StringPool.DOUBLE_SLASH, StringPool.BLANK);
    }//  w w  w  .  j av a 2s.c  o  m

    if (!url.startsWith(Http.HTTP)) {
        url = Http.HTTP_WITH_SLASH + url;
    }

    return HttpUtil.protocolize(url, secure);
}

From source file:com.liferay.exportimport.staging.StagingImpl.java

License:Open Source License

@Override
public String buildRemoteURL(String remoteAddress, int remotePort, String remotePathContext,
        boolean secureConnection) {

    StringBundler sb = new StringBundler(5);

    if (secureConnection) {
        sb.append(Http.HTTPS_WITH_SLASH);
    } else {/*from  www.j a v a2  s  .  c  o m*/
        sb.append(Http.HTTP_WITH_SLASH);
    }

    sb.append(remoteAddress);

    if (remotePort > 0) {
        sb.append(StringPool.COLON);
        sb.append(remotePort);
    }

    if (Validator.isNotNull(remotePathContext)) {
        sb.append(remotePathContext);
    }

    return sb.toString();
}

From source file:com.liferay.exportimport.staging.StagingImpl.java

License:Open Source License

@Override
public String stripProtocolFromRemoteAddress(String remoteAddress) {
    if (remoteAddress.startsWith(Http.HTTP_WITH_SLASH)) {
        remoteAddress = remoteAddress.substring(Http.HTTP_WITH_SLASH.length());
    } else if (remoteAddress.startsWith(Http.HTTPS_WITH_SLASH)) {
        remoteAddress = remoteAddress.substring(Http.HTTPS_WITH_SLASH.length());
    }/*from w  w  w.j a  v a2s  . c o  m*/

    return remoteAddress;
}

From source file:com.liferay.iframe.web.internal.portlet.IFramePortlet.java

License:Open Source License

@Override
public void doView(RenderRequest renderRequest, RenderResponse renderResponse)
        throws IOException, PortletException {

    String src = null;//www  . j a  va  2 s.c  o  m

    try {
        src = transformSrc(renderRequest, renderResponse);
    } catch (PortalException pe) {
        _log.error(pe, pe);
    }

    renderRequest.setAttribute(IFrameWebKeys.IFRAME_SRC, src);

    if (Validator.isNull(src) || src.equals(Http.HTTP_WITH_SLASH) || src.equals(Http.HTTPS_WITH_SLASH)) {

        include("/portlet_not_setup.jsp", renderRequest, renderResponse);
    } else {
        super.doView(renderRequest, renderResponse);
    }
}