Example usage for com.liferay.portal.kernel.servlet SessionMessages add

List of usage examples for com.liferay.portal.kernel.servlet SessionMessages add

Introduction

In this page you can find the example usage for com.liferay.portal.kernel.servlet SessionMessages add.

Prototype

public static void add(PortletRequest portletRequest, String key) 

Source Link

Usage

From source file:org.opencps.dossiermgt.portlet.DossierStateMenuPortlet.java

License:Open Source License

private void ajaxReturn(ActionRequest actionRequest, ActionResponse actionResponse, Map<String, String> par) {
    try {/*from  w  w  w . jav a  2s  . co  m*/

        HttpServletResponse httpResponse = PortalUtil.getHttpServletResponse(actionResponse);

        httpResponse.setContentType("text");

        JSONObject payloadJSON = JSONFactoryUtil.createJSONObject();

        for (Map.Entry<String, String> entry : par.entrySet()) {

            payloadJSON.put(entry.getKey(), HtmlUtil.escape(entry.getValue()));

        }

        httpResponse.getWriter().print(payloadJSON.toString());
        httpResponse.flushBuffer();

        SessionMessages.add(actionRequest,
                PortalUtil.getPortletId(actionRequest) + SessionMessages.KEY_SUFFIX_HIDE_DEFAULT_ERROR_MESSAGE);
        SessionMessages.add(actionRequest, PortalUtil.getPortletId(actionRequest)
                + SessionMessages.KEY_SUFFIX_HIDE_DEFAULT_SUCCESS_MESSAGE);

    } catch (Exception e) {
        // TODO Auto-generated catch block
        e.printStackTrace();
    }
}

From source file:org.opencps.holidayconfig.portlet.HolidayConfigPortlet.java

License:Open Source License

public void updateHoliday(ActionRequest actionRequest, ActionResponse actionResponse) throws IOException {

    long holidayId = ParamUtil.getLong(actionRequest, HolidayConfigDisplayTerms.HOLIDAY_ID, 0L);

    Date holidayDate = ParamUtil.getDate(actionRequest, HolidayConfigDisplayTerms.HOLIDAY_DATE,
            DateTimeUtil.getDateTimeFormat(DateTimeUtil._VN_DATE_FORMAT));

    String description = ParamUtil.getString(actionRequest, HolidayConfigDisplayTerms.DESCRIPTION);

    int status = ParamUtil.getInteger(actionRequest, HolidayConfigDisplayTerms.HOLIDAY_STATUS, 0);

    String redirectURL = ParamUtil.getString(actionRequest, WebKeys.REDIRECT_URL);
    String returnURL = ParamUtil.getString(actionRequest, WebKeys.RETURN_URL);
    try {//ww w  .j  a v  a2  s  . c  o  m

        ServiceContext serviceContext = ServiceContextFactory.getInstance(actionRequest);

        if (holidayId == 0) {

            HolidayConfigLocalServiceUtil.addHoliday(holidayDate, description, status, serviceContext);

            SessionMessages.add(actionRequest, MessageKeys.HOLIDAYCONFIG_ADD_SUCESS);
        } else {
            HolidayConfigLocalServiceUtil.updateHoliday(holidayId, holidayDate, description, status);

            SessionMessages.add(actionRequest, MessageKeys.HOLIDAYCONFIG_UPDATE_SUCESS);
        }
    } catch (Exception e) {

        SessionErrors.add(actionRequest, MessageKeys.HOLIDAYCONFIG_SYSTEM_EXCEPTION_OCCURRED);

        redirectURL = returnURL;

    } finally {
        if (Validator.isNotNull(redirectURL)) {
            actionResponse.sendRedirect(redirectURL);
        }
    }
}

From source file:org.opencps.notificationmgt.portlet.ConfigurationImpl.java

License:Open Source License

