Example usage for com.liferay.portal.kernel.util ParamUtil getDouble

List of usage examples for com.liferay.portal.kernel.util ParamUtil getDouble

Introduction

In this page you can find the example usage for com.liferay.portal.kernel.util ParamUtil getDouble.

Prototype

public static double getDouble(ServiceContext serviceContext, String param, double defaultValue) 

Source Link

Document

Returns the service context parameter value as a double.

Usage

From source file:com.liferay.blogs.web.internal.portlet.action.RSSAction.java

License:Open Source License

@Override
protected byte[] getRSS(HttpServletRequest request) throws Exception {
    ThemeDisplay themeDisplay = (ThemeDisplay) request.getAttribute(WebKeys.THEME_DISPLAY);

    Layout layout = themeDisplay.getLayout();

    long plid = ParamUtil.getLong(request, "p_l_id");

    if (plid == LayoutConstants.DEFAULT_PLID) {
        plid = themeDisplay.getPlid();/*from   ww  w.  j av  a 2s  .  c  o  m*/
    }

    long companyId = ParamUtil.getLong(request, "companyId");
    long groupId = ParamUtil.getLong(request, "groupId");
    long organizationId = ParamUtil.getLong(request, "organizationId");
    int status = WorkflowConstants.STATUS_APPROVED;
    int max = ParamUtil.getInteger(request, "max", SearchContainer.DEFAULT_DELTA);
    String type = ParamUtil.getString(request, "type", RSSUtil.FORMAT_DEFAULT);
    double version = ParamUtil.getDouble(request, "version", RSSUtil.VERSION_DEFAULT);
    String displayStyle = ParamUtil.getString(request, "displayStyle", RSSUtil.DISPLAY_STYLE_DEFAULT);

    String feedURL = themeDisplay.getPortalURL() + themeDisplay.getPathMain() + "/blogs/find_entry?";

    String entryURL = feedURL;

    String rss = StringPool.BLANK;

    if (companyId > 0) {
        feedURL = StringPool.BLANK;

        rss = _blogsEntryService.getCompanyEntriesRSS(companyId, new Date(), status, max, type, version,
                displayStyle, feedURL, entryURL, themeDisplay);
    } else if (groupId > 0) {
        feedURL += "p_l_id=" + plid;

        entryURL = feedURL;

        rss = _blogsEntryService.getGroupEntriesRSS(groupId, new Date(), status, max, type, version,
                displayStyle, feedURL, entryURL, themeDisplay);
    } else if (organizationId > 0) {
        feedURL = StringPool.BLANK;

        rss = _blogsEntryService.getOrganizationEntriesRSS(organizationId, new Date(), status, max, type,
                version, displayStyle, feedURL, entryURL, themeDisplay);
    } else if (layout != null) {
        groupId = themeDisplay.getScopeGroupId();

        feedURL = themeDisplay.getPathMain() + "/blogs/rss";

        entryURL = feedURL;

        rss = _blogsEntryService.getGroupEntriesRSS(groupId, new Date(), status, max, type, version,
                displayStyle, feedURL, entryURL, themeDisplay);
    }

    return rss.getBytes(StringPool.UTF8);
}

From source file:com.liferay.journal.web.internal.portlet.action.ActionUtil.java

License:Open Source License

public static JournalArticle getPreviewArticle(PortletRequest portletRequest) throws Exception {

    long groupId = ParamUtil.getLong(portletRequest, "groupId");
    String articleId = ParamUtil.getString(portletRequest, "articleId");
    double version = ParamUtil.getDouble(portletRequest, "version", JournalArticleConstants.VERSION_DEFAULT);

    JournalArticle article = JournalArticleServiceUtil.getArticle(groupId, articleId, version);

    JournalUtil.addRecentArticle(portletRequest, article);

    return article;
}

From source file:com.liferay.message.boards.web.internal.portlet.action.RSSAction.java

License:Open Source License

