List of usage examples for com.liferay.portal.kernel.portlet LiferayPortletResponse createActionURL
public LiferayPortletURL createActionURL(String portletName);
From source file:com.liferay.blogs.item.selector.web.internal.display.context.BlogsItemSelectorViewDisplayContext.java
License:Open Source License
public PortletURL getUploadURL(LiferayPortletResponse liferayPortletResponse) { PortletURL portletURL = liferayPortletResponse.createActionURL(PortletKeys.BLOGS); portletURL.setParameter(ActionRequest.ACTION_NAME, "/blogs/upload_image"); return portletURL; }
From source file:com.liferay.contacts.contactscenter.notifications.ContactsCenterUserNotificationHandler.java
License:Open Source License
@Override protected String getBody(UserNotificationEvent userNotificationEvent, ServiceContext serviceContext) throws Exception { JSONObject jsonObject = JSONFactoryUtil.createJSONObject(userNotificationEvent.getPayload()); long socialRequestId = jsonObject.getLong("classPK"); SocialRequest socialRequest = SocialRequestLocalServiceUtil.fetchSocialRequest(socialRequestId); if (socialRequest == null) { UserNotificationEventLocalServiceUtil .deleteUserNotificationEvent(userNotificationEvent.getUserNotificationEventId()); return null; }//from w w w . j av a2s .com String title = StringPool.BLANK; if (socialRequest.getType() == SocialRelationConstants.TYPE_BI_CONNECTION) { String creatorUserName = getUserNameLink(socialRequest.getUserId(), serviceContext); title = serviceContext.translate("request-social-networking-summary-add-connection", creatorUserName); } LiferayPortletResponse liferayPortletResponse = serviceContext.getLiferayPortletResponse(); PortletURL confirmURL = liferayPortletResponse.createActionURL(PortletKeys.CONTACTS_CENTER); confirmURL.setParameter(ActionRequest.ACTION_NAME, "updateSocialRequest"); confirmURL.setParameter("redirect", serviceContext.getLayoutFullURL()); confirmURL.setParameter("socialRequestId", String.valueOf(socialRequestId)); confirmURL.setParameter("status", String.valueOf(SocialRequestConstants.STATUS_CONFIRM)); confirmURL.setParameter("userNotificationEventId", String.valueOf(userNotificationEvent.getUserNotificationEventId())); confirmURL.setWindowState(WindowState.NORMAL); PortletURL ignoreURL = liferayPortletResponse.createActionURL(PortletKeys.CONTACTS_CENTER); ignoreURL.setParameter(ActionRequest.ACTION_NAME, "updateSocialRequest"); ignoreURL.setParameter("redirect", serviceContext.getLayoutFullURL()); ignoreURL.setParameter("socialRequestId", String.valueOf(socialRequestId)); ignoreURL.setParameter("status", String.valueOf(SocialRequestConstants.STATUS_IGNORE)); ignoreURL.setParameter("userNotificationEventId", String.valueOf(userNotificationEvent.getUserNotificationEventId())); ignoreURL.setWindowState(WindowState.NORMAL); return StringUtil.replace(getBodyTemplate(), new String[] { "[$CONFIRM$]", "[$CONFIRM_URL$]", "[$IGNORE$]", "[$IGNORE_URL$]", "[$TITLE$]" }, new String[] { serviceContext.translate("confirm"), confirmURL.toString(), serviceContext.translate("ignore"), ignoreURL.toString(), title }); }
From source file:com.liferay.contacts.web.internal.notifications.ContactsCenterUserNotificationHandler.java
License:Open Source License
@Override protected String getBody(UserNotificationEvent userNotificationEvent, ServiceContext serviceContext) throws Exception { JSONObject jsonObject = JSONFactoryUtil.createJSONObject(userNotificationEvent.getPayload()); long socialRequestId = jsonObject.getLong("classPK"); SocialRequest socialRequest = _socialRequestLocalService.fetchSocialRequest(socialRequestId); if (socialRequest == null) { _userNotificationEventLocalService .deleteUserNotificationEvent(userNotificationEvent.getUserNotificationEventId()); return null; }/* ww w .j a v a2 s .co m*/ String creatorUserName = getUserNameLink(socialRequest.getUserId(), serviceContext); ResourceBundle resourceBundle = _resourceBundleLoader.loadResourceBundle(serviceContext.getLocale()); String title = StringPool.BLANK; if (socialRequest.getType() == SocialRelationConstants.TYPE_BI_CONNECTION) { title = ResourceBundleUtil.getString(resourceBundle, serviceContext.getLocale(), "request-social-networking-summary-add-connection", new Object[] { creatorUserName }); } else { title = ResourceBundleUtil.getString(resourceBundle, serviceContext.getLocale(), "x-sends-you-a-social-relationship-request", new Object[] { creatorUserName }); } if ((socialRequest.getStatus() != SocialRequestConstants.STATUS_PENDING) || (socialRequest.getModifiedDate() > userNotificationEvent.getTimestamp())) { return StringUtil.replace(_BODY, new String[] { "[$BODY$]", "[$TITLE$]" }, new String[] { StringPool.BLANK, title }); } LiferayPortletResponse liferayPortletResponse = serviceContext.getLiferayPortletResponse(); PortletURL confirmURL = liferayPortletResponse.createActionURL(ContactsPortletKeys.CONTACTS_CENTER); confirmURL.setParameter(ActionRequest.ACTION_NAME, "updateSocialRequest"); confirmURL.setParameter("redirect", serviceContext.getLayoutFullURL()); confirmURL.setParameter("socialRequestId", String.valueOf(socialRequestId)); confirmURL.setParameter("status", String.valueOf(SocialRequestConstants.STATUS_CONFIRM)); confirmURL.setParameter("userNotificationEventId", String.valueOf(userNotificationEvent.getUserNotificationEventId())); confirmURL.setWindowState(WindowState.NORMAL); PortletURL ignoreURL = liferayPortletResponse.createActionURL(ContactsPortletKeys.CONTACTS_CENTER); ignoreURL.setParameter(ActionRequest.ACTION_NAME, "updateSocialRequest"); ignoreURL.setParameter("redirect", serviceContext.getLayoutFullURL()); ignoreURL.setParameter("socialRequestId", String.valueOf(socialRequestId)); ignoreURL.setParameter("status", String.valueOf(SocialRequestConstants.STATUS_IGNORE)); ignoreURL.setParameter("userNotificationEventId", String.valueOf(userNotificationEvent.getUserNotificationEventId())); ignoreURL.setWindowState(WindowState.NORMAL); return StringUtil.replace(getBodyTemplate(), new String[] { "[$CONFIRM$]", "[$CONFIRM_URL$]", "[$IGNORE$]", "[$IGNORE_URL$]", "[$TITLE$]" }, new String[] { serviceContext.translate("confirm"), confirmURL.toString(), serviceContext.translate("ignore"), ignoreURL.toString(), title }); }
From source file:com.liferay.document.library.item.selector.web.internal.display.context.DLItemSelectorViewDisplayContext.java
License:Open Source License
public PortletURL getUploadURL(HttpServletRequest request, LiferayPortletResponse liferayPortletResponse) { PortletURL portletURL = liferayPortletResponse.createActionURL(PortletKeys.DOCUMENT_LIBRARY); portletURL.setParameter(ActionRequest.ACTION_NAME, "/document_library/upload_file_entry"); portletURL.setParameter("folderId", String.valueOf(getFolderId(request))); return portletURL; }
From source file:com.liferay.invitation.invite.members.web.internal.notifications.InviteMembersUserNotificationHandler.java
License:Open Source License
@Override protected String getBody(UserNotificationEvent userNotificationEvent, ServiceContext serviceContext) throws Exception { JSONObject jsonObject = JSONFactoryUtil.createJSONObject(userNotificationEvent.getPayload()); long memberRequestId = jsonObject.getLong("classPK"); MemberRequest memberRequest = _memberRequestLocalService.fetchMemberRequest(memberRequestId); if (memberRequest.getStatus() != MembershipRequestConstants.STATUS_PENDING) { return StringPool.BLANK; }//ww w . j a v a 2 s . c o m Group group = null; if (memberRequest != null) { group = _groupLocalService.fetchGroup(memberRequest.getGroupId()); } if ((group == null) || (memberRequest == null)) { _userNotificationEventLocalService .deleteUserNotificationEvent(userNotificationEvent.getUserNotificationEventId()); return null; } ResourceBundle resourceBundle = _resourceBundleLoader.loadResourceBundle(serviceContext.getLocale()); String title = ResourceBundleUtil.getString(resourceBundle, "x-invited-you-to-join-x", getUserNameLink(memberRequest.getUserId(), serviceContext), getSiteDescriptiveName(memberRequest.getGroupId(), serviceContext)); LiferayPortletResponse liferayPortletResponse = serviceContext.getLiferayPortletResponse(); PortletURL confirmURL = liferayPortletResponse.createActionURL(InviteMembersPortletKeys.INVITE_MEMBERS); confirmURL.setParameter(ActionRequest.ACTION_NAME, "updateMemberRequest"); confirmURL.setParameter("memberRequestId", String.valueOf(memberRequestId)); confirmURL.setParameter("status", String.valueOf(MembershipRequestConstants.STATUS_APPROVED)); confirmURL.setParameter("userNotificationEventId", String.valueOf(userNotificationEvent.getUserNotificationEventId())); confirmURL.setWindowState(WindowState.NORMAL); PortletURL ignoreURL = liferayPortletResponse.createActionURL(InviteMembersPortletKeys.INVITE_MEMBERS); ignoreURL.setParameter(ActionRequest.ACTION_NAME, "updateMemberRequest"); ignoreURL.setParameter("memberRequestId", String.valueOf(memberRequestId)); ignoreURL.setParameter("status", String.valueOf(MembershipRequestConstants.STATUS_DENIED)); ignoreURL.setParameter("userNotificationEventId", String.valueOf(userNotificationEvent.getUserNotificationEventId())); ignoreURL.setWindowState(WindowState.NORMAL); return StringUtil.replace(getBodyTemplate(), new String[] { "[$CONFIRM$]", "[$CONFIRM_URL$]", "[$IGNORE$]", "[$IGNORE_URL$]", "[$TITLE$]" }, new String[] { serviceContext.translate("confirm"), confirmURL.toString(), serviceContext.translate("ignore"), ignoreURL.toString(), title }); }
From source file:com.liferay.journal.item.selector.web.internal.context.JournalItemSelectorViewDisplayContext.java
License:Open Source License
public PortletURL getUploadURL(LiferayPortletResponse liferayPortletResponse) { PortletURL portletURL = liferayPortletResponse.createActionURL(JournalPortletKeys.JOURNAL); portletURL.setParameter(ActionRequest.ACTION_NAME, "/journal/upload_image"); return portletURL; }
From source file:com.liferay.notifications.notifications.portlet.NotificationsPortlet.java
License:Open Source License
protected String getIconMenu(UserNotificationEvent userNotificationEvent, LiferayPortletResponse liferayPortletResponse, ThemeDisplay themeDisplay) throws Exception { String markAsReadLI = StringPool.BLANK; if (!userNotificationEvent.isArchived()) { markAsReadLI = getMarkAsReadLI(themeDisplay); }// w ww . java 2s . c om String unsubscribeLI = StringPool.BLANK; JSONObject jsonObject = JSONFactoryUtil.createJSONObject(userNotificationEvent.getPayload()); long subscriptionId = jsonObject.getLong("subscriptionId"); if (subscriptionId > 0) { Subscription subscription = SubscriptionLocalServiceUtil.fetchSubscription(subscriptionId); if (subscription == null) { subscriptionId = 0; } } if (subscriptionId > 0) { PortletURL unsubscribeActionURL = liferayPortletResponse.createActionURL(PortletKeys.NOTIFICATIONS); unsubscribeActionURL.setParameter("subscriptionId", String.valueOf(subscriptionId)); unsubscribeActionURL.setParameter("userNotificationEventId", String.valueOf(userNotificationEvent.getUserNotificationEventId())); unsubscribeActionURL.setWindowState(WindowState.NORMAL); unsubscribeActionURL.setParameter("javax.portlet.action", "unsubscribe"); unsubscribeLI = getUnsubscribeLI(unsubscribeActionURL.toString(), themeDisplay); } String listItems = markAsReadLI + unsubscribeLI; return getIconMenuDiv(listItems); }
From source file:com.liferay.notifications.notifications.portlet.NotificationsPortlet.java
License:Open Source License
protected String renderEntry(ResourceRequest resourceRequest, ResourceResponse resourceResponse, UserNotificationEvent userNotificationEvent) throws Exception { ThemeDisplay themeDisplay = (ThemeDisplay) resourceRequest.getAttribute(WebKeys.THEME_DISPLAY); UserNotificationFeedEntry userNotificationFeedEntry = UserNotificationManagerUtil.interpret( StringPool.BLANK, userNotificationEvent, ServiceContextFactory.getInstance(resourceRequest)); if (userNotificationFeedEntry == null) { return null; }/*w w w . j a va2 s . c o m*/ LiferayPortletResponse liferayPortletResponse = (LiferayPortletResponse) resourceResponse; PortletURL actionURL = liferayPortletResponse.createActionURL(PortletKeys.NOTIFICATIONS); actionURL.setParameter("userNotificationEventId", String.valueOf(userNotificationEvent.getUserNotificationEventId())); actionURL.setWindowState(WindowState.NORMAL); String actionDiv = StringPool.BLANK; String cssClass = StringPool.BLANK; String iconMenu = StringPool.BLANK; if (userNotificationEvent.isActionRequired()) { actionURL.setParameter("javax.portlet.action", "deleteUserNotificationEvent"); actionDiv = StringUtil.replace(_DELETE_DIV, "[$DELETE_URL$]", actionURL.toString()); } else { actionURL.setParameter("javax.portlet.action", "markAsRead"); actionDiv = StringUtil.replace(_MARK_AS_READ_DIV, new String[] { "[$LINK$]", "[$MARK_AS_READ_URL$]" }, new String[] { userNotificationFeedEntry.getLink(), actionURL.toString() }); if (userNotificationEvent.isArchived()) { cssClass = "archived"; } iconMenu = getIconMenu(userNotificationEvent, liferayPortletResponse, themeDisplay); } Portlet portlet = PortletLocalServiceUtil.getPortletById(themeDisplay.getCompanyId(), userNotificationEvent.getType()); String portletName = portlet.getDisplayName(); String portletIcon = portlet.getContextPath() + portlet.getIcon(); JSONObject userNotificationEventJSONObject = JSONFactoryUtil .createJSONObject(userNotificationEvent.getPayload()); long userId = userNotificationEventJSONObject.getLong("userId"); String userFullName = HtmlUtil.escape(PortalUtil.getUserName(userId, StringPool.BLANK)); String userPortraitURL = StringPool.BLANK; User user = UserLocalServiceUtil.fetchUserById(userId); if (user != null) { userPortraitURL = user.getPortraitURL(themeDisplay); } Format dateFormatDate = FastDateFormatFactoryUtil.getDate(DateFormat.FULL, themeDisplay.getLocale(), themeDisplay.getTimeZone()); Format dateTimeFormat = FastDateFormatFactoryUtil.getDateTime(DateFormat.FULL, DateFormat.SHORT, themeDisplay.getLocale(), themeDisplay.getTimeZone()); return StringUtil.replace(ContentUtil.get(PortletPropsValues.USER_NOTIFICATION_ENTRY), new String[] { "[$ACTION_DIV$]", "[$BODY$]", "[$CSS_CLASS$]", "[$ICON_MENU$]", "[$PORTLET_ICON$]", "[$PORTLET_NAME$]", "[$TIMESTAMP$]", "[$TIMETITLE$]", "[$USER_FULL_NAME$]", "[$USER_PORTRAIT_URL$]" }, new String[] { actionDiv, userNotificationFeedEntry.getBody(), cssClass, iconMenu, portletIcon, portletName, Time.getRelativeTimeDescription(userNotificationEvent.getTimestamp(), themeDisplay.getLocale(), themeDisplay.getTimeZone(), dateFormatDate), dateTimeFormat.format(userNotificationEvent.getTimestamp()), userFullName, userPortraitURL }); }
From source file:com.liferay.so.invitemembers.notifications.InviteMembersUserNotificationHandler.java
License:Open Source License
@Override protected String getBody(UserNotificationEvent userNotificationEvent, ServiceContext serviceContext) throws Exception { JSONObject jsonObject = JSONFactoryUtil.createJSONObject(userNotificationEvent.getPayload()); long memberRequestId = jsonObject.getLong("classPK"); MemberRequest memberRequest = MemberRequestLocalServiceUtil.fetchMemberRequest(memberRequestId); if (memberRequest == null) { UserNotificationEventLocalServiceUtil .deleteUserNotificationEvent(userNotificationEvent.getUserNotificationEventId()); return null; }/* ww w. j a va 2s. c o m*/ String title = StringPool.BLANK; if (memberRequest.getStatus() == MembershipRequestConstants.STATUS_PENDING) { title = serviceContext.translate("x-invited-you-to-join-x", new Object[] { getUserNameLink(memberRequest.getUserId(), serviceContext), getSiteDescriptiveName(memberRequest.getGroupId(), serviceContext) }); } LiferayPortletResponse liferayPortletResponse = serviceContext.getLiferayPortletResponse(); PortletURL confirmURL = liferayPortletResponse.createActionURL(PortletKeys.SO_INVITE_MEMBERS); confirmURL.setParameter(ActionRequest.ACTION_NAME, "updateMemberRequest"); confirmURL.setParameter("memberRequestId", String.valueOf(memberRequestId)); confirmURL.setParameter("status", String.valueOf(MembershipRequestConstants.STATUS_APPROVED)); confirmURL.setParameter("userNotificationEventId", String.valueOf(userNotificationEvent.getUserNotificationEventId())); confirmURL.setWindowState(WindowState.NORMAL); PortletURL ignoreURL = liferayPortletResponse.createActionURL(PortletKeys.SO_INVITE_MEMBERS); ignoreURL.setParameter(ActionRequest.ACTION_NAME, "updateMemberRequest"); ignoreURL.setParameter("memberRequestId", String.valueOf(memberRequestId)); ignoreURL.setParameter("status", String.valueOf(MembershipRequestConstants.STATUS_DENIED)); ignoreURL.setParameter("userNotificationEventId", String.valueOf(userNotificationEvent.getUserNotificationEventId())); ignoreURL.setWindowState(WindowState.NORMAL); return StringUtil.replace(getBodyTemplate(), new String[] { "[$CONFIRM$]", "[$CONFIRM_URL$]", "[$IGNORE$]", "[$IGNORE_URL$]", "[$TITLE$]" }, new String[] { serviceContext.translate("confirm"), confirmURL.toString(), serviceContext.translate("ignore"), ignoreURL.toString(), title }); }
From source file:com.liferay.so.invitemembers.notifications.InviteMembersUserNotificationHandler.java
License:Open Source License
protected String getSiteDescriptiveName(long groupId, ServiceContext serviceContext) throws Exception { Group group = GroupLocalServiceUtil.getGroup(groupId); StringBundler sb = new StringBundler(6); sb.append("<a"); if (group.hasPublicLayouts()) { sb.append(" href=\""); LiferayPortletResponse liferayPortletResponse = serviceContext.getLiferayPortletResponse(); PortletURL portletURL = liferayPortletResponse.createActionURL(PortletKeys.SITE_REDIRECTOR); portletURL.setWindowState(WindowState.NORMAL); portletURL.setParameter("struts_action", "/my_sites/view"); portletURL.setParameter("groupId", String.valueOf(groupId)); portletURL.setParameter("privateLayout", Boolean.FALSE.toString()); sb.append(portletURL);/*from ww w. jav a 2 s .co m*/ sb.append("\">"); } else { sb.append(">"); } sb.append(HtmlUtil.escape(group.getDescriptiveName(serviceContext.getLocale()))); sb.append("</a>"); return sb.toString(); }