List of usage examples for com.liferay.portal.kernel.util Constants SAVE
String SAVE
To view the source code for com.liferay.portal.kernel.util Constants SAVE.
Click Source Link
From source file:com.beorn.onlinepayment.shopping.action.BtopCheckoutAction.java
License:Open Source License
@Override public void processAction(StrutsPortletAction originalStrutsPortletAction, PortletConfig portletConfig, ActionRequest actionRequest, ActionResponse actionResponse) throws Exception { ThemeDisplay themeDisplay = (ThemeDisplay) actionRequest.getAttribute(WebKeys.THEME_DISPLAY); long companyId = themeDisplay.getCompanyId(); long ownerId = themeDisplay.getScopeGroupId(); int ownerType = PortletKeys.PREFS_OWNER_TYPE_GROUP; long plid = PortletKeys.PREFS_PLID_SHARED; String portletId = PortletKeys.SHOPPING; PortletPreferences preferences = PortletPreferencesLocalServiceUtil.getPreferences(companyId, ownerId, ownerType, plid, portletId); String paymentType = PrefsParamUtil.getString(preferences, actionRequest, "paymentType"); String cmd = ParamUtil.getString(actionRequest, Constants.CMD); if (cmd.equals(Constants.SAVE) && paymentType.equals("Betop")) { processSaveCheckoutActionWithoutForwarding(originalStrutsPortletAction, actionRequest, actionResponse); PaymentAppSender paymentAppSender = PaymentAppUtil.getPaymentAppSender(); ShoppingCart cart = ShoppingUtil.getCart(actionRequest); ShoppingOrder order = (ShoppingOrder) actionRequest.getAttribute("SHOPPING_ORDER"); long sellerId = GetterUtil.getLong(preferences.getValue("sellerId", "0")); double amount = ShoppingUtil.calculateTotal(cart.getItems(), order.getBillingState(), cart.getCoupon(), cart.getAltShipping(), cart.isInsure()); String currencyCode = preferences.getValue("currencyId", "USD"); Long transactionId = paymentAppSender.addTransaction(sellerId, amount, currencyCode); OrderTransactionLocalServiceUtil.addOrderTransaction(order.getOrderId(), transactionId); HttpServletRequest request = PortalUtil.getHttpServletRequest(actionRequest); String remoteIp = request.getRemoteAddr(); String forwardedForIp = StringUtil.extractFirst(request.getHeader("X-Forwarded-For"), StringPool.COMMA_AND_SPACE); if (forwardedForIp != null) remoteIp = forwardedForIp;/* www.j a v a 2s . co m*/ List<ApiPaymentMethod> paymentMethods = paymentAppSender.getPaymentMethods(transactionId, paymentAppSender.geolocalizeIp(remoteIp)); Long[] paymentMethodIds = new Long[paymentMethods.size()]; String[] paymentMethodNames = new String[paymentMethods.size()]; for (int i = 0; i < paymentMethods.size(); ++i) { paymentMethodIds[i] = paymentMethods.get(i).getPaymentMethodId(); paymentMethodNames[i] = paymentMethods.get(i).getName(themeDisplay.getLocale()); } actionRequest.setAttribute("orderId", order.getOrderId()); actionRequest.setAttribute("paymentMethodIds", paymentMethodIds); actionRequest.setAttribute("paymentMethodNames", paymentMethodNames); } else { originalStrutsPortletAction.processAction(originalStrutsPortletAction, portletConfig, actionRequest, actionResponse); } }
From source file:com.beorn.onlinepayment.shopping.action.BtopCheckoutAction.java
License:Open Source License
@Override public String render(StrutsPortletAction originalStrutsPortletAction, PortletConfig portletConfig, RenderRequest renderRequest, RenderResponse renderResponse) throws Exception { ThemeDisplay themeDisplay = (ThemeDisplay) renderRequest.getAttribute(WebKeys.THEME_DISPLAY); long companyId = themeDisplay.getCompanyId(); long ownerId = themeDisplay.getScopeGroupId(); int ownerType = PortletKeys.PREFS_OWNER_TYPE_GROUP; long plid = PortletKeys.PREFS_PLID_SHARED; String portletId = PortletKeys.SHOPPING; PortletPreferences preferences = PortletPreferencesLocalServiceUtil.getPreferences(companyId, ownerId, ownerType, plid, portletId); String paymentType = PrefsParamUtil.getString(preferences, renderRequest, "paymentType"); String cmd = ParamUtil.getString(renderRequest, Constants.CMD); if (cmd.equals(Constants.SAVE) && paymentType.equals("Betop")) return "/portlet/shopping/btop_choose_payment_method.jsp"; return originalStrutsPortletAction.render(originalStrutsPortletAction, portletConfig, renderRequest, renderResponse);/*from w w w. jav a 2 s. co m*/ }
From source file:com.liferay.portlet.portletconfiguration.action.EditArchivedSetupsAction.java
License:Open Source License
@Override public void processAction(ActionMapping mapping, ActionForm form, PortletConfig portletConfig, ActionRequest actionRequest, ActionResponse actionResponse) throws Exception { Portlet portlet = null;//from ww w . java2 s . co m try { portlet = getPortlet(actionRequest); } catch (PrincipalException pe) { SessionErrors.add(actionRequest, PrincipalException.class.getName()); setForward(actionRequest, "portlet.portlet_configuration.error"); } String cmd = ParamUtil.getString(actionRequest, Constants.CMD); try { if (cmd.equals(Constants.SAVE)) { updateSetup(actionRequest, portlet); } else if (cmd.equals(Constants.RESTORE)) { restoreSetup(actionRequest, portlet); } else if (cmd.equals(Constants.DELETE)) { deleteSetup(actionRequest); } } catch (Exception e) { if (e instanceof NoSuchPortletItemException || e instanceof PortletItemNameException) { SessionErrors.add(actionRequest, e.getClass().getName()); sendRedirect(actionRequest, actionResponse); } else if (e instanceof PrincipalException) { SessionErrors.add(actionRequest, e.getClass().getName()); setForward(actionRequest, "portlet.portlet_configuration.error"); } else { throw e; } } if (SessionErrors.isEmpty(actionRequest)) { String portletResource = ParamUtil.getString(actionRequest, "portletResource"); SessionMessages.add(actionRequest, portletConfig.getPortletName() + SessionMessages.KEY_SUFFIX_REFRESH_PORTLET, portletResource); SessionMessages.add(actionRequest, portletConfig.getPortletName() + SessionMessages.KEY_SUFFIX_UPDATED_CONFIGURATION); String redirect = PortalUtil.escapeRedirect(ParamUtil.getString(actionRequest, "redirect")); if (Validator.isNotNull(redirect)) { actionResponse.sendRedirect(redirect); } } }
From source file:com.liferay.portlet.portletconfiguration.action.EditScopeAction.java
License:Open Source License
@Override public void processAction(ActionMapping mapping, ActionForm form, PortletConfig portletConfig, ActionRequest actionRequest, ActionResponse actionResponse) throws Exception { Portlet portlet = null;/*from w w w . java 2 s .c o m*/ try { portlet = getPortlet(actionRequest); } catch (PrincipalException pe) { SessionErrors.add(actionRequest, PrincipalException.class.getName()); setForward(actionRequest, "portlet.portlet_configuration.error"); } String cmd = ParamUtil.getString(actionRequest, Constants.CMD); if (cmd.equals(Constants.SAVE)) { updateScope(actionRequest, portlet); } if (SessionErrors.isEmpty(actionRequest)) { String portletResource = ParamUtil.getString(actionRequest, "portletResource"); SessionMessages.add(actionRequest, portletConfig.getPortletName() + SessionMessages.KEY_SUFFIX_REFRESH_PORTLET, portletResource); SessionMessages.add(actionRequest, portletConfig.getPortletName() + SessionMessages.KEY_SUFFIX_UPDATED_CONFIGURATION); String redirect = PortalUtil.escapeRedirect(ParamUtil.getString(actionRequest, "redirect")); if (Validator.isNotNull(redirect)) { actionResponse.sendRedirect(redirect); } } }
From source file:com.liferay.portlet.shopping.action.CheckoutAction.java
License:Open Source License
@Override public void processAction(ActionMapping mapping, ActionForm form, PortletConfig portletConfig, ActionRequest actionRequest, ActionResponse actionResponse) throws Exception { if (redirectToLogin(actionRequest, actionResponse)) { return;/*w ww . j a v a 2 s . c o m*/ } String cmd = ParamUtil.getString(actionRequest, Constants.CMD); getLatestOrder(actionRequest); if (cmd.equals(Constants.SAVE)) { updateCart(actionRequest, actionResponse); updateLatestOrder(actionRequest); saveLatestOrder(actionRequest); forwardCheckout(actionRequest, actionResponse); } else if (cmd.equals(Constants.UPDATE)) { try { updateLatestOrder(actionRequest); setForward(actionRequest, "portlet.shopping.checkout_second"); } catch (Exception e) { if (e instanceof BillingCityException || e instanceof BillingCountryException || e instanceof BillingEmailAddressException || e instanceof BillingFirstNameException || e instanceof BillingLastNameException || e instanceof BillingPhoneException || e instanceof BillingStateException || e instanceof BillingStreetException || e instanceof BillingZipException || e instanceof CCExpirationException || e instanceof CCNameException || e instanceof CCNumberException || e instanceof CCTypeException || e instanceof ShippingCityException || e instanceof ShippingCountryException || e instanceof ShippingEmailAddressException || e instanceof ShippingFirstNameException || e instanceof ShippingLastNameException || e instanceof ShippingPhoneException || e instanceof ShippingStateException || e instanceof ShippingStreetException || e instanceof ShippingZipException) { SessionErrors.add(actionRequest, e.getClass().getName()); setForward(actionRequest, "portlet.shopping.checkout_first"); } else if (e instanceof PrincipalException) { setForward(actionRequest, "portlet.shopping.error"); } else { throw e; } } } else if (cmd.equals(Constants.VIEW)) { setForward(actionRequest, "portlet.shopping.checkout_third"); } else { setForward(actionRequest, "portlet.shopping.checkout_first"); } }
From source file:com.liferay.portlet.workflowtasks.action.EditWorkflowTaskAction.java
License:Open Source License
@Override public void processAction(ActionMapping mapping, ActionForm form, PortletConfig portletConfig, ActionRequest actionRequest, ActionResponse actionResponse) throws Exception { String cmd = ParamUtil.getString(actionRequest, Constants.CMD); try {//w w w . j a v a 2 s . c om if (cmd.equals(Constants.ASSIGN)) { assignTask(actionRequest); } else if (cmd.equals(Constants.SAVE)) { completeTask(actionRequest); } else if (cmd.equals(Constants.UPDATE)) { updateTask(actionRequest); } sendRedirect(actionRequest, actionResponse); } catch (Exception e) { if (e instanceof WorkflowTaskDueDateException) { SessionErrors.add(actionRequest, e.getClass().getName()); } else if (e instanceof PrincipalException || e instanceof WorkflowException) { SessionErrors.add(actionRequest, e.getClass().getName()); setForward(actionRequest, "portlet.workflow_tasks.error"); } else { throw e; } } }