@Override
protected byte[] getRSS(HttpServletRequest request) throws Exception {
    ThemeDisplay themeDisplay = (ThemeDisplay) request.getAttribute(WebKeys.THEME_DISPLAY);

    long plid = ParamUtil.getLong(request, "p_l_id");

    if (plid == LayoutConstants.DEFAULT_PLID) {
        plid = themeDisplay.getPlid();//from  ww  w. j  a  v  a 2s  . c o  m
    }

    long companyId = ParamUtil.getLong(request, "companyId");
    long groupId = ParamUtil.getLong(request, "groupId");
    long userId = ParamUtil.getLong(request, "userId");
    long categoryId = ParamUtil.getLong(request, "mbCategoryId");
    long threadId = ParamUtil.getLong(request, "threadId");
    int max = ParamUtil.getInteger(request, "max", SearchContainer.DEFAULT_DELTA);
    String type = ParamUtil.getString(request, "type", RSSUtil.FORMAT_DEFAULT);
    double version = ParamUtil.getDouble(request, "version", RSSUtil.VERSION_DEFAULT);
    String displayStyle = ParamUtil.getString(request, "displayStyle", RSSUtil.DISPLAY_STYLE_DEFAULT);

    String entryURL = themeDisplay.getPortalURL() + themeDisplay.getPathMain()
            + "/message_boards/find_message?p_l_id=" + plid;

    String rss = StringPool.BLANK;

    if (companyId > 0) {
        String feedURL = StringPool.BLANK;

        rss = _mbMessageService.getCompanyMessagesRSS(companyId, WorkflowConstants.STATUS_APPROVED, max, type,
                version, displayStyle, feedURL, entryURL, themeDisplay);
    } else if (groupId > 0) {
        String mvcRenderCommandName = ParamUtil.getString(request, "mvcRenderCommandName");

        String feedURL = null;

        if (mvcRenderCommandName.equals("/message_boards/view_recent_posts")) {

            feedURL = themeDisplay.getPortalURL() + themeDisplay.getPathMain()
                    + "/message_boards/find_recent_posts?p_l_id=" + plid;
        } else {
            feedURL = themeDisplay.getPortalURL() + themeDisplay.getPathMain()
                    + "/message_boards/find_category?p_l_id=" + plid + "&mbCategoryId=" + categoryId;
        }

        if (userId > 0) {
            rss = _mbMessageService.getGroupMessagesRSS(groupId, userId, WorkflowConstants.STATUS_APPROVED, max,
                    type, version, displayStyle, feedURL, entryURL, themeDisplay);
        } else {
            rss = _mbMessageService.getGroupMessagesRSS(groupId, WorkflowConstants.STATUS_APPROVED, max, type,
                    version, displayStyle, feedURL, entryURL, themeDisplay);
        }
    } else if (categoryId > 0) {
        String feedURL = themeDisplay.getPortalURL() + themeDisplay.getPathMain()
                + "/message_boards/find_category?p_l_id=" + plid + "&mbCategoryId=" + categoryId;

        rss = _mbMessageService.getCategoryMessagesRSS(groupId, categoryId, WorkflowConstants.STATUS_APPROVED,
                max, type, version, displayStyle, feedURL, entryURL, themeDisplay);
    } else if (threadId > 0) {
        String feedURL = themeDisplay.getPortalURL() + themeDisplay.getPathMain()
                + "/message_boards/find_thread?p_l_id=" + plid + "&threadId=" + threadId;

        rss = _mbMessageService.getThreadMessagesRSS(threadId, WorkflowConstants.STATUS_APPROVED, max, type,
                version, displayStyle, feedURL, entryURL, themeDisplay);
    }

    return rss.getBytes(StringPool.UTF8);
}

From source file:com.liferay.portlet.blogs.action.RSSAction.java

License:Open Source License

