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.oep.cmon.portlet.document.business.ThuTucHanhChinhBusiness.java

License:Apache License

public void addFileUpload(ActionRequest resourceRequest, ActionResponse actionResponse) {
    UploadPortletRequest uploadRequest = PortalUtil.getUploadPortletRequest(resourceRequest);
    IDocumentStorage iDocumentStorage = new DocumentStorageImpl();

    VanBanHuongDan vbbm = null;//  ww  w.ja v  a2s .  c  o m
    InputStream inputStream = null;
    String tenTaiLieu = uploadRequest.getParameter("tenTaiLieu");

    String mota = uploadRequest.getParameter("motaTaiLieu");
    String loaiTaiLieuId = uploadRequest.getParameter("loaiTaiLieuId");
    String tthcId = uploadRequest.getParameter("tthcId");
    File fileUpload = uploadRequest.getFile("taiLieuDinhKem");
    String sourceFileName = uploadRequest.getFileName("taiLieuDinhKem");

    if (validationTaiLieuUploadInput(tenTaiLieu, fileUpload, FormatUtil.convertToLong(tthcId),
            FormatUtil.convertToLong(loaiTaiLieuId), resourceRequest)) {
        try {
            inputStream = new FileInputStream(fileUpload);
            if (inputStream != null) {
                BufferedInputStream byteArrayInputStream = new BufferedInputStream(inputStream);
                ByteArrayOutputStream byteArrayOutputStream = new ByteArrayOutputStream();
                int data = byteArrayInputStream.read();
                while (data != -1) {
                    byteArrayOutputStream.write(data);
                    data = byteArrayInputStream.read();
                }
                //String tthcCode=ThuTucHanhChinhLocalServiceUtil.fetchThuTucHanhChinh(FormatUtil.convertToLong(tthcId)).getMa();
                ResultUpload upload = iDocumentStorage.uploadCauHinhTTHC(FormatUtil.convertToLong(tthcId),
                        PortalUtil.getUser(resourceRequest).getUserId(), byteArrayOutputStream.toByteArray(),
                        sourceFileName);
                if (upload.getCode().compareTo(Constants.UPLOAD_OK) == 0 && upload != null) {
                    //listResult.add(upload);
                    vbbm = new VanBanHuongDanClp();
                    vbbm.setId(CounterLocalServiceUtil.increment(VanBanHuongDan.class.getName()));
                    vbbm.setThuTucHanhChinhId(FormatUtil.convertToLong(tthcId));
                    //vbbm.setTenTaiLieu(uploadRequest.getFileName(tenFileUpload));   
                    vbbm.setTenTaiLieu(tenTaiLieu);
                    vbbm.setNoiLuuTruId(upload.getFileId());
                    //fileUpload.setTenFileUpload(uploadRequest.getParameter(tenFileUpload.replace("taiLieuDinhKem", "tenLieuDinhKem")));
                    vbbm.setMoTa(mota);
                    vbbm.setDaXoa(DocumentConstants.ACTIVE);
                    vbbm.setLoaiTaiLieu(FormatUtil.convertToLong(loaiTaiLieuId));

                    vbbm.setNgaySua(new Date());
                    vbbm.setNgayTao(new Date());
                    vbbm.setNguoiSua(PortalUtil.getUser(resourceRequest).getEmailAddress());
                    vbbm.setNguoiTao(PortalUtil.getUser(resourceRequest).getEmailAddress());

                    try {
                        VanBanHuongDanLocalServiceUtil.addVanBanHuongDan(vbbm);
                        resourceRequest.setAttribute("update_success", "update_success");
                        SessionMessages.add(resourceRequest, "successUpdateHDVB");

                    } catch (Exception es) {
                        es.printStackTrace();
                    } finally {
                        try {
                            if (byteArrayInputStream != null) {
                                byteArrayInputStream.close();
                            }
                            if (byteArrayOutputStream != null) {
                                byteArrayOutputStream.close();
                            }
                            if (inputStream != null) {
                                inputStream.close();
                            }
                        } catch (IOException e) {
                            e.printStackTrace();
                        }
                    }
                }
                //upload if error 
                else {
                    SessionErrors.add(resourceRequest, "errorUpLoadHDVB");
                }

            }

        } catch (Exception es) {
            es.printStackTrace();
            SessionErrors.add(resourceRequest, "errorUpdateHDVB");
        }
    }
    resourceRequest.setAttribute("action", "save");
    actionResponse.setRenderParameter("tthcId", uploadRequest.getParameter("tthcId"));
    actionResponse.setRenderParameter("tthcID", tthcId);
    resourceRequest.getPortletSession().setAttribute("tthcID", tthcId);
    actionResponse.setRenderParameter("loaiTaiLieuId", uploadRequest.getParameter("loaiTaiLieuId"));
    resourceRequest.getPortletSession().setAttribute("loaiTaiLieuId", loaiTaiLieuId);
    //actionResponse.setRenderParameter("jspPage", "/html/portlet/document/setting/popup_tai_lieu.jsp");
    actionResponse.setRenderParameter("jspPage",
            "/html/portlet/document/setting/cau_hinh_huong_dan_bieu_mau.jsp");

}