@Override
public void processAction(PortletConfig portletConfig, ActionRequest actionRequest,
        ActionResponse actionResponse) throws Exception {

    long rootGroupId = ParamUtil.getLong(actionRequest, PortletKeys.PREFER__ROOTGROUPID__);

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

    PortletPreferences preferences = PortletPreferencesFactoryUtil.getPortletSetup(actionRequest,
            portletResource);//from  w  ww  . jav a 2  s.  c o  m

    preferences.setValue(PortletKeys.PREFER__ROOTGROUPID__, String.valueOf(rootGroupId));

    preferences.store();

    SessionMessages.add(actionRequest, "potlet-config-saved");

}

From source file:org.opencps.notificationmgt.portlet.NotificationPortlet.java

License:Open Source License

public void updateNotificationStatusConfig(ActionRequest actionRequest, ActionResponse actionResponse)
        throws IOException, WindowStateException {

    long notificationConfigId = ParamUtil.getLong(actionRequest,
            NotificationStatusConfigDisplayTerms.NOTICE_CONFIG_ID);
    String dossierNextStatus = ParamUtil.getString(actionRequest,
            NotificationStatusConfigDisplayTerms.DOSSIER_NEXT_STATUS);
    boolean isSendNotification = ParamUtil.getBoolean(actionRequest,
            NotificationStatusConfigDisplayTerms.IS_SEND_NOTIFICATION, false);

    String currentURL = ParamUtil.getString(actionRequest, WebKeys.CURRENT_URL);

    String backURL = ParamUtil.getString(actionRequest, WebKeys.BACK_URL);

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

    NotificationStatusConfig notificationConfig = null;

    try {/*from  www  .jav  a2 s.c  o  m*/

        try {
            notificationConfig = NotificationStatusConfigLocalServiceUtil
                    .fetchNotificationStatusConfig(notificationConfigId);

            notificationConfig = NotificationStatusConfigLocalServiceUtil
                    .getByDossierNextStatus(dossierNextStatus);
        } catch (SystemException e) {

        }

        if (Validator.isNull(notificationConfig)) {

            notificationConfig = NotificationStatusConfigLocalServiceUtil.createNotificationStatusConfig(
                    CounterLocalServiceUtil.increment(NotificationStatusConfig.class.getName()));

            notificationConfig.setCompanyId(themeDisplay.getCompanyId());
            notificationConfig.setGroupId(themeDisplay.getScopeGroupId());
            notificationConfig.setUserId(themeDisplay.getUserId());
            notificationConfig.setCreateDate(new Date());
            notificationConfig.setModifiedDate(new Date());

            notificationConfig.setDossierNextStatus(dossierNextStatus);
            notificationConfig.setIsSendNotification(isSendNotification);

            NotificationStatusConfigLocalServiceUtil.addNotificationStatusConfig(notificationConfig);
            SessionMessages.add(actionRequest, MessageKeys.NOTIFICATION_STATUS_ADD_SUCESS);

        } else {

            notificationConfig.setCompanyId(themeDisplay.getCompanyId());
            notificationConfig.setGroupId(themeDisplay.getScopeGroupId());
            notificationConfig.setUserId(themeDisplay.getUserId());
            notificationConfig.setModifiedDate(new Date());

            notificationConfig.setDossierNextStatus(dossierNextStatus);
            notificationConfig.setIsSendNotification(isSendNotification);

            NotificationStatusConfigLocalServiceUtil.updateNotificationStatusConfig(notificationConfig);

            SessionMessages.add(actionRequest, MessageKeys.NOTIFICATION_STATUS_UPDATE_SUCESS);

        }

    } catch (Exception e) {
        _log.error(e);
        SessionMessages.add(actionRequest, MessageKeys.NOTIFICATION_STATUS_SYSTEM_EXCEPTION_OCCURRED);
    } finally {

        PortletURL redirectURL = PortletURLFactoryUtil.create(PortalUtil.getHttpServletRequest(actionRequest),
                (String) actionRequest.getAttribute(WebKeys.PORTLET_ID), themeDisplay.getLayout().getPlid(),
                PortletRequest.RENDER_PHASE);
        redirectURL.setParameter(NotificationStatusConfigDisplayTerms.NOTICE_CONFIG_ID,
                String.valueOf(notificationConfig.getNotiStatusConfigId()));
        WindowState state = WindowStateFactory.getWindowState(LiferayWindowState.POP_UP.toString());
        redirectURL.setWindowState(state);

        redirectURL.setParameter("mvcPath",
                "/html/portlets/notificationmgt/backoffice/status/notification_status_config_edit.jsp");
        actionResponse.sendRedirect(redirectURL.toString());

    }

}