protected byte[] getRSS(HttpServletRequest request) throws Exception {
    ThemeDisplay themeDisplay = (ThemeDisplay) request.getAttribute(WebKeys.THEME_DISPLAY);

    Layout layout = themeDisplay.getLayout();

    long plid = ParamUtil.getLong(request, "p_l_id");
    long companyId = ParamUtil.getLong(request, "companyId");
    long groupId = ParamUtil.getLong(request, "groupId");
    long organizationId = ParamUtil.getLong(request, "organizationId");
    int status = WorkflowConstants.STATUS_APPROVED;
    int max = ParamUtil.getInteger(request, "max", SearchContainer.DEFAULT_DELTA);
    String type = ParamUtil.getString(request, "type", RSSUtil.TYPE_DEFAULT);
    double version = ParamUtil.getDouble(request, "version", RSSUtil.VERSION_DEFAULT);
    String displayStyle = ParamUtil.getString(request, "displayStyle", RSSUtil.DISPLAY_STYLE_FULL_CONTENT);

    String feedURL = themeDisplay.getPortalURL() + themeDisplay.getPathMain() + "/blogs/find_entry?";

    String entryURL = feedURL;//ww  w  .j  av a 2s  . co  m

    String rss = StringPool.BLANK;

    if (companyId > 0) {
        feedURL = StringPool.BLANK;

        rss = BlogsEntryServiceUtil.getCompanyEntriesRSS(companyId, new Date(), status, max, type, version,
                displayStyle, feedURL, entryURL, themeDisplay);
    } else if (groupId > 0) {
        feedURL += "p_l_id=" + plid;

        entryURL = feedURL;

        rss = BlogsEntryServiceUtil.getGroupEntriesRSS(groupId, new Date(), status, max, type, version,
                displayStyle, feedURL, entryURL, themeDisplay);
    } else if (organizationId > 0) {
        feedURL = StringPool.BLANK;

        rss = BlogsEntryServiceUtil.getOrganizationEntriesRSS(organizationId, new Date(), status, max, type,
                version, displayStyle, feedURL, entryURL, themeDisplay);
    } else if (layout != null) {
        groupId = themeDisplay.getScopeGroupId();

        feedURL = PortalUtil.getLayoutFullURL(themeDisplay) + Portal.FRIENDLY_URL_SEPARATOR + "blogs/rss";

        entryURL = feedURL;

        rss = BlogsEntryServiceUtil.getGroupEntriesRSS(groupId, new Date(), status, max, type, version,
                displayStyle, feedURL, entryURL, themeDisplay);
    }

    return rss.getBytes(StringPool.UTF8);
}

From source file:com.liferay.portlet.journal.action.EditFeedAction.java

License:Open Source License

protected void updateFeed(ActionRequest actionRequest) throws Exception {
    String cmd = ParamUtil.getString(actionRequest, Constants.CMD);

    long groupId = ParamUtil.getLong(actionRequest, "groupId");

    String feedId = ParamUtil.getString(actionRequest, "feedId");
    boolean autoFeedId = ParamUtil.getBoolean(actionRequest, "autoFeedId");

    String name = ParamUtil.getString(actionRequest, "name");
    String description = ParamUtil.getString(actionRequest, "description");
    String type = ParamUtil.getString(actionRequest, "type");
    String structureId = ParamUtil.getString(actionRequest, "structureId");
    String templateId = ParamUtil.getString(actionRequest, "templateId");
    String rendererTemplateId = ParamUtil.getString(actionRequest, "rendererTemplateId");
    int delta = ParamUtil.getInteger(actionRequest, "delta");
    String orderByCol = ParamUtil.getString(actionRequest, "orderByCol");
    String orderByType = ParamUtil.getString(actionRequest, "orderByType");
    String targetLayoutFriendlyUrl = ParamUtil.getString(actionRequest, "targetLayoutFriendlyUrl");
    String targetPortletId = ParamUtil.getString(actionRequest, "targetPortletId");
    String contentField = ParamUtil.getString(actionRequest, "contentField");

    String feedType = RSSUtil.TYPE_DEFAULT;
    double feedVersion = RSSUtil.VERSION_DEFAULT;

    String feedTypeAndVersion = ParamUtil.getString(actionRequest, "feedTypeAndVersion");

    if (Validator.isNotNull(feedTypeAndVersion)) {
        String[] parts = feedTypeAndVersion.split(StringPool.COLON);

        try {//from   w w w .  j av  a2s  . com
            feedType = parts[0];
            feedVersion = GetterUtil.getDouble(parts[1]);
        } catch (Exception e) {
        }
    } else {
        feedType = ParamUtil.getString(actionRequest, "feedType", feedType);
        feedVersion = ParamUtil.getDouble(actionRequest, "feedVersion", feedVersion);
    }

    ServiceContext serviceContext = ServiceContextFactory.getInstance(JournalFeed.class.getName(),
            actionRequest);

    if (cmd.equals(Constants.ADD)) {

        // Add feed

        JournalFeedServiceUtil.addFeed(groupId, feedId, autoFeedId, name, description, type, structureId,
                templateId, rendererTemplateId, delta, orderByCol, orderByType, targetLayoutFriendlyUrl,
                targetPortletId, contentField, feedType, feedVersion, serviceContext);
    } else {

        // Update feed

        JournalFeedServiceUtil.updateFeed(groupId, feedId, name, description, type, structureId, templateId,
                rendererTemplateId, delta, orderByCol, orderByType, targetLayoutFriendlyUrl, targetPortletId,
                contentField, feedType, feedVersion, serviceContext);
    }
}

