List of usage examples for com.liferay.portal.kernel.portlet LiferayPortletResponse createRenderURL
public LiferayPortletURL createRenderURL(String portletName);
From source file:com.liferay.calendar.asset.CalendarBookingAssetRenderer.java
License:Open Source License
@Override public String getURLViewInContext(LiferayPortletRequest liferayPortletRequest, LiferayPortletResponse liferayPortletResponse, String noSuchEntryRedirect) { try {/* ww w. j a va 2s . c o m*/ PortletURL portletURL = liferayPortletResponse.createRenderURL(PortletKeys.CALENDAR); portletURL.setParameter("mvcPath", "/view_calendar_booking.jsp"); portletURL.setParameter("calendarBookingId", String.valueOf(_calendarBooking.getCalendarBookingId())); portletURL.setWindowState(WindowState.MAXIMIZED); return portletURL.toString(); } catch (Exception e) { } return null; }
From source file:com.liferay.calendar.asset.CalendarBookingAssetRendererFactory.java
License:Open Source License
@Override public PortletURL getURLAdd(LiferayPortletRequest liferayPortletRequest, LiferayPortletResponse liferayPortletResponse) throws PortalException { ThemeDisplay themeDisplay = (ThemeDisplay) liferayPortletRequest.getAttribute(WebKeys.THEME_DISPLAY); CalendarResource calendarResource = CalendarResourceUtil .getScopeGroupCalendarResource(liferayPortletRequest, themeDisplay.getScopeGroupId()); if (calendarResource == null) { return null; }/* w w w. j av a2 s . c om*/ PortletURL portletURL = liferayPortletResponse.createRenderURL(PortletKeys.CALENDAR); portletURL.setParameter("mvcPath", "/edit_calendar_booking.jsp"); Calendar calendar = calendarResource.getDefaultCalendar(); portletURL.setParameter("calendarId", String.valueOf(calendar.getCalendarId())); return portletURL; }
From source file:com.liferay.calendar.web.internal.asset.CalendarBookingAssetRenderer.java
License:Open Source License
@Override public String getURLViewInContext(LiferayPortletRequest liferayPortletRequest, LiferayPortletResponse liferayPortletResponse, String noSuchEntryRedirect) { try {//from w ww . j a v a 2s . co m PortletURL portletURL = liferayPortletResponse.createRenderURL(CalendarPortletKeys.CALENDAR); portletURL.setParameter("mvcPath", "/view_calendar_booking.jsp"); portletURL.setParameter("calendarBookingId", String.valueOf(_calendarBooking.getCalendarBookingId())); portletURL.setWindowState(WindowState.MAXIMIZED); return portletURL.toString(); } catch (Exception e) { } return null; }
From source file:com.liferay.exportimport.changeset.web.internal.portlet.action.ExportImportEntityMVCActionCommand.java
License:Open Source License
protected void sendRedirect(ActionRequest actionRequest, ActionResponse actionResponse, long backgroundTaskId) throws IOException { LiferayPortletResponse liferayPortletResponse = _portal.getLiferayPortletResponse(actionResponse); PortletURL renderURL = liferayPortletResponse.createRenderURL(ExportImportPortletKeys.EXPORT_IMPORT); renderURL.setParameter("mvcPath", "/view_export_import.jsp"); renderURL.setParameter("backURL", actionRequest.getParameter("backURL")); renderURL.setParameter("backgroundTaskId", String.valueOf(backgroundTaskId)); actionRequest.setAttribute(WebKeys.REDIRECT, renderURL.toString()); hideDefaultSuccessMessage(actionRequest); sendRedirect(actionRequest, actionResponse); }
From source file:com.liferay.JournalArticleAssetRendererFactory.java
License:Open Source License
@Override public PortletURL getURLAdd(LiferayPortletRequest liferayPortletRequest, LiferayPortletResponse liferayPortletResponse) throws PortalException, SystemException { ThemeDisplay themeDisplay = (ThemeDisplay) liferayPortletRequest.getAttribute(WebKeys.THEME_DISPLAY); if (!JournalPermission.contains(themeDisplay.getPermissionChecker(), themeDisplay.getScopeGroupId(), ActionKeys.ADD_ARTICLE)) {/*from w ww .j a v a 2 s . co m*/ return null; } long classTypeId = GetterUtil .getLong(liferayPortletRequest.getAttribute(WebKeys.ASSET_RENDERER_FACTORY_CLASS_TYPE_ID)); if ((classTypeId > 0) && !DDMStructurePermission.contains(themeDisplay.getPermissionChecker(), classTypeId, ActionKeys.VIEW)) { return null; } PortletURL portletURL = liferayPortletResponse.createRenderURL(PortletKeys.JOURNAL); portletURL.setParameter("struts_action", "/journal/edit_article"); return portletURL; }
From source file:com.liferay.microblogs.util.MicroblogsUtil.java
License:Open Source License
protected static String replaceHashtags(String content, ServiceContext serviceContext) throws PortalException { String escapedContent = HtmlUtil.escape(content); ThemeDisplay themeDisplay = serviceContext.getThemeDisplay(); Matcher matcher = _hashtagPattern.matcher(content); while (matcher.find()) { String result = matcher.group(); StringBuilder sb = new StringBuilder(6); sb.append("<span class=\"hashtag\">#</span>"); sb.append("<a class=\"hashtag-link\" href=\""); PortletURL portletURL = null;/* w w w . java 2 s . c o m*/ Group group = GroupLocalServiceUtil.getUserGroup(themeDisplay.getCompanyId(), themeDisplay.getUserId()); long portletPlid = PortalUtil.getPlidFromPortletId(group.getGroupId(), true, "1_WAR_microblogsportlet"); if (portletPlid != 0) { portletURL = PortletURLFactoryUtil.create(serviceContext.getLiferayPortletRequest(), "1_WAR_microblogsportlet", portletPlid, PortletRequest.RENDER_PHASE); try { portletURL.setWindowState(LiferayWindowState.NORMAL); } catch (WindowStateException wse) { } } else { LiferayPortletResponse liferayPortletResponse = serviceContext.getLiferayPortletResponse(); portletURL = liferayPortletResponse.createRenderURL("1_WAR_microblogsportlet"); try { portletURL.setWindowState(WindowState.MAXIMIZED); } catch (WindowStateException wse) { } } portletURL.setParameter("mvcPath", "/microblogs/view.jsp"); String assetTagName = result.substring(1); portletURL.setParameter("tabs1", assetTagName); portletURL.setParameter("assetTagName", assetTagName); sb.append(portletURL); sb.append("\">"); sb.append(assetTagName); sb.append("</a>"); String tagLink = sb.toString(); escapedContent = StringUtil.replace(escapedContent, result, tagLink); } return escapedContent; }
From source file:com.liferay.microblogs.web.internal.util.MicroblogsWebUtil.java
License:Open Source License
protected static String replaceHashtags(String content, ServiceContext serviceContext) throws PortalException { String escapedContent = HtmlUtil.escape(content); ThemeDisplay themeDisplay = serviceContext.getThemeDisplay(); Matcher matcher = _hashtagPattern.matcher(content); while (matcher.find()) { String result = matcher.group(); StringBuilder sb = new StringBuilder(6); sb.append("<span class=\"hashtag\">#</span>"); sb.append("<a class=\"hashtag-link\" href=\""); PortletURL portletURL = null;//from w w w . jav a2 s .c om Group group = GroupLocalServiceUtil.getUserGroup(themeDisplay.getCompanyId(), themeDisplay.getUserId()); long portletPlid = PortalUtil.getPlidFromPortletId(group.getGroupId(), true, MicroblogsPortletKeys.MICROBLOGS); if (portletPlid != 0) { portletURL = PortletURLFactoryUtil.create(serviceContext.getLiferayPortletRequest(), MicroblogsPortletKeys.MICROBLOGS, portletPlid, PortletRequest.RENDER_PHASE); try { portletURL.setWindowState(LiferayWindowState.NORMAL); } catch (WindowStateException wse) { } } else { LiferayPortletResponse liferayPortletResponse = serviceContext.getLiferayPortletResponse(); portletURL = liferayPortletResponse.createRenderURL(MicroblogsPortletKeys.MICROBLOGS); try { portletURL.setWindowState(WindowState.MAXIMIZED); } catch (WindowStateException wse) { } } portletURL.setParameter("mvcPath", "/microblogs/view.jsp"); String assetTagName = result.substring(1); portletURL.setParameter("tabs1", assetTagName); portletURL.setParameter("assetTagName", assetTagName); sb.append(portletURL); sb.append("\">"); sb.append(assetTagName); sb.append("</a>"); String tagLink = sb.toString(); escapedContent = StringUtil.replace(escapedContent, result, tagLink); } return escapedContent; }
From source file:com.liferay.privatemessaging.notifications.PrivateMessagingUserNotificationHandler.java
License:Open Source License
@Override protected String getLink(UserNotificationEvent userNotificationEvent, ServiceContext serviceContext) throws Exception { long mbThreadId = 0; JSONObject jsonObject = JSONFactoryUtil.createJSONObject(userNotificationEvent.getPayload()); long classPK = jsonObject.getLong("classPK"); MBMessage mbMessage = MBMessageLocalServiceUtil.fetchMBMessage(classPK); if (mbMessage == null) { MBThread mbThread = MBThreadLocalServiceUtil.fetchMBThread(classPK); if (mbThread == null) { UserNotificationEventLocalServiceUtil .deleteUserNotificationEvent(userNotificationEvent.getUserNotificationEventId()); return null; }/*from ww w .j a v a 2s . c o m*/ mbThreadId = classPK; } else { mbThreadId = mbMessage.getThreadId(); } ThemeDisplay themeDisplay = serviceContext.getThemeDisplay(); User user = themeDisplay.getUser(); Group group = user.getGroup(); long portletPlid = PortalUtil.getPlidFromPortletId(group.getGroupId(), true, PortletKeys.PRIVATE_MESSAGING); PortletURL portletURL = null; if (portletPlid != 0) { portletURL = PortletURLFactoryUtil.create(serviceContext.getLiferayPortletRequest(), PortletKeys.PRIVATE_MESSAGING, portletPlid, PortletRequest.RENDER_PHASE); portletURL.setParameter("mbThreadId", String.valueOf(mbThreadId)); } else { LiferayPortletResponse liferayPortletResponse = serviceContext.getLiferayPortletResponse(); portletURL = liferayPortletResponse.createRenderURL(PortletKeys.PRIVATE_MESSAGING); portletURL.setParameter("mvcPath", "/view.jsp"); portletURL.setParameter("mbThreadId", String.valueOf(mbThreadId)); portletURL.setWindowState(WindowState.MAXIMIZED); } return portletURL.toString(); }
From source file:com.liferay.so.announcements.notifications.SOAnnouncementsUserNotificationHandler.java
License:Open Source License
@Override protected String getLink(UserNotificationEvent userNotificationEvent, ServiceContext serviceContext) throws Exception { JSONObject jsonObject = JSONFactoryUtil.createJSONObject(userNotificationEvent.getPayload()); long announcementEntryId = jsonObject.getLong("classPK"); AnnouncementsEntry announcementEntry = AnnouncementsEntryLocalServiceUtil .fetchAnnouncementsEntry(announcementEntryId); if (announcementEntry == null) { UserNotificationEventLocalServiceUtil .deleteUserNotificationEvent(userNotificationEvent.getUserNotificationEventId()); return null; }/*from w w w .ja v a 2 s .c om*/ ThemeDisplay themeDisplay = serviceContext.getThemeDisplay(); User user = themeDisplay.getUser(); Group group = user.getGroup(); long portletPlid = PortalUtil.getPlidFromPortletId(group.getGroupId(), true, PortletKeys.SO_ANNOUNCEMENTS); PortletURL portletURL = null; if (portletPlid != 0) { portletURL = PortletURLFactoryUtil.create(serviceContext.getLiferayPortletRequest(), PortletKeys.SO_ANNOUNCEMENTS, portletPlid, PortletRequest.RENDER_PHASE); } else { LiferayPortletResponse liferayPortletResponse = serviceContext.getLiferayPortletResponse(); portletURL = liferayPortletResponse.createRenderURL(PortletKeys.SO_ANNOUNCEMENTS); portletURL.setParameter("mvcPath", "/view.jsp"); portletURL.setWindowState(WindowState.MAXIMIZED); } return portletURL.toString(); }
From source file:com.liferay.users.admin.web.internal.portlet.action.ExportUsersMVCResourceCommand.java
License:Open Source License
protected List<User> getUsers(ResourceRequest resourceRequest, ResourceResponse resourceResponse) throws Exception { ThemeDisplay themeDisplay = (ThemeDisplay) resourceRequest.getAttribute(WebKeys.THEME_DISPLAY); PermissionChecker permissionChecker = themeDisplay.getPermissionChecker(); boolean exportAllUsers = PortalPermissionUtil.contains(permissionChecker, ActionKeys.EXPORT_USER); if (!exportAllUsers && !PortletPermissionUtil.contains(permissionChecker, UsersAdminPortletKeys.USERS_ADMIN, ActionKeys.EXPORT_USER)) {//from w w w.j ava2s . c om return Collections.emptyList(); } LiferayPortletResponse liferayPortletResponse = _portal.getLiferayPortletResponse(resourceResponse); PortletURL portletURL = liferayPortletResponse.createRenderURL(UsersAdminPortletKeys.USERS_ADMIN); UserSearch userSearch = new UserSearch(resourceRequest, portletURL); UserSearchTerms searchTerms = (UserSearchTerms) userSearch.getSearchTerms(); LinkedHashMap<String, Object> params = new LinkedHashMap<>(); long organizationId = searchTerms.getOrganizationId(); if (organizationId > 0) { params.put("usersOrgs", Long.valueOf(organizationId)); } else if (!exportAllUsers) { User user = themeDisplay.getUser(); Long[] organizationIds = ArrayUtil.toArray(user.getOrganizationIds(true)); if (organizationIds.length > 0) { params.put("usersOrgs", organizationIds); } } long roleId = searchTerms.getRoleId(); if (roleId > 0) { params.put("usersRoles", Long.valueOf(roleId)); } long userGroupId = searchTerms.getUserGroupId(); if (userGroupId > 0) { params.put("usersUserGroups", Long.valueOf(userGroupId)); } Indexer<?> indexer = IndexerRegistryUtil.nullSafeGetIndexer(User.class); if (indexer.isIndexerEnabled() && PropsValues.USERS_SEARCH_WITH_INDEX) { params.put("expandoAttributes", searchTerms.getKeywords()); } if (searchTerms.isAdvancedSearch()) { return _userLocalService.search(themeDisplay.getCompanyId(), searchTerms.getFirstName(), searchTerms.getMiddleName(), searchTerms.getLastName(), searchTerms.getScreenName(), searchTerms.getEmailAddress(), searchTerms.getStatus(), params, searchTerms.isAndOperator(), QueryUtil.ALL_POS, QueryUtil.ALL_POS, (OrderByComparator<User>) null); } else { return _userLocalService.search(themeDisplay.getCompanyId(), searchTerms.getKeywords(), searchTerms.getStatus(), params, QueryUtil.ALL_POS, QueryUtil.ALL_POS, (OrderByComparator<User>) null); } }