From source file:org.opencps.notificationmgt.portlet.NotificationPortlet.java

License:Open Source License

public void changeNotificationStatusConfig(ActionRequest actionRequest, ActionResponse actionResponse)
        throws IOException {

    long notificationConfigId = ParamUtil.getLong(actionRequest,
            NotificationStatusConfigDisplayTerms.NOTICE_CONFIG_ID);

    boolean isSendNotification = ParamUtil.getBoolean(actionRequest,
            NotificationStatusConfigDisplayTerms.IS_SEND_NOTIFICATION, false);

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

    NotificationStatusConfig notificationConfig = null;

    try {//from   w  ww .ja v  a2  s  .c  o  m

        try {
            notificationConfig = NotificationStatusConfigLocalServiceUtil
                    .fetchNotificationStatusConfig(notificationConfigId);

        } catch (SystemException e) {

        }

        if (Validator.isNotNull(notificationConfig)) {

            notificationConfig.setCompanyId(themeDisplay.getCompanyId());
            notificationConfig.setGroupId(themeDisplay.getScopeGroupId());
            notificationConfig.setUserId(themeDisplay.getUserId());
            notificationConfig.setModifiedDate(new Date());

            notificationConfig.setIsSendNotification(isSendNotification);

            NotificationStatusConfigLocalServiceUtil.updateNotificationStatusConfig(notificationConfig);

            SessionMessages.add(actionRequest, MessageKeys.NOTIFICATION_STATUS_UPDATE_SUCESS);

        }

    } catch (Exception e) {
        _log.error(e);
        SessionMessages.add(actionRequest, MessageKeys.NOTIFICATION_STATUS_SYSTEM_EXCEPTION_OCCURRED);
    }

}

From source file:org.opencps.notificationmgt.portlet.NotificationPortlet.java

License:Open Source License

public void changeNotiEventConfig(ActionRequest actionRequest, ActionResponse actionResponse)
        throws IOException {

    long notiEventConfigId = ParamUtil.getLong(actionRequest,
            NotificationEventConfigDisplayTerms.NOTICE_EVENT_CONFIG_ID);

    boolean active = ParamUtil.getBoolean(actionRequest, NotificationEventConfigDisplayTerms.ACTIVE, false);

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

    NotificationEventConfig notiEventConfig = null;

    try {/*from   ww  w.  j  av a 2 s. c o  m*/

        try {
            notiEventConfig = NotificationEventConfigLocalServiceUtil
                    .fetchNotificationEventConfig(notiEventConfigId);

        } catch (SystemException e) {

        }

        if (Validator.isNotNull(notiEventConfig)) {

            notiEventConfig.setCompanyId(themeDisplay.getCompanyId());
            notiEventConfig.setGroupId(themeDisplay.getScopeGroupId());
            notiEventConfig.setUserId(themeDisplay.getUserId());
            notiEventConfig.setModifiedDate(new Date());

            notiEventConfig.setActive(active);

            NotificationEventConfigLocalServiceUtil.updateNotificationEventConfig(notiEventConfig);

            SessionMessages.add(actionRequest, MessageKeys.NOTIFICATION_EVENT_UPDATE_SUCESS);

        }

    } catch (Exception e) {
        _log.error(e);
        SessionMessages.add(actionRequest, MessageKeys.NOTIFICATION_EVENT_SYSTEM_EXCEPTION_OCCURRED);
    }

}

From source file:org.opencps.notificationmgt.portlet.NotificationPortlet.java

License:Open Source License