From source file:com.liferay.portlet.journal.action.ViewArticleContentAction.java

License:Open Source License

@Override
public ActionForward execute(ActionMapping mapping, ActionForm form, HttpServletRequest request,
        HttpServletResponse response) throws Exception {

    try {//from www  .j  ava 2  s. com
        String cmd = ParamUtil.getString(request, Constants.CMD);

        ThemeDisplay themeDisplay = (ThemeDisplay) request.getAttribute(WebKeys.THEME_DISPLAY);

        long groupId = ParamUtil.getLong(request, "groupId");
        String articleId = ParamUtil.getString(request, "articleId");
        double version = ParamUtil.getDouble(request, "version", JournalArticleConstants.VERSION_DEFAULT);

        String languageId = LanguageUtil.getLanguageId(request);

        String output = null;

        if (cmd.equals(Constants.PREVIEW)) {
            JournalArticle article = JournalArticleServiceUtil.getArticle(groupId, articleId, version);

            output = JournalArticleLocalServiceUtil.getArticleContent(article, article.getTemplateId(), null,
                    languageId, themeDisplay);
        } else {
            output = JournalArticleServiceUtil.getArticleContent(groupId, articleId, version, languageId,
                    themeDisplay);
        }

        request.setAttribute(WebKeys.JOURNAL_ARTICLE_CONTENT, output);

        if (output.startsWith("<?xml ")) {
            return mapping.findForward("portlet.journal.raw_article_content");
        } else {
            return mapping.findForward("portlet.journal.view_article_content");
        }
    } catch (Exception e) {
        PortalUtil.sendError(e, request, response);

        return null;
    }
}

From source file:com.liferay.portlet.messageboards.action.RSSAction.java

License:Open Source License