From source file:org.oep.cmon.portlet.hosochungthuc.Configuration.java

License:Apache License

/**
 * This is function processAction/*from  w  w  w . j ava 2 s  . c  o m*/
 * Version: 1.0
 *  
 * History: 
 *   DATE        AUTHOR      DESCRIPTION 
 *  ------------------------------------------------- 
 *  3-March-2013  Nam Dinh    Create new
 * @param portletConfig
 * @param actionRequest
 * @param actionResponse
 * @throws Exception
 */
@Override
public void processAction(PortletConfig portletConfig, ActionRequest actionRequest,
        ActionResponse actionResponse) throws Exception {
    String cmd = ParamUtil.getString(actionRequest, com.liferay.portal.kernel.util.Constants.CMD);
    if (!cmd.equals(com.liferay.portal.kernel.util.Constants.UPDATE)) {
        return;
    }

    String portletResource = ParamUtil.getString(actionRequest, "portletResource");
    PortletPreferences prefs = PortletPreferencesFactoryUtil.getPortletSetup(actionRequest, portletResource);

    String quiTrinh = ParamUtil.getString(actionRequest, org.oep.cmon.Constants.QuiTrinh.QUITRINH_PARAMS);
    prefs.setValue(org.oep.cmon.Constants.QuiTrinh.QUITRINH_PARAMS, quiTrinh);

    prefs.store();
    // PortletSession portletSession = actionRequest.getPortletSession();
    SessionMessages.add(actionRequest, portletConfig.getPortletName() + ".doConfigure");
}

From source file:org.oep.cmon.portlet.ipmslist.action.Configuration.java

License:Apache License

/**
 * This is function processAction//from   ww w  . j  a va2  s.co m
 * Version: 1.0
 *  
 * History: 
 *   DATE        AUTHOR      DESCRIPTION 
 *  ------------------------------------------------- 
 *  3-March-2013  Nam Dinh    Create new
 * @param portletConfig
 * @param actionRequest
 * @param actionResponse
 * @throws Exception
 */
@Override
public void processAction(PortletConfig portletConfig, ActionRequest actionRequest,
        ActionResponse actionResponse) throws Exception {
    String cmd = ParamUtil.getString(actionRequest, com.liferay.portal.kernel.util.Constants.CMD);
    if (!cmd.equals(com.liferay.portal.kernel.util.Constants.UPDATE)) {
        return;
    }
    String portletResource = ParamUtil.getString(actionRequest, "portletResource");
    PortletPreferences prefs = PortletPreferencesFactoryUtil.getPortletSetup(actionRequest, portletResource);
    List<DanhMucUngDung> ungDungs = DanhMucUngDungLocalServiceUtil.getDSUngDung(Constants.ACTIVATED);
    if (ungDungs != null) {
        for (int i = 0; i < ungDungs.size(); i++) {
            DanhMucUngDung instance = (DanhMucUngDung) ungDungs.get(i);
            String maUngDung = instance.getMa().trim().toLowerCase();
            String paramName = maUngDung + "Name";
            String paramId = maUngDung + "Id";
            String portletId = ParamUtil.getString(actionRequest, paramId);
            String portletName = ParamUtil.getString(actionRequest, paramName);

            prefs.setValue(paramId, portletId);
            prefs.setValue(paramName, portletName);
        }
    }
    //Doi voi Can bo xu ly
    String PrefParamName = org.oep.cmon.Constants.XuLyHoSo.PROCESSING_PROFILE_PREF_PARAM;
    String PrefParamValue = ParamUtil.getString(actionRequest, PrefParamName);

    prefs.setValue(PrefParamName, PrefParamValue);

    //Doi voi Vai tro xu ly
    String vaiTroParamName = org.oep.cmon.Constants.CanBoXuLy.PROCESSING_CAN_BO_PREF_PARAM;
    String vaiTroParamValue = ParamUtil.getString(actionRequest, vaiTroParamName);

    prefs.setValue(vaiTroParamName, vaiTroParamValue);

    // Save status hoso
    String statusPreParam = org.oep.cmon.Constants.QuanLiHoSo.HSTTHCC_CURRENT_STATUS_PREF_PARAM;
    String statusPreParamValue = ParamUtil.getString(actionRequest, statusPreParam);
    prefs.setValue(statusPreParam, statusPreParamValue);

    // yeu cau rut ho so
    prefs.setValue(org.oep.cmon.Constants.QuanLiHoSo.YEU_CAU_RUT,
            ParamUtil.getString(actionRequest, "yeucaurut"));

    prefs.store();
    // PortletSession portletSession = actionRequest.getPortletSession();
    SessionMessages.add(actionRequest, portletConfig.getPortletName() + ".doConfigure");
}