public void updateNotificationEventConfig(ActionRequest actionRequest, ActionResponse actionResponse)
        throws IOException, WindowStateException {

    long notiEventConfigId = ParamUtil.getLong(actionRequest,
            NotificationEventConfigDisplayTerms.NOTICE_EVENT_CONFIG_ID);

    long notiStatusConfigId = ParamUtil.getLong(actionRequest,
            NotificationStatusConfigDisplayTerms.NOTICE_CONFIG_ID);

    boolean active = ParamUtil.getBoolean(actionRequest, NotificationEventConfigDisplayTerms.ACTIVE, false);

    String eventName = ParamUtil.getString(actionRequest, NotificationEventConfigDisplayTerms.EVENT_NAME);
    String description = ParamUtil.getString(actionRequest, NotificationEventConfigDisplayTerms.DESCRIPTION);
    String pattern = ParamUtil.getString(actionRequest, NotificationEventConfigDisplayTerms.PATTERN);

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

    NotificationEventConfig notiEventConfig = null;

    try {/*  w w w  .ja  va  2s  .  c o m*/

        try {
            notiEventConfig = NotificationEventConfigLocalServiceUtil
                    .fetchNotificationEventConfig(notiEventConfigId);

        } catch (SystemException e) {

        }

        if (Validator.isNotNull(notiEventConfig)) {

            notiEventConfig.setCompanyId(themeDisplay.getCompanyId());
            notiEventConfig.setGroupId(themeDisplay.getScopeGroupId());
            notiEventConfig.setUserId(themeDisplay.getUserId());
            notiEventConfig.setModifiedDate(new Date());

            notiEventConfig.setNotiStatusConfigId(notiStatusConfigId);
            notiEventConfig.setEventName(eventName);
            notiEventConfig.setDescription(description);
            notiEventConfig.setActive(active);
            notiEventConfig.setPattern(pattern);

            NotificationEventConfigLocalServiceUtil.updateNotificationEventConfig(notiEventConfig);

            SessionMessages.add(actionRequest, MessageKeys.NOTIFICATION_EVENT_UPDATE_SUCESS);

        } else {

            notiEventConfig = NotificationEventConfigLocalServiceUtil.createNotificationEventConfig(
                    CounterLocalServiceUtil.increment(NotificationEventConfig.class.getName()));

            notiEventConfig.setCompanyId(themeDisplay.getCompanyId());
            notiEventConfig.setGroupId(themeDisplay.getScopeGroupId());
            notiEventConfig.setUserId(themeDisplay.getUserId());
            notiEventConfig.setCreateDate(new Date());
            notiEventConfig.setModifiedDate(new Date());

            notiEventConfig.setNotiStatusConfigId(notiStatusConfigId);
            notiEventConfig.setEventName(eventName);
            notiEventConfig.setDescription(description);
            notiEventConfig.setActive(active);
            notiEventConfig.setPattern(pattern);

            NotificationEventConfigLocalServiceUtil.addNotificationEventConfig(notiEventConfig);

            SessionMessages.add(actionRequest, MessageKeys.NOTIFICATION_EVENT_ADD_SUCESS);
        }
    } catch (Exception e) {
        _log.error(e);
    } finally {

        PortletURL redirectURL = PortletURLFactoryUtil.create(PortalUtil.getHttpServletRequest(actionRequest),
                (String) actionRequest.getAttribute(WebKeys.PORTLET_ID), themeDisplay.getLayout().getPlid(),
                PortletRequest.RENDER_PHASE);
        redirectURL.setParameter(NotificationEventConfigDisplayTerms.NOTICE_EVENT_CONFIG_ID,
                String.valueOf(notiEventConfig.getNotiEventConfigId()));
        WindowState state = WindowStateFactory.getWindowState(LiferayWindowState.POP_UP.toString());
        redirectURL.setWindowState(state);

        redirectURL.setParameter("mvcPath",
                "/html/portlets/notificationmgt/backoffice/event/notification_event_config_edit.jsp");
        actionResponse.sendRedirect(redirectURL.toString());

    }

}

