List of usage examples for com.liferay.portal.kernel.util HttpUtil setParameter
public static String setParameter(String url, String name, String value)
From source file:com.beorn.onlinepayment.portlet.AdminPortlet.java
License:Open Source License
public void editSeller(ActionRequest actionRequest, ActionResponse actionResponse) throws PortletException, IOException { try {/*from w ww . j a va2 s . c o m*/ ThemeDisplay themeDisplay = (ThemeDisplay) actionRequest.getAttribute(WebKeys.THEME_DISPLAY); PermissionChecker permissionChecker = themeDisplay.getPermissionChecker(); long sellerId = ParamUtil.getLong(actionRequest, "sellerId"); String name = ParamUtil.getString(actionRequest, "name"); boolean active = ParamUtil.getBoolean(actionRequest, "active"); if (Validator.isNull(name)) SessionErrors.add(actionRequest, "name-required"); if (!SessionErrors.isEmpty(actionRequest)) { actionResponse.setRenderParameters(actionRequest.getParameterMap()); return; } ServiceContext serviceContext = ServiceContextFactory.getInstance(Seller.class.getName(), actionRequest); Seller seller; if (sellerId == 0) { PaymentAppPermission.check(permissionChecker, themeDisplay.getScopeGroupId(), ActionKeys.ADD_SELLER); seller = SellerLocalServiceUtil.addSeller(themeDisplay.getUserId(), name, active, serviceContext); } else { SellerPermission.check(permissionChecker, sellerId, ActionKeys.UPDATE); seller = SellerLocalServiceUtil.updateSeller(sellerId, name, active, serviceContext); } String redirect = ParamUtil.getString(actionRequest, "successURL"); redirect = HttpUtil.setParameter(redirect, "_1_WAR_onlinepaymentportlet_sellerId", seller.getSellerId()); actionResponse.sendRedirect(redirect); SessionMessages.add(actionRequest, "edit-seller.success"); } catch (Exception e) { _log.error(e); actionResponse.setRenderParameters(actionRequest.getParameterMap()); SessionErrors.add(actionRequest, e.getClass().getName()); } }
From source file:com.beorn.onlinepayment.portlet.AdminPortlet.java
License:Open Source License
public void editRule(ActionRequest actionRequest, ActionResponse actionResponse) throws PortletException, IOException { try {//w ww . j a v a 2 s . c o m ThemeDisplay themeDisplay = (ThemeDisplay) actionRequest.getAttribute(WebKeys.THEME_DISPLAY); PermissionChecker permissionChecker = themeDisplay.getPermissionChecker(); long ruleId = ParamUtil.getLong(actionRequest, "ruleId"); long paymentPluginConfigId = ParamUtil.getLong(actionRequest, "paymentPluginConfigId"); String content = ParamUtil.getString(actionRequest, "content"); PaymentPluginConfigPermission.check(permissionChecker, paymentPluginConfigId, ActionKeys.UPDATE); ServiceContext serviceContext = ServiceContextFactory.getInstance(Rule.class.getName(), actionRequest); Rule rule; if (ruleId == 0) { rule = RuleLocalServiceUtil.addRule(themeDisplay.getUserId(), paymentPluginConfigId, content, 0, serviceContext); } else { // Check that the user can update the previous config rule = RuleLocalServiceUtil.getRule(ruleId); PaymentPluginConfigPermission.check(permissionChecker, rule.getPaymentPluginConfigId(), ActionKeys.UPDATE); rule = RuleLocalServiceUtil.updateRule(ruleId, paymentPluginConfigId, content, rule.getPriority(), serviceContext); } String redirect = ParamUtil.getString(actionRequest, "successURL"); redirect = HttpUtil.setParameter(redirect, "_1_WAR_onlinepaymentportlet_ruleId", rule.getRuleId()); actionResponse.sendRedirect(redirect); SessionMessages.add(actionRequest, "edit-rule.success"); } catch (Exception e) { _log.error(e); actionResponse.setRenderParameters(actionRequest.getParameterMap()); SessionErrors.add(actionRequest, e.getClass().getName()); } }
From source file:com.liferay.asset.publisher.web.util.AssetPublisherHelper.java
License:Open Source License
public static String getAssetViewURL(LiferayPortletRequest liferayPortletRequest, LiferayPortletResponse liferayPortletResponse, AssetRenderer<?> assetRenderer, AssetEntry assetEntry, boolean viewInContext) { PortletURL viewFullContentURL = liferayPortletResponse.createRenderURL(); viewFullContentURL.setParameter("mvcPath", "/view_content.jsp"); viewFullContentURL.setParameter("assetEntryId", String.valueOf(assetEntry.getEntryId())); PortletURL redirectURL = liferayPortletResponse.createRenderURL(); int cur = ParamUtil.getInteger(liferayPortletRequest, "cur"); int delta = ParamUtil.getInteger(liferayPortletRequest, "delta"); boolean resetCur = ParamUtil.getBoolean(liferayPortletRequest, "resetCur"); redirectURL.setParameter("cur", String.valueOf(cur)); if (delta > 0) { redirectURL.setParameter("delta", String.valueOf(delta)); }//from w w w. jav a2 s .c o m redirectURL.setParameter("resetCur", String.valueOf(resetCur)); redirectURL.setParameter("assetEntryId", String.valueOf(assetEntry.getEntryId())); viewFullContentURL.setParameter("redirect", redirectURL.toString()); AssetRendererFactory<?> assetRendererFactory = assetRenderer.getAssetRendererFactory(); viewFullContentURL.setParameter("type", assetRendererFactory.getType()); ThemeDisplay themeDisplay = (ThemeDisplay) liferayPortletRequest.getAttribute(WebKeys.THEME_DISPLAY); if (Validator.isNotNull(assetRenderer.getUrlTitle())) { if (assetRenderer.getGroupId() != themeDisplay.getScopeGroupId()) { viewFullContentURL.setParameter("groupId", String.valueOf(assetRenderer.getGroupId())); } viewFullContentURL.setParameter("urlTitle", assetRenderer.getUrlTitle()); } String viewURL = null; if (viewInContext) { try { String noSuchEntryRedirect = viewFullContentURL.toString(); viewURL = assetRenderer.getURLViewInContext(liferayPortletRequest, liferayPortletResponse, noSuchEntryRedirect); if (Validator.isNotNull(viewURL) && !Objects.equals(viewURL, noSuchEntryRedirect)) { viewURL = HttpUtil.setParameter(viewURL, "redirect", PortalUtil.getCurrentURL(liferayPortletRequest)); } } catch (Exception e) { } } if (Validator.isNull(viewURL)) { viewURL = viewFullContentURL.toString(); } return viewURL; }
From source file:com.liferay.calendar.portlet.CalendarPortlet.java
License:Open Source License
public void updateCalendarBooking(ActionRequest actionRequest, ActionResponse actionResponse) throws Exception { long calendarBookingId = ParamUtil.getLong(actionRequest, "calendarBookingId"); long calendarId = ParamUtil.getLong(actionRequest, "calendarId"); long[] childCalendarIds = ParamUtil.getLongValues(actionRequest, "childCalendarIds"); Map<Locale, String> titleMap = LocalizationUtil.getLocalizationMap(actionRequest, "title"); Map<Locale, String> descriptionMap = LocalizationUtil.getLocalizationMap(actionRequest, "description"); String location = ParamUtil.getString(actionRequest, "location"); java.util.Calendar startTimeJCalendar = getJCalendar(actionRequest, "startTime"); java.util.Calendar endTimeJCalendar = getJCalendar(actionRequest, "endTime"); boolean allDay = ParamUtil.getBoolean(actionRequest, "allDay"); String recurrence = getRecurrence(actionRequest); long[] reminders = getReminders(actionRequest); String[] remindersType = getRemindersType(actionRequest); int status = ParamUtil.getInteger(actionRequest, "status"); ServiceContext serviceContext = ServiceContextFactory.getInstance(CalendarBooking.class.getName(), actionRequest);/*from w ww .ja va 2 s . c o m*/ CalendarBooking calendarBooking = null; if (calendarBookingId <= 0) { calendarBooking = CalendarBookingServiceUtil.addCalendarBooking(calendarId, childCalendarIds, CalendarBookingConstants.PARENT_CALENDAR_BOOKING_ID_DEFAULT, titleMap, descriptionMap, location, startTimeJCalendar.getTimeInMillis(), endTimeJCalendar.getTimeInMillis(), allDay, recurrence, reminders[0], remindersType[0], reminders[1], remindersType[1], serviceContext); } else { int instanceIndex = ParamUtil.getInteger(actionRequest, "instanceIndex"); boolean updateCalendarBookingInstance = ParamUtil.getBoolean(actionRequest, "updateCalendarBookingInstance"); if (updateCalendarBookingInstance) { calendarBooking = CalendarBookingLocalServiceUtil.getCalendarBooking(calendarBookingId); boolean allFollowing = ParamUtil.getBoolean(actionRequest, "allFollowing"); calendarBooking = CalendarBookingServiceUtil.updateCalendarBookingInstance(calendarBookingId, instanceIndex, calendarId, childCalendarIds, titleMap, descriptionMap, location, startTimeJCalendar.getTimeInMillis(), endTimeJCalendar.getTimeInMillis(), allDay, recurrence, allFollowing, reminders[0], remindersType[0], reminders[1], remindersType[1], status, serviceContext); } else { calendarBooking = CalendarBookingServiceUtil.getCalendarBookingInstance(calendarBookingId, instanceIndex); long duration = (endTimeJCalendar.getTimeInMillis() - startTimeJCalendar.getTimeInMillis()); long offset = (startTimeJCalendar.getTimeInMillis() - calendarBooking.getStartTime()); calendarBooking = CalendarBookingServiceUtil .getNewStartTimeAndDurationCalendarBooking(calendarBookingId, offset, duration); calendarBooking = CalendarBookingServiceUtil.updateCalendarBooking(calendarBookingId, calendarId, childCalendarIds, titleMap, descriptionMap, location, calendarBooking.getStartTime(), calendarBooking.getEndTime(), allDay, recurrence, reminders[0], remindersType[0], reminders[1], remindersType[1], status, serviceContext); } } String redirect = getRedirect(actionRequest, actionResponse); redirect = HttpUtil.setParameter(redirect, actionResponse.getNamespace() + "calendarBookingId", calendarBooking.getCalendarBookingId()); actionRequest.setAttribute(WebKeys.REDIRECT, redirect); }
From source file:com.liferay.calendar.portlet.CalendarPortlet.java
License:Open Source License
protected String getEditCalendarURL(ActionRequest actionRequest, ActionResponse actionResponse, Calendar calendar) throws Exception { ThemeDisplay themeDisplay = (ThemeDisplay) actionRequest.getAttribute(WebKeys.THEME_DISPLAY); String editCalendarURL = getRedirect(actionRequest, actionResponse); if (Validator.isNull(editCalendarURL)) { editCalendarURL = PortalUtil.getLayoutFullURL(themeDisplay); }// w ww . jav a 2 s .com String namespace = actionResponse.getNamespace(); editCalendarURL = HttpUtil.setParameter(editCalendarURL, "p_p_id", PortletKeys.CALENDAR); editCalendarURL = HttpUtil.setParameter(editCalendarURL, namespace + "mvcPath", templatePath + "edit_calendar.jsp"); editCalendarURL = HttpUtil.setParameter(editCalendarURL, namespace + "redirect", getRedirect(actionRequest, actionResponse)); editCalendarURL = HttpUtil.setParameter(editCalendarURL, namespace + "backURL", ParamUtil.getString(actionRequest, "backURL")); editCalendarURL = HttpUtil.setParameter(editCalendarURL, namespace + "calendarId", calendar.getCalendarId()); return editCalendarURL; }
From source file:com.liferay.calendar.web.internal.portlet.CalendarPortlet.java
License:Open Source License
public void updateFormCalendarBooking(ActionRequest actionRequest, ActionResponse actionResponse) throws Exception { long calendarBookingId = ParamUtil.getLong(actionRequest, "calendarBookingId"); long calendarId = ParamUtil.getLong(actionRequest, "calendarId"); Calendar calendar = _calendarService.getCalendar(calendarId); long[] childCalendarIds = ParamUtil.getLongValues(actionRequest, "childCalendarIds"); Map<Locale, String> titleMap = LocalizationUtil.getLocalizationMap(actionRequest, "title"); Map<Locale, String> descriptionMap = LocalizationUtil.getLocalizationMap(actionRequest, "description"); String location = ParamUtil.getString(actionRequest, "location"); java.util.Calendar startTimeJCalendar = getJCalendar(actionRequest, "startTime"); java.util.Calendar endTimeJCalendar = getJCalendar(actionRequest, "endTime"); boolean allDay = ParamUtil.getBoolean(actionRequest, "allDay"); Recurrence recurrence = getRecurrence(actionRequest); long[] reminders = getReminders(actionRequest); String[] remindersType = getRemindersType(actionRequest); int instanceIndex = ParamUtil.getInteger(actionRequest, "instanceIndex"); boolean updateCalendarBookingInstance = ParamUtil.getBoolean(actionRequest, "updateCalendarBookingInstance"); boolean allFollowing = ParamUtil.getBoolean(actionRequest, "allFollowing"); ServiceContext serviceContext = ServiceContextFactory.getInstance(CalendarBooking.class.getName(), actionRequest);//from ww w . j a v a 2s .co m CalendarBooking calendarBooking = updateCalendarBooking(calendarBookingId, calendar, childCalendarIds, titleMap, descriptionMap, location, startTimeJCalendar.getTimeInMillis(), endTimeJCalendar.getTimeInMillis(), allDay, recurrence, reminders, remindersType, instanceIndex, updateCalendarBookingInstance, allFollowing, serviceContext); String redirect = getRedirect(actionRequest, actionResponse); redirect = HttpUtil.setParameter(redirect, actionResponse.getNamespace() + "calendarBookingId", calendarBooking.getCalendarBookingId()); actionRequest.setAttribute(WebKeys.REDIRECT, redirect); }
From source file:com.liferay.calendar.web.internal.portlet.CalendarPortlet.java
License:Open Source License
protected String getEditCalendarURL(ActionRequest actionRequest, ActionResponse actionResponse, Calendar calendar) throws Exception { ThemeDisplay themeDisplay = (ThemeDisplay) actionRequest.getAttribute(WebKeys.THEME_DISPLAY); String editCalendarURL = getRedirect(actionRequest, actionResponse); if (Validator.isNull(editCalendarURL)) { editCalendarURL = _portal.getLayoutFullURL(themeDisplay); }//from www. j a v a 2s . c om String namespace = actionResponse.getNamespace(); editCalendarURL = HttpUtil.setParameter(editCalendarURL, "p_p_id", themeDisplay.getPpid()); editCalendarURL = HttpUtil.setParameter(editCalendarURL, namespace + "mvcPath", templatePath + "edit_calendar.jsp"); editCalendarURL = HttpUtil.setParameter(editCalendarURL, namespace + "redirect", getRedirect(actionRequest, actionResponse)); editCalendarURL = HttpUtil.setParameter(editCalendarURL, namespace + "backURL", ParamUtil.getString(actionRequest, "backURL")); editCalendarURL = HttpUtil.setParameter(editCalendarURL, namespace + "calendarId", calendar.getCalendarId()); return editCalendarURL; }
From source file:com.liferay.dynamic.data.mapping.web.internal.portlet.action.DDMBaseMVCActionCommand.java
License:Open Source License
protected String getRedirect(ActionRequest actionRequest) { String redirect = ParamUtil.getString(actionRequest, "redirect"); String closeRedirect = ParamUtil.getString(actionRequest, "closeRedirect"); if (Validator.isNull(closeRedirect)) { return redirect; }/*from www. j a v a 2 s .c o m*/ redirect = HttpUtil.setParameter(redirect, "closeRedirect", closeRedirect); SessionMessages.add(actionRequest, PortalUtil.getPortletId(actionRequest) + SessionMessages.KEY_SUFFIX_CLOSE_REDIRECT, closeRedirect); return redirect; }
From source file:com.liferay.knowledgebase.hook.events.ServicePreAction.java
License:Open Source License
protected void doRun(HttpServletRequest request, HttpServletResponse response) throws Exception { ThemeDisplay themeDisplay = (ThemeDisplay) request.getAttribute(WebKeys.THEME_DISPLAY); if (!_PORTLET_ADD_DEFAULT_RESOURCE_CHECK_ENABLED) { return;//from ww w .j a v a2s.c om } if (!themeDisplay.isLifecycleRender()) { return; } String portletId = ParamUtil.getString(request, "p_p_id"); if (Validator.isNull(portletId)) { return; } if (!portletId.equals(PortletKeys.KNOWLEDGE_BASE_ARTICLE_DEFAULT_INSTANCE)) { return; } String request_p_p_auth = ParamUtil.getString(request, "p_p_auth"); if (Validator.isNull(request_p_p_auth)) { return; } String actual_p_p_auth = AuthTokenUtil.getToken(request, themeDisplay.getPlid(), portletId); if (request_p_p_auth.equals(actual_p_p_auth)) { return; } // A guest user that signs in will cause the original portlet // authentication token to become stale. See SessionAuthToken. String redirect = HttpUtil.setParameter(themeDisplay.getURLCurrent(), "p_p_auth", actual_p_p_auth); response.sendRedirect(redirect); }
From source file:com.liferay.knowledgebase.portlet.BaseKBPortlet.java
License:Open Source License
protected String buildEditURL(ActionRequest actionRequest, ActionResponse actionResponse, KBArticle kbArticle) throws PortalException { ThemeDisplay themeDisplay = (ThemeDisplay) actionRequest.getAttribute(WebKeys.THEME_DISPLAY); PortletDisplay portletDisplay = themeDisplay.getPortletDisplay(); String editURL = PortalUtil.getLayoutFullURL(themeDisplay); editURL = HttpUtil.setParameter(editURL, "p_p_id", portletDisplay.getId()); editURL = HttpUtil.setParameter(editURL, actionResponse.getNamespace() + "mvcPath", templatePath + "edit_article.jsp"); editURL = HttpUtil.setParameter(editURL, actionResponse.getNamespace() + "redirect", getRedirect(actionRequest, actionResponse)); editURL = HttpUtil.setParameter(editURL, actionResponse.getNamespace() + "resourcePrimKey", kbArticle.getResourcePrimKey()); editURL = HttpUtil.setParameter(editURL, actionResponse.getNamespace() + "status", WorkflowConstants.STATUS_ANY); return editURL; }