protected byte[] getRSS(HttpServletRequest request) throws Exception {
    ThemeDisplay themeDisplay = (ThemeDisplay) request.getAttribute(WebKeys.THEME_DISPLAY);

    String plid = ParamUtil.getString(request, "p_l_id");
    long companyId = ParamUtil.getLong(request, "companyId");
    long groupId = ParamUtil.getLong(request, "groupId");
    long userId = ParamUtil.getLong(request, "userId");
    long categoryId = ParamUtil.getLong(request, "mbCategoryId");
    long threadId = ParamUtil.getLong(request, "threadId");
    int max = ParamUtil.getInteger(request, "max", SearchContainer.DEFAULT_DELTA);
    String type = ParamUtil.getString(request, "type", RSSUtil.TYPE_DEFAULT);
    double version = ParamUtil.getDouble(request, "version", RSSUtil.VERSION_DEFAULT);
    String displayStyle = ParamUtil.getString(request, "displayStyle", RSSUtil.DISPLAY_STYLE_FULL_CONTENT);

    String entryURL = themeDisplay.getPortalURL() + themeDisplay.getPathMain()
            + "/message_boards/find_message?p_l_id=" + plid;

    String rss = StringPool.BLANK;

    if (companyId > 0) {
        String feedURL = StringPool.BLANK;

        rss = MBMessageServiceUtil.getCompanyMessagesRSS(companyId, WorkflowConstants.STATUS_APPROVED, max,
                type, version, displayStyle, feedURL, entryURL, themeDisplay);
    } else if (groupId > 0) {
        String feedURL = themeDisplay.getPortalURL() + themeDisplay.getPathMain()
                + "/message_boards/find_recent_posts?p_l_id=" + plid;

        if (userId > 0) {
            rss = MBMessageServiceUtil.getGroupMessagesRSS(groupId, userId, WorkflowConstants.STATUS_APPROVED,
                    max, type, version, displayStyle, feedURL, entryURL, themeDisplay);
        } else {//w ww  .j  av a2 s  . co  m
            rss = MBMessageServiceUtil.getGroupMessagesRSS(groupId, WorkflowConstants.STATUS_APPROVED, max,
                    type, version, displayStyle, feedURL, entryURL, themeDisplay);
        }
    } else if (categoryId > 0) {
        String feedURL = themeDisplay.getPortalURL() + themeDisplay.getPathMain()
                + "/message_boards/find_category?p_l_id=" + plid + "&mbCategoryId=" + categoryId;

        rss = MBMessageServiceUtil.getCategoryMessagesRSS(groupId, categoryId,
                WorkflowConstants.STATUS_APPROVED, max, type, version, displayStyle, feedURL, entryURL,
                themeDisplay);
    } else if (threadId > 0) {
        String feedURL = themeDisplay.getPortalURL() + themeDisplay.getPathMain()
                + "/message_boards/find_thread?p_l_id=" + plid + "&threadId=" + threadId;

        rss = MBMessageServiceUtil.getThreadMessagesRSS(threadId, WorkflowConstants.STATUS_APPROVED, max, type,
                version, displayStyle, feedURL, entryURL, themeDisplay);
    }

    return rss.getBytes(StringPool.UTF8);
}

From source file:com.liferay.portlet.shopping.action.EditCouponAction.java

License:Open Source License

protected void updateCoupon(ActionRequest actionRequest) throws Exception {
    long couponId = ParamUtil.getLong(actionRequest, "couponId");

    String code = ParamUtil.getString(actionRequest, "code");
    boolean autoCode = ParamUtil.getBoolean(actionRequest, "autoCode");

    String name = ParamUtil.getString(actionRequest, "name");
    String description = ParamUtil.getString(actionRequest, "description");

    int startDateMonth = ParamUtil.getInteger(actionRequest, "startDateMonth");
    int startDateDay = ParamUtil.getInteger(actionRequest, "startDateDay");
    int startDateYear = ParamUtil.getInteger(actionRequest, "startDateYear");
    int startDateHour = ParamUtil.getInteger(actionRequest, "startDateHour");
    int startDateMinute = ParamUtil.getInteger(actionRequest, "startDateMinute");
    int startDateAmPm = ParamUtil.getInteger(actionRequest, "startDateAmPm");

    if (startDateAmPm == Calendar.PM) {
        startDateHour += 12;/*from  www  . java  2s . c  o  m*/
    }

    int endDateMonth = ParamUtil.getInteger(actionRequest, "endDateMonth");
    int endDateDay = ParamUtil.getInteger(actionRequest, "endDateDay");
    int endDateYear = ParamUtil.getInteger(actionRequest, "endDateYear");
    int endDateHour = ParamUtil.getInteger(actionRequest, "endDateHour");
    int endDateMinute = ParamUtil.getInteger(actionRequest, "endDateMinute");
    int endDateAmPm = ParamUtil.getInteger(actionRequest, "endDateAmPm");
    boolean neverExpire = ParamUtil.getBoolean(actionRequest, "neverExpire");

    if (endDateAmPm == Calendar.PM) {
        endDateHour += 12;
    }

    boolean active = ParamUtil.getBoolean(actionRequest, "active");
    String limitCategories = ParamUtil.getString(actionRequest, "limitCategories");
    String limitSkus = ParamUtil.getString(actionRequest, "limitSkus");
    double minOrder = ParamUtil.getDouble(actionRequest, "minOrder", -1.0);
    double discount = ParamUtil.getDouble(actionRequest, "discount", -1.0);
    String discountType = ParamUtil.getString(actionRequest, "discountType");

    ServiceContext serviceContext = ServiceContextFactory.getInstance(ShoppingCoupon.class.getName(),
            actionRequest);

    if (couponId <= 0) {

        // Add coupon

        ShoppingCouponServiceUtil.addCoupon(code, autoCode, name, description, startDateMonth, startDateDay,
                startDateYear, startDateHour, startDateMinute, endDateMonth, endDateDay, endDateYear,
                endDateHour, endDateMinute, neverExpire, active, limitCategories, limitSkus, minOrder, discount,
                discountType, serviceContext);
    } else {

        // Update coupon

        ShoppingCouponServiceUtil.updateCoupon(couponId, name, description, startDateMonth, startDateDay,
                startDateYear, startDateHour, startDateMinute, endDateMonth, endDateDay, endDateYear,
                endDateHour, endDateMinute, neverExpire, active, limitCategories, limitSkus, minOrder, discount,
                discountType, serviceContext);
    }
}

