List of usage examples for com.liferay.portal.util PropsValues BLOGS_PING_GOOGLE_ENABLED
boolean BLOGS_PING_GOOGLE_ENABLED
To view the source code for com.liferay.portal.util PropsValues BLOGS_PING_GOOGLE_ENABLED.
Click Source Link
From source file:com.liferay.blogs.service.impl.BlogsEntryLocalServiceImpl.java
License:Open Source License
protected void pingGoogle(BlogsEntry entry, ServiceContext serviceContext) throws PortalException { if (!PropsValues.BLOGS_PING_GOOGLE_ENABLED || !entry.isApproved()) { return;/* w ww .j a va2 s . c o m*/ } String portletId = PortletProviderUtil.getPortletId(BlogsEntry.class.getName(), PortletProvider.Action.MANAGE); if (Validator.isNull(portletId)) { if (_log.isDebugEnabled()) { _log.debug("Not pinging Google because there is no blogs portlet " + "provider"); } return; } String layoutFullURL = PortalUtil.getLayoutFullURL(serviceContext.getScopeGroupId(), portletId); if (Validator.isNull(layoutFullURL)) { return; } if (layoutFullURL.contains("://localhost")) { if (_log.isDebugEnabled()) { _log.debug("Not pinging Google because of localhost URL " + layoutFullURL); } return; } Group group = groupPersistence.findByPrimaryKey(entry.getGroupId()); StringBundler sb = new StringBundler(6); String name = group.getDescriptiveName(); String url = layoutFullURL + Portal.FRIENDLY_URL_SEPARATOR + "blogs"; String changesURL = serviceContext.getPathMain() + "/blogs/rss"; sb.append("http://blogsearch.google.com/ping?name="); sb.append(HttpUtil.encodeURL(name)); sb.append("&url="); sb.append(HttpUtil.encodeURL(url)); sb.append("&changesURL="); sb.append(HttpUtil.encodeURL(changesURL)); String location = sb.toString(); if (_log.isInfoEnabled()) { _log.info("Pinging Google at " + location); } try { String response = HttpUtil.URLtoString(sb.toString()); if (_log.isInfoEnabled()) { _log.info("Google ping response: " + response); } } catch (IOException ioe) { _log.error("Unable to ping Google at " + location, ioe); } }
From source file:com.liferay.portlet.blogs.service.impl.BlogsEntryLocalServiceImpl.java
License:Open Source License
protected void pingGoogle(BlogsEntry entry, ServiceContext serviceContext) throws PortalException, SystemException { if (!PropsValues.BLOGS_PING_GOOGLE_ENABLED || !entry.isApproved()) { return;//w ww . j a va 2s . com } String layoutFullURL = PortalUtil.getLayoutFullURL(serviceContext.getScopeGroupId(), PortletKeys.BLOGS); if (Validator.isNull(layoutFullURL)) { return; } if (layoutFullURL.contains("://localhost")) { if (_log.isDebugEnabled()) { _log.debug("Not pinging Google because of localhost URL " + layoutFullURL); } return; } Group group = groupPersistence.findByPrimaryKey(entry.getGroupId()); StringBundler sb = new StringBundler(6); String name = group.getDescriptiveName(); String url = layoutFullURL + Portal.FRIENDLY_URL_SEPARATOR + "blogs"; String changesURL = layoutFullURL + Portal.FRIENDLY_URL_SEPARATOR + "blogs/rss"; sb.append("http://blogsearch.google.com/ping?name="); sb.append(HttpUtil.encodeURL(name)); sb.append("&url="); sb.append(HttpUtil.encodeURL(url)); sb.append("&changesURL="); sb.append(HttpUtil.encodeURL(changesURL)); String location = sb.toString(); if (_log.isInfoEnabled()) { _log.info("Pinging Google at " + location); } try { String response = HttpUtil.URLtoString(sb.toString()); if (_log.isInfoEnabled()) { _log.info("Google ping response: " + response); } } catch (IOException ioe) { _log.error("Unable to ping Google at " + location, ioe); } }