List of usage examples for com.liferay.portal.kernel.util WebKeys THEME_DISPLAY
String THEME_DISPLAY
To view the source code for com.liferay.portal.kernel.util WebKeys THEME_DISPLAY.
Click Source Link
From source file:com.beorn.onlinepayment.portlet.AdminPortlet.java
License:Open Source License
public void deleteRule(ActionRequest actionRequest, ActionResponse actionResponse) throws PortletException, IOException { try {/* ww w .j a v a2s . c o m*/ ThemeDisplay themeDisplay = (ThemeDisplay) actionRequest.getAttribute(WebKeys.THEME_DISPLAY); PermissionChecker permissionChecker = themeDisplay.getPermissionChecker(); long ruleId = ParamUtil.getLong(actionRequest, "ruleId"); Rule rule = RuleLocalServiceUtil.getRule(ruleId); PaymentPluginConfigPermission.check(permissionChecker, rule.getPaymentPluginConfigId(), ActionKeys.UPDATE); RuleLocalServiceUtil.deleteRule(rule); String redirect = ParamUtil.getString(actionRequest, "successURL"); actionResponse.sendRedirect(redirect); SessionMessages.add(actionRequest, "delete-rule.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 editPlugin(ActionRequest actionRequest, ActionResponse actionResponse) throws PortletException, IOException { try {/* w ww . j a v a 2 s.co m*/ ThemeDisplay themeDisplay = (ThemeDisplay) actionRequest.getAttribute(WebKeys.THEME_DISPLAY); PermissionChecker permissionChecker = themeDisplay.getPermissionChecker(); HttpServletRequest httpServletRequest = PortalUtil.getHttpServletRequest(actionRequest); ServletContext servletContext = httpServletRequest.getSession().getServletContext(); long paymentPluginId = ParamUtil.getLong(actionRequest, "pluginId"); PaymentPluginPermission.check(permissionChecker, paymentPluginId, ActionKeys.UPDATE); Map<Locale, String> nameMap = LocalizationUtil.getLocalizationMap(actionRequest, "name"); PaymentPlugin paymentPlugin = PaymentPluginLocalServiceUtil.getPaymentPlugin(paymentPluginId); String pluginConfig = ConfigUtil .getConfig(actionRequest, ConfigDescriptionUtil.parseConfigDescription(paymentPlugin.getPluginConfigParameters())) .toString(); if (Validator.isNull(nameMap) && nameMap.isEmpty()) SessionErrors.add(actionRequest, "name-required"); if (Validator.isNotNull(paymentPlugin.getPluginConfigParameters()) && !isConfigValid(servletContext, paymentPlugin, pluginConfig, false)) SessionErrors.add(actionRequest, "invalid-config"); if (!SessionErrors.isEmpty(actionRequest)) { actionResponse.setRenderParameters(actionRequest.getParameterMap()); return; } ServiceContext serviceContext = ServiceContextFactory.getInstance(PaymentPlugin.class.getName(), actionRequest); paymentPlugin = PaymentPluginLocalServiceUtil.updatePaymentPlugin(paymentPluginId, paymentPlugin.getApplicationId(), nameMap, null, null, pluginConfig, true, serviceContext); String redirect = ParamUtil.getString(actionRequest, "successURL"); actionResponse.sendRedirect(redirect); SessionMessages.add(actionRequest, "edit-plugin.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 editSellerPlugin(ActionRequest actionRequest, ActionResponse actionResponse) throws PortletException, IOException { try {//from w w w. j a v a 2 s.c o m ThemeDisplay themeDisplay = (ThemeDisplay) actionRequest.getAttribute(WebKeys.THEME_DISPLAY); PermissionChecker permissionChecker = themeDisplay.getPermissionChecker(); HttpServletRequest httpServletRequest = PortalUtil.getHttpServletRequest(actionRequest); ServletContext servletContext = httpServletRequest.getSession().getServletContext(); long pluginConfigId = ParamUtil.getLong(actionRequest, "pluginConfigId"); PaymentPluginConfigPermission.check(permissionChecker, pluginConfigId, ActionKeys.UPDATE); PaymentPluginConfig pluginConfig = PaymentPluginConfigLocalServiceUtil .getPaymentPluginConfig(pluginConfigId); PaymentPlugin paymentPlugin = PaymentPluginLocalServiceUtil .getPaymentPlugin(pluginConfig.getPaymentPluginId()); String config = ConfigUtil .getConfig(actionRequest, ConfigDescriptionUtil.parseConfigDescription(paymentPlugin.getSellerConfigParameters())) .toString(); if (Validator.isNotNull(paymentPlugin.getSellerConfigParameters())) { if (!isConfigValid(servletContext, paymentPlugin, config, true)) SessionErrors.add(actionRequest, "invalid-config"); } else { config = StringPool.BLANK; } if (!SessionErrors.isEmpty(actionRequest)) { actionResponse.setRenderParameters(actionRequest.getParameterMap()); return; } ServiceContext serviceContext = ServiceContextFactory.getInstance(PaymentPluginConfig.class.getName(), actionRequest); pluginConfig = PaymentPluginConfigLocalServiceUtil.updatePaymentPluginConfig(pluginConfigId, pluginConfig.getSellerId(), pluginConfig.getPaymentPluginId(), config, true, serviceContext); String redirect = ParamUtil.getString(actionRequest, "successURL"); actionResponse.sendRedirect(redirect); SessionMessages.add(actionRequest, "edit-seller-plugin.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 editMethod(ActionRequest actionRequest, ActionResponse actionResponse) throws PortletException, IOException { try {//from w w w . j a v a 2 s . com ThemeDisplay themeDisplay = (ThemeDisplay) actionRequest.getAttribute(WebKeys.THEME_DISPLAY); PermissionChecker permissionChecker = themeDisplay.getPermissionChecker(); long paymentMethodId = ParamUtil.getLong(actionRequest, "methodId"); PaymentMethodPermission.check(permissionChecker, paymentMethodId, ActionKeys.UPDATE); Map<Locale, String> nameMap = LocalizationUtil.getLocalizationMap(actionRequest, "name"); if (Validator.isNull(nameMap) && nameMap.isEmpty()) SessionErrors.add(actionRequest, "name-required"); if (!SessionErrors.isEmpty(actionRequest)) { actionResponse.setRenderParameters(actionRequest.getParameterMap()); return; } ServiceContext serviceContext = ServiceContextFactory.getInstance(Seller.class.getName(), actionRequest); PaymentMethod paymentMethod = PaymentMethodLocalServiceUtil.getPaymentMethod(paymentMethodId); paymentMethod = PaymentMethodLocalServiceUtil.updatePaymentMethod(paymentMethodId, paymentMethod.getKey(), nameMap, serviceContext); String redirect = ParamUtil.getString(actionRequest, "successURL"); actionResponse.sendRedirect(redirect); SessionMessages.add(actionRequest, "edit-method.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 associatePluginSellers(ActionRequest actionRequest, ActionResponse actionResponse) throws PortletException, IOException { try {/* www. java 2 s . com*/ ThemeDisplay themeDisplay = (ThemeDisplay) actionRequest.getAttribute(WebKeys.THEME_DISPLAY); PermissionChecker permissionChecker = themeDisplay.getPermissionChecker(); long pluginId = ParamUtil.getLong(actionRequest, "pluginId"); PaymentAppPermission.check(permissionChecker, themeDisplay.getScopeGroupId(), ActionKeys.ADD_PAYMENT_PLUGIN_CONFIG); ServiceContext serviceContext = ServiceContextFactory.getInstance(PaymentPluginConfig.class.getName(), actionRequest); List<Seller> sellers = SellerServiceUtil.search(themeDisplay.getCompanyId(), null, true, QueryUtil.ALL_POS, QueryUtil.ALL_POS, new SellerCreateDateComparator()); for (Seller seller : sellers) { String paramName = "seller_" + seller.getSellerId(); boolean sellerEnabled = ParamUtil.getBoolean(actionRequest, paramName); boolean sellerWasEnabled = PaymentPluginConfigLocalServiceUtil .hasPaymentPluginConfigBySellerIdAndPaymentPluginId(seller.getSellerId(), pluginId); if (!sellerWasEnabled && sellerEnabled) { PaymentPluginConfigLocalServiceUtil.addPaymentPluginConfig(seller.getUserId(), seller.getSellerId(), pluginId, serviceContext); } else if (sellerWasEnabled && !sellerEnabled) { PaymentPluginConfig paymentPluginConfig = PaymentPluginConfigLocalServiceUtil .getPaymentPluginConfigBySellerIdAndPaymentPluginId(seller.getSellerId(), pluginId); PaymentPluginConfigLocalServiceUtil.deletePaymentPluginConfig(paymentPluginConfig); } } String redirect = ParamUtil.getString(actionRequest, "successURL"); actionResponse.sendRedirect(redirect); SessionMessages.add(actionRequest, "associate-plugin-sellers.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 associateSellerPlugins(ActionRequest actionRequest, ActionResponse actionResponse) throws PortletException, IOException { try {//from ww w . j av a 2s . c o m ThemeDisplay themeDisplay = (ThemeDisplay) actionRequest.getAttribute(WebKeys.THEME_DISPLAY); PermissionChecker permissionChecker = themeDisplay.getPermissionChecker(); long sellerId = ParamUtil.getLong(actionRequest, "sellerId"); PaymentAppPermission.check(permissionChecker, themeDisplay.getScopeGroupId(), ActionKeys.ADD_PAYMENT_PLUGIN_CONFIG); Seller seller = SellerLocalServiceUtil.getSeller(sellerId); ServiceContext serviceContext = ServiceContextFactory.getInstance(PaymentPluginConfig.class.getName(), actionRequest); List<PaymentPlugin> paymentPlugins = PaymentPluginServiceUtil.search(themeDisplay.getCompanyId(), null, null, null, QueryUtil.ALL_POS, QueryUtil.ALL_POS, new PaymentPluginCreateDateComparator()); for (PaymentPlugin paymentPlugin : paymentPlugins) { String paramName = "paymentPlugin_" + paymentPlugin.getPaymentPluginId(); boolean paymentPluginEnabled = ParamUtil.getBoolean(actionRequest, paramName); boolean paymentPluginWasEnabled = PaymentPluginConfigLocalServiceUtil .hasPaymentPluginConfigBySellerIdAndPaymentPluginId(sellerId, paymentPlugin.getPaymentPluginId()); if (!paymentPluginWasEnabled && paymentPluginEnabled) { PaymentPluginConfigLocalServiceUtil.addPaymentPluginConfig(seller.getUserId(), sellerId, paymentPlugin.getPaymentPluginId(), serviceContext); } else if (paymentPluginWasEnabled && !paymentPluginEnabled) { PaymentPluginConfig paymentPluginConfig = PaymentPluginConfigLocalServiceUtil .getPaymentPluginConfigBySellerIdAndPaymentPluginId(sellerId, paymentPlugin.getPaymentPluginId()); PaymentPluginConfigLocalServiceUtil.deletePaymentPluginConfig(paymentPluginConfig); } } String redirect = ParamUtil.getString(actionRequest, "successURL"); actionResponse.sendRedirect(redirect); SessionMessages.add(actionRequest, "associate-seller-plugins.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 editRulesPriority(ActionRequest actionRequest, ActionResponse actionResponse) throws PortletException, IOException { try {//from w w w.ja v a 2 s. co m ThemeDisplay themeDisplay = (ThemeDisplay) actionRequest.getAttribute(WebKeys.THEME_DISPLAY); PermissionChecker permissionChecker = themeDisplay.getPermissionChecker(); long sellerId = ParamUtil.getLong(actionRequest, "sellerId"); SellerPermission.check(permissionChecker, sellerId, ActionKeys.UPDATE); ServiceContext serviceContext = ServiceContextFactory.getInstance(Rule.class.getName(), actionRequest); for (Rule rule : RuleLocalServiceUtil.getSellerRules(sellerId, QueryUtil.ALL_POS, QueryUtil.ALL_POS, null)) { int priority = ParamUtil.getInteger(actionRequest, "rulePriority_" + rule.getRuleId()); RuleLocalServiceUtil.updateRule(rule.getRuleId(), rule.getPaymentPluginConfigId(), rule.getContent(), priority, serviceContext); } SessionMessages.add(actionRequest, "edit-rules-priority.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 editDefaultPluginConfig(ActionRequest actionRequest, ActionResponse actionResponse) throws PortletException, IOException { try {/*from w w w . j ava 2 s .co m*/ ThemeDisplay themeDisplay = (ThemeDisplay) actionRequest.getAttribute(WebKeys.THEME_DISPLAY); PermissionChecker permissionChecker = themeDisplay.getPermissionChecker(); long sellerId = ParamUtil.getLong(actionRequest, "sellerId"); long defaultPaymentPluginConfigId = ParamUtil.getLong(actionRequest, "defaultPaymentPluginConfigId"); SellerPermission.check(permissionChecker, sellerId, ActionKeys.UPDATE); PaymentPluginConfigLocalServiceUtil.updateDefaultPluginConfig(sellerId, defaultPaymentPluginConfigId); SessionMessages.add(actionRequest, "edit-default-plugin-config.success"); } catch (Exception e) { _log.error(e); actionResponse.setRenderParameters(actionRequest.getParameterMap()); SessionErrors.add(actionRequest, e.getClass().getName()); } }
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;/*w ww. ja va 2s. c o 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 ww . j a va2s .c o m }