From source file:org.oep.cmon.portlet.ipmslist.action.IPMSListPortlet.java

License:Apache License

/**
 * This is function uploadLoadFileKetQua
 * Version: 1.0/*ww w  . j  ava  2 s.  c o m*/
 *  
 * History: 
 *   DATE        AUTHOR      DESCRIPTION 
 *  ------------------------------------------------- 
 *  3-March-2013  Nam Dinh    Create new
 * @param resourceRequest
 * @param httpReq
 * @throws NumberFormatException
 * @throws Exception
 */
public void uploadLoadFileKetQua(ActionRequest resourceRequest, ActionResponse httpReq)
        throws NumberFormatException, Exception {

    FormOfflineBusiness formOfflineBusiness = new FormOfflineBusiness();
    formOfflineBusiness.uploadLoadFileKetQua(resourceRequest, httpReq);
    PortletConfig portletConfig = (PortletConfig) resourceRequest
            .getAttribute(JavaConstants.JAVAX_PORTLET_CONFIG);
    SessionMessages.add(resourceRequest,
            portletConfig.getPortletName() + SessionMessages.KEY_SUFFIX_HIDE_DEFAULT_ERROR_MESSAGE);
}

From source file:org.oep.cmon.portlet.ipmslist.action.IPMSListPortlet.java

License:Apache License

/**
 * This is function uploadLoadFileKetQuaDoanhNghiep
 * Version: 1.0/*  w  w w  .j  a va2s.c  o m*/
 *  
 * History: 
 *   DATE        AUTHOR      DESCRIPTION 
 *  ------------------------------------------------- 
 *  3-March-2013  Nam Dinh    Create new
 * @param resourceRequest
 * @param httpReq
 * @throws NumberFormatException
 * @throws Exception
 */
public void uploadLoadFileKetQuaDoanhNghiep(ActionRequest resourceRequest, ActionResponse httpReq)
        throws NumberFormatException, Exception {

    FormOfflineBusiness formOfflineBusiness = new FormOfflineBusiness();
    formOfflineBusiness.uploadLoadFileKetQuaDoanhNghiep(resourceRequest, httpReq);
    PortletConfig portletConfig = (PortletConfig) resourceRequest
            .getAttribute(JavaConstants.JAVAX_PORTLET_CONFIG);
    SessionMessages.add(resourceRequest,
            portletConfig.getPortletName() + SessionMessages.KEY_SUFFIX_HIDE_DEFAULT_ERROR_MESSAGE);
}

From source file:org.oep.cmon.portlet.ipmslist.action.IPMSListPortlet.java

License:Apache License

/**
 * This is function doiChieuHoSoRequest//  w  w  w  .j a  v a2 s. co  m
 * Version: 1.0
 *  
 * History: 
 *   DATE        AUTHOR      DESCRIPTION 
 *  ------------------------------------------------- 
 *  3-March-2013  Nam Dinh    Create new
 * @param resourceRequest
 * @param httpReq
 * @throws NumberFormatException
 * @throws Exception
 */
public void doiChieuHoSoRequest(ActionRequest resourceRequest, ActionResponse httpReq)
        throws NumberFormatException, Exception {

    FormOfflineBusiness formOfflineBusiness = new FormOfflineBusiness();
    formOfflineBusiness.doiChieuHoSoRequest(resourceRequest, httpReq);
    PortletConfig portletConfig = (PortletConfig) resourceRequest
            .getAttribute(JavaConstants.JAVAX_PORTLET_CONFIG);
    SessionMessages.add(resourceRequest,
            portletConfig.getPortletName() + SessionMessages.KEY_SUFFIX_HIDE_DEFAULT_ERROR_MESSAGE);
}

From source file:org.oep.cmon.portlet.ipmslist.action.IPMSListPortlet.java

License:Apache License