From source file:com.liferay.portlet.wiki.action.RSSAction.java

License:Open Source License

protected byte[] getRSS(HttpServletRequest request) throws Exception {
    ThemeDisplay themeDisplay = (ThemeDisplay) request.getAttribute(WebKeys.THEME_DISPLAY);

    Layout layout = themeDisplay.getLayout();

    long companyId = ParamUtil.getLong(request, "companyId");
    long nodeId = ParamUtil.getLong(request, "nodeId");
    String title = ParamUtil.getString(request, "title");
    int max = ParamUtil.getInteger(request, "max", SearchContainer.DEFAULT_DELTA);
    String type = ParamUtil.getString(request, "type", RSSUtil.TYPE_DEFAULT);
    double version = ParamUtil.getDouble(request, "version", RSSUtil.VERSION_DEFAULT);
    String displayStyle = ParamUtil.getString(request, "displayStyle", RSSUtil.DISPLAY_STYLE_FULL_CONTENT);

    PortletURL feedURL = new PortletURLImpl(request, PortletKeys.WIKI, layout.getPlid(),
            PortletRequest.RENDER_PHASE);

    feedURL.setParameter("nodeId", String.valueOf(nodeId));

    PortletURL entryURL = new PortletURLImpl(request, PortletKeys.WIKI, layout.getPlid(),
            PortletRequest.RENDER_PHASE);

    entryURL.setParameter("nodeId", String.valueOf(nodeId));
    entryURL.setParameter("title", title);

    Locale locale = themeDisplay.getLocale();

    String rss = StringPool.BLANK;

    if ((nodeId > 0) && (Validator.isNotNull(title))) {
        rss = WikiPageServiceUtil.getPagesRSS(companyId, nodeId, title, max, type, version, displayStyle,
                feedURL.toString(), entryURL.toString(), locale);
    } else if (nodeId > 0) {
        rss = WikiPageServiceUtil.getNodePagesRSS(nodeId, max, type, version, displayStyle, feedURL.toString(),
                entryURL.toString());/*  ww w  .  j  av a2  s.c o  m*/
    }

    return rss.getBytes(StringPool.UTF8);
}

From source file:com.liferay.shopping.ShoppingPortlet.java

License:Open Source License