From source file:org.opencps.paymentmgt.portlet.ConfigurationImpl.java

License:Open Source License

@Override
public void processAction(PortletConfig portletConfig, ActionRequest actionRequest,
        ActionResponse actionResponse) throws Exception {

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

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

    PortletPreferences preferences = PortletPreferencesFactoryUtil.getPortletSetup(actionRequest,
            portletResource);/*w  w  w  .  j  a  v a2  s  .  c o  m*/

    preferences.setValue("itemsToDisplay", String.valueOf(itemsToDisplay));
    preferences.store();

    SessionMessages.add(actionRequest, "potlet-config-saved");

}

From source file:org.opencps.paymentmgt.portlet.PaymentMgtBackOfficePortlet.java

License:Open Source License

/**
 * @param actionRequest/*from ww  w .j a  va 2 s . co m*/
 * 
 * @param actionResponse
 * @throws IOException
 */
public void confirmPaymentRequested(ActionRequest actionRequest, ActionResponse actionResponse)
        throws IOException {
    long paymentFileId = ParamUtil.getLong(actionRequest, PaymentFileDisplayTerms.PAYMENT_FILE_ID);
    int confirmHopLe = ParamUtil.getInteger(actionRequest, "confirmHopLeHidden", 0);
    String lyDo = "";
    if (confirmHopLe == 0) {
        lyDo = ParamUtil.getString(actionRequest, "lyDo");
    }
    PaymentFile paymentFile = null;
    try {
        paymentFile = PaymentFileLocalServiceUtil.getPaymentFile(paymentFileId);
        if (paymentFile != null) {
            if (confirmHopLe == 1) {
                paymentFile.setPaymentStatus(PaymentMgtUtil.PAYMENT_STATUS_APPROVED);
            } else if (confirmHopLe == 0) {
                paymentFile.setPaymentStatus(PaymentMgtUtil.PAYMENT_STATUS_REJECTED);
                paymentFile.setApproveNote(lyDo);
            }
            PaymentFileLocalServiceUtil.updatePaymentFile(paymentFile);
            SessionMessages.add(actionRequest, MessageKeys.PAYMENT_FILE_CONFIRM_BANK_SUCCESS);
        }

    } catch (NoSuchPaymentFileException e) {
        SessionErrors.add(actionRequest, MessageKeys.PAYMENT_FILE_CONFIRM_BANK_ERROR);
    } catch (SystemException e) {
        SessionErrors.add(actionRequest, MessageKeys.PAYMENT_FILE_CONFIRM_BANK_ERROR);

    } catch (PortalException e) {
        SessionErrors.add(actionRequest, MessageKeys.PAYMENT_FILE_CONFIRM_BANK_ERROR);

    }

}

From source file:org.opencps.paymentmgt.portlet.PaymentMgtBackOfficePortlet.java

License:Open Source License

/**
 * @param actionRequest//from www .  j  a  v  a  2 s .co m
 * @param actionResponse
 */
public void updateConfirmPayment(ActionRequest actionRequest, ActionResponse actionResponse) {

    long paymentFileId = ParamUtil.getLong(actionRequest, "paymentFileId");
    PaymentFile paymentFile = null;
    try {
        paymentFile = PaymentFileLocalServiceUtil.getPaymentFile(paymentFileId);
        paymentFile.setPaymentStatus(PaymentMgtUtil.PAYMENT_STATUS_CONFIRMED);
        paymentFile.setPaymentMethod(PaymentMgtUtil.PAYMENT_METHOD_BANK);
        PaymentFileLocalServiceUtil.updatePaymentFile(paymentFile);
        addProcessActionSuccessMessage = false;
        SessionMessages.add(actionRequest, "confirm-payment-cash-success");
    } catch (PortalException e) {
        SessionErrors.add(actionRequest, "confirm-payment-cash-error");
    } catch (SystemException e) {
        SessionErrors.add(actionRequest, "confirm-payment-cash-error");
    }

}