/**
 * This is function doiChieuHoSoDoanhNghiepRequest
 * Version: 1.0//from ww w.  j  a v  a  2s.c om
 *  
 * History: 
 *   DATE        AUTHOR      DESCRIPTION 
 *  ------------------------------------------------- 
 *  3-March-2013  Nam Dinh    Create new
 * @param resourceRequest
 * @param httpReq
 * @throws NumberFormatException
 * @throws Exception
 */
public void doiChieuHoSoDoanhNghiepRequest(ActionRequest resourceRequest, ActionResponse httpReq)
        throws NumberFormatException, Exception {

    FormOfflineBusiness formOfflineBusiness = new FormOfflineBusiness();
    formOfflineBusiness.doiChieuHoSoDoanhNghiepRequest(resourceRequest, httpReq);
    PortletConfig portletConfig = (PortletConfig) resourceRequest
            .getAttribute(JavaConstants.JAVAX_PORTLET_CONFIG);
    SessionMessages.add(resourceRequest,
            portletConfig.getPortletName() + SessionMessages.KEY_SUFFIX_HIDE_DEFAULT_ERROR_MESSAGE);
}

From source file:org.oep.cmon.portlet.ipmslist.action.IPMSListPortlet.java

License:Apache License

/**
 * This is function addTaiLieuUpload//from  w w w  . j  a  v  a  2s .  c  om
 * Version: 1.0
 *  
 * History: 
 *   DATE        AUTHOR      DESCRIPTION 
 *  ------------------------------------------------- 
 *  3-March-2013  Nam Dinh    Create new
 * @param resourceRequest
 * @param httpReq
 * @throws NumberFormatException
 * @throws Exception
 */
public void addTaiLieuUpload(ActionRequest resourceRequest, ActionResponse httpReq)
        throws NumberFormatException, Exception {

    FormOfflineBusiness formOfflineBusiness = new FormOfflineBusiness();
    formOfflineBusiness.addFileUpload(resourceRequest, httpReq);
    PortletConfig portletConfig = (PortletConfig) resourceRequest
            .getAttribute(JavaConstants.JAVAX_PORTLET_CONFIG);
    SessionMessages.add(resourceRequest,
            portletConfig.getPortletName() + SessionMessages.KEY_SUFFIX_HIDE_DEFAULT_ERROR_MESSAGE);
}

From source file:org.oep.cmon.portlet.ipmslist.action.IPMSListPortlet.java

License:Apache License

/**
 * This is function addTaiLieuDoanhNghiepUpload
 * Version: 1.0/*from   ww  w  .  ja va 2s  .  c  o  m*/
 *  
 * History: 
 *   DATE        AUTHOR      DESCRIPTION 
 *  ------------------------------------------------- 
 *  3-March-2013  Nam Dinh    Create new
 * @param resourceRequest
 * @param httpReq
 * @throws NumberFormatException
 * @throws Exception
 */
public void addTaiLieuDoanhNghiepUpload(ActionRequest resourceRequest, ActionResponse httpReq)
        throws NumberFormatException, Exception {

    FormOfflineBusiness formOfflineBusiness = new FormOfflineBusiness();
    formOfflineBusiness.addFileDoanhNghiepUpload(resourceRequest, httpReq);
    PortletConfig portletConfig = (PortletConfig) resourceRequest
            .getAttribute(JavaConstants.JAVAX_PORTLET_CONFIG);
    SessionMessages.add(resourceRequest,
            portletConfig.getPortletName() + SessionMessages.KEY_SUFFIX_HIDE_DEFAULT_ERROR_MESSAGE);
}

From source file:org.oep.cmon.portlet.ipmslist.action.IPMSListPortlet.java

License:Apache License

/**
 * This is function traHoSoDoanhNghiepRequest
 * Version: 1.0/* w  ww  . ja v  a  2s . c o m*/
 *  
 * History: 
 *   DATE        AUTHOR      DESCRIPTION 
 *  ------------------------------------------------- 
 *  3-March-2013  Nam Dinh    Create new
 * @param resourceRequest
 * @param httpReq
 * @throws NumberFormatException
 * @throws Exception
 */
public void traHoSoDoanhNghiepRequest(ActionRequest resourceRequest, ActionResponse httpReq)
        throws NumberFormatException, Exception {

    FormOfflineBusiness formOfflineBusiness = new FormOfflineBusiness();
    formOfflineBusiness.traHoSoDoanhNghiepRequest(resourceRequest, httpReq);
    PortletConfig portletConfig = (PortletConfig) resourceRequest
            .getAttribute(JavaConstants.JAVAX_PORTLET_CONFIG);
    SessionMessages.add(resourceRequest,
            portletConfig.getPortletName() + SessionMessages.KEY_SUFFIX_HIDE_DEFAULT_ERROR_MESSAGE);
}