public void updateCoupon(ActionRequest actionRequest, ActionResponse actionResponse) throws Exception {

    try {//from   ww w. j a v a2  s  .  co m
        long couponId = ParamUtil.getLong(actionRequest, "couponId");

        String code = ParamUtil.getString(actionRequest, "code");
        boolean autoCode = ParamUtil.getBoolean(actionRequest, "autoCode");

        String name = ParamUtil.getString(actionRequest, "name");
        String description = ParamUtil.getString(actionRequest, "description");

        int startDateMonth = ParamUtil.getInteger(actionRequest, "startDateMonth");
        int startDateDay = ParamUtil.getInteger(actionRequest, "startDateDay");
        int startDateYear = ParamUtil.getInteger(actionRequest, "startDateYear");
        int startDateHour = ParamUtil.getInteger(actionRequest, "startDateHour");
        int startDateMinute = ParamUtil.getInteger(actionRequest, "startDateMinute");
        int startDateAmPm = ParamUtil.getInteger(actionRequest, "startDateAmPm");

        if (startDateAmPm == Calendar.PM) {
            startDateHour += 12;
        }

        int endDateMonth = ParamUtil.getInteger(actionRequest, "endDateMonth");
        int endDateDay = ParamUtil.getInteger(actionRequest, "endDateDay");
        int endDateYear = ParamUtil.getInteger(actionRequest, "endDateYear");
        int endDateHour = ParamUtil.getInteger(actionRequest, "endDateHour");
        int endDateMinute = ParamUtil.getInteger(actionRequest, "endDateMinute");
        int endDateAmPm = ParamUtil.getInteger(actionRequest, "endDateAmPm");
        boolean neverExpire = ParamUtil.getBoolean(actionRequest, "neverExpire");

        if (endDateAmPm == Calendar.PM) {
            endDateHour += 12;
        }

        boolean active = ParamUtil.getBoolean(actionRequest, "active");
        String limitCategories = ParamUtil.getString(actionRequest, "limitCategories");
        String limitSkus = ParamUtil.getString(actionRequest, "limitSkus");
        double minOrder = ParamUtil.getDouble(actionRequest, "minOrder", -1.0);
        double discount = ParamUtil.getDouble(actionRequest, "discount", -1.0);
        String discountType = ParamUtil.getString(actionRequest, "discountType");

        ServiceContext serviceContext = ServiceContextFactory.getInstance(ShoppingCoupon.class.getName(),
                actionRequest);

        if (couponId <= 0) {

            // Add coupon
            _log.error("AA CouponId: " + couponId);

            ShoppingCouponServiceUtil.addCoupon(code, autoCode, name, description, startDateMonth, startDateDay,
                    startDateYear, startDateHour, startDateMinute, endDateMonth, endDateDay, endDateYear,
                    endDateHour, endDateMinute, neverExpire, active, limitCategories, limitSkus, minOrder,
                    discount, discountType, serviceContext);
        } else {

            // Update coupon
            _log.error("UPDATE CouponId: " + couponId);

            ShoppingCouponServiceUtil.updateCoupon(couponId, name, description, startDateMonth, startDateDay,
                    startDateYear, startDateHour, startDateMinute, endDateMonth, endDateDay, endDateYear,
                    endDateHour, endDateMinute, neverExpire, active, limitCategories, limitSkus, minOrder,
                    discount, discountType, serviceContext);
        }
    } catch (Exception e) {
        if (e instanceof NoSuchCouponException || e instanceof PrincipalException) {

            SessionErrors.add(actionRequest, e.getClass().getName());

            // setForward(actionRequest, "portlet.shopping.error");
            actionResponse.setRenderParameter("jspPage", "/error.jsp");
        } else if (e instanceof CouponCodeException || e instanceof CouponDateException
                || e instanceof CouponDescriptionException || e instanceof CouponDiscountException
                || e instanceof CouponEndDateException || e instanceof CouponLimitCategoriesException
                || e instanceof CouponLimitSKUsException || e instanceof CouponMinimumOrderException
                || e instanceof CouponNameException || e instanceof CouponStartDateException
                || e instanceof DuplicateCouponCodeException) {

            if (e instanceof CouponLimitCategoriesException) {
                CouponLimitCategoriesException clce = (CouponLimitCategoriesException) e;

                SessionErrors.add(actionRequest, e.getClass().getName(), clce.getCategoryIds());
            } else if (e instanceof CouponLimitSKUsException) {
                CouponLimitSKUsException clskue = (CouponLimitSKUsException) e;

                SessionErrors.add(actionRequest, e.getClass().getName(), clskue.getSkus());
            } else {
                SessionErrors.add(actionRequest, e.getClass().getName());
            }
            actionResponse.setRenderParameter("jspPage", "/edit_coupon.jsp");
        } else {
            throw e;
        }
    }

}