List of usage examples for com.liferay.portal.kernel.util PortalUtil getLayoutFullURL
public static String getLayoutFullURL(long groupId, String portletId) throws PortalException
From source file:com.liferay.blogs.internal.util.PingbackMethodImpl.java
License:Open Source License
protected ServiceContext buildServiceContext(long companyId, long groupId, String urlTitle) throws Exception { ServiceContext serviceContext = new ServiceContext(); String pingbackUserName = LanguageUtil.get(LocaleUtil.getSiteDefault(), "pingback"); serviceContext.setAttribute("pingbackUserName", pingbackUserName); StringBundler sb = new StringBundler(5); String portletId = PortletProviderUtil.getPortletId(BlogsEntry.class.getName(), PortletProvider.Action.VIEW); if (Validator.isNull(portletId)) { return serviceContext; }/* w w w.ja v a2s . c o m*/ String layoutFullURL = PortalUtil.getLayoutFullURL(groupId, portletId); sb.append(layoutFullURL); sb.append(Portal.FRIENDLY_URL_SEPARATOR); Portlet portlet = _portletLocalService.getPortletById(companyId, portletId); sb.append(portlet.getFriendlyURLMapping()); sb.append(StringPool.SLASH); sb.append(urlTitle); serviceContext.setAttribute("redirect", sb.toString()); serviceContext.setLayoutFullURL(layoutFullURL); return serviceContext; }
From source file:com.liferay.blogs.service.impl.BlogsEntryLocalServiceImpl.java
License:Open Source License
@Override public void checkEntries() throws PortalException { Date now = new Date(); int count = blogsEntryPersistence.countByLtD_S(now, WorkflowConstants.STATUS_SCHEDULED); if (count == 0) { return;// w ww.j a va 2s. c om } List<BlogsEntry> entries = blogsEntryPersistence.findByLtD_S(now, WorkflowConstants.STATUS_SCHEDULED); for (BlogsEntry entry : entries) { ServiceContext serviceContext = new ServiceContext(); String[] trackbacks = StringUtil.split(entry.getTrackbacks()); serviceContext.setAttribute("trackbacks", trackbacks); serviceContext.setCommand(Constants.UPDATE); String portletId = PortletProviderUtil.getPortletId(BlogsEntry.class.getName(), PortletProvider.Action.VIEW); if (Validator.isNotNull(portletId)) { String layoutFullURL = PortalUtil.getLayoutFullURL(entry.getGroupId(), portletId); serviceContext.setLayoutFullURL(layoutFullURL); } serviceContext.setScopeGroupId(entry.getGroupId()); blogsEntryLocalService.updateStatus(entry.getStatusByUserId(), entry.getEntryId(), WorkflowConstants.STATUS_APPROVED, serviceContext, new HashMap<String, Serializable>()); } }
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;// www . j av a 2 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.blogs.service.test.BlogsEntryStatusTransitionTest.java
License:Open Source License
protected ServiceContext getServiceContext(BlogsEntry entry) throws Exception { ServiceContext serviceContext = new ServiceContext(); String[] trackbacks = StringUtil.split(entry.getTrackbacks()); serviceContext.setAttribute("trackbacks", trackbacks); serviceContext.setCommand(Constants.UPDATE); String portletId = PortletProviderUtil.getPortletId(BlogsEntry.class.getName(), PortletProvider.Action.VIEW); String layoutFullURL = PortalUtil.getLayoutFullURL(entry.getGroupId(), portletId); serviceContext.setLayoutFullURL(layoutFullURL); serviceContext.setScopeGroupId(entry.getGroupId()); return serviceContext; }
From source file:com.liferay.journal.service.impl.JournalArticleLocalServiceImpl.java
License:Open Source License
protected void checkArticlesByDisplayDate(Date displayDate) throws PortalException { String portletId = PortletProviderUtil.getPortletId(JournalArticle.class.getName(), PortletProvider.Action.EDIT); List<JournalArticle> articles = journalArticlePersistence.findByLtD_S(displayDate, WorkflowConstants.STATUS_SCHEDULED); for (JournalArticle article : articles) { long userId = PortalUtil.getValidUserId(article.getCompanyId(), article.getUserId()); ServiceContext serviceContext = new ServiceContext(); serviceContext.setCommand(Constants.UPDATE); String layoutFullURL = PortalUtil.getLayoutFullURL(article.getGroupId(), portletId); serviceContext.setLayoutFullURL(layoutFullURL); serviceContext.setScopeGroupId(article.getGroupId()); journalArticleLocalService.updateStatus(userId, article, WorkflowConstants.STATUS_APPROVED, null, serviceContext, new HashMap<String, Serializable>()); }//from w w w . j a va 2 s. c o m }
From source file:com.liferay.layout.admin.web.internal.display.context.LayoutsAdminDisplayContext.java
License:Open Source License
public String getEditLayoutURL(Layout layout) throws PortalException { return PortalUtil.getLayoutFullURL(layout, _themeDisplay); }
From source file:com.liferay.wiki.web.internal.portlet.action.RSSAction.java
License:Open Source License
@Override protected byte[] getRSS(HttpServletRequest request) throws Exception { ThemeDisplay themeDisplay = (ThemeDisplay) request.getAttribute(WebKeys.THEME_DISPLAY); long nodeId = ParamUtil.getLong(request, "nodeId"); String title = ParamUtil.getString(request, "title"); int max = ParamUtil.getInteger(request, "max", SearchContainer.DEFAULT_DELTA); String type = ParamUtil.getString(request, "type", RSSUtil.FORMAT_DEFAULT); double version = ParamUtil.getDouble(request, "version", RSSUtil.VERSION_DEFAULT); String displayStyle = ParamUtil.getString(request, "displayStyle", RSSUtil.DISPLAY_STYLE_DEFAULT); String layoutFullURL = PortalUtil.getLayoutFullURL(themeDisplay.getScopeGroupId(), WikiPortletKeys.WIKI); StringBundler sb = new StringBundler(4); sb.append(layoutFullURL);/* w ww . j a v a2s . c om*/ sb.append(Portal.FRIENDLY_URL_SEPARATOR); sb.append("wiki/"); sb.append(nodeId); String feedURL = sb.toString(); String entryURL = feedURL + StringPool.SLASH + title; Locale locale = themeDisplay.getLocale(); String rss = StringPool.BLANK; if (nodeId > 0) { String attachmentURLPrefix = WikiUtil.getAttachmentURLPrefix(themeDisplay.getPathMain(), themeDisplay.getPlid(), nodeId, title); if (Validator.isNotNull(title)) { rss = _wikiPageService.getPagesRSS(nodeId, title, max, type, version, displayStyle, feedURL, entryURL, attachmentURLPrefix, locale); } else { rss = _wikiPageService.getNodePagesRSS(nodeId, max, type, version, displayStyle, feedURL, entryURL, attachmentURLPrefix); } } return rss.getBytes(StringPool.UTF8); }