Example usage for com.liferay.portal.kernel.util JavaConstants JAVAX_PORTLET_CONFIG

List of usage examples for com.liferay.portal.kernel.util JavaConstants JAVAX_PORTLET_CONFIG

Introduction

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

Prototype

String JAVAX_PORTLET_CONFIG

To view the source code for com.liferay.portal.kernel.util JavaConstants JAVAX_PORTLET_CONFIG.

Click Source Link

Usage

From source file:org.oep.cmon.timhoso.portlet.action.TimHoSoAction.java

License:Apache License

/**
 * This is function search CongDan//from  w w  w.j  ava 2s.c  o m
 * Version: 1.0
 *  
 * History: 
 *   DATE        AUTHOR      DESCRIPTION 
 *  ------------------------------------------------- 
 *  3-March-2013  Nam Dinh    Create new
 * @param actionRequest
 * @param actionResponse
 * @throws Exception
 */
public void searchHoSoByMa(ActionRequest actionRequest, ActionResponse actionResponse) throws Exception {
    String searchKeyWord = ParamUtil.getString(actionRequest, "searchKeyWord").trim();
    actionResponse.setRenderParameter("searchKeyWord", searchKeyWord);
    PortletConfig portletConfig = (PortletConfig) actionRequest
            .getAttribute(JavaConstants.JAVAX_PORTLET_CONFIG);
    SessionMessages.add(actionRequest,
            portletConfig.getPortletName() + SessionMessages.KEY_SUFFIX_HIDE_DEFAULT_ERROR_MESSAGE);
}

From source file:org.oep.cmon.user.portlet.action.UserEndorsePortlet.java

License:Apache License

/**
 * This is function Citizen endorsement//from  w w  w  .ja  va 2 s.c  o m
 * Version: 1.0
 *  
 * History: 
 *   DATE        AUTHOR      DESCRIPTION 
 *  ------------------------------------------------- 
 *  3-March-2013  Nam Dinh    Create new
 * @param actionRequest
 * @param actionResponse
 * @throws Exception 
 */
public void endorse(ActionRequest actionRequest, ActionResponse actionResponse) throws Exception {
    // Get the object from session
    Map<String, String> userRequest = (Map<String, String>) actionRequest.getPortletSession()
            .getAttribute("USER_REQUEST_OBJECT");

    // Get all parameters from request
    String hoCongDan = "";
    if (Validator.isNotNull(ParamUtil.getString(actionRequest, "ho"))) {
        hoCongDan = ParamUtil.getString(actionRequest, "ho").trim().toUpperCase();
        userRequest.put("HOCONGDAN", hoCongDan);
    }

    String tenDem = "";
    if (Validator.isNotNull(ParamUtil.getString(actionRequest, "dem"))) {
        tenDem = ParamUtil.getString(actionRequest, "dem").trim().toUpperCase();
        userRequest.put("TENDEM", tenDem);
    }

    String tenCongDan = "";
    if (Validator.isNotNull(ParamUtil.getString(actionRequest, "ten"))) {
        tenCongDan = ParamUtil.getString(actionRequest, "ten").trim().toUpperCase();
        userRequest.put("TENCONGDAN", tenCongDan);
    }

    String soCmnd = ParamUtil.getString(actionRequest, "soCmnd").trim();
    userRequest.put("SOCMND", soCmnd);

    String ngayCapCmnd = ParamUtil.getString(actionRequest, "ngayCapCmnd");
    userRequest.put("NGAYCAPCMND", ngayCapCmnd);

    String noiCapCmnd = ParamUtil.getString(actionRequest, "noiCapCmnd");
    if (Validator.isNotNull(noiCapCmnd)) {
        userRequest.put("IDNOICAPCMND", noiCapCmnd);
    }

    String ghiChuCmnd = ParamUtil.getString(actionRequest, "ghiChuCmnd").trim();
    userRequest.put("GHICHUCMND", ghiChuCmnd);

    String email = ParamUtil.getString(actionRequest, "email").trim();
    userRequest.put("EMAIL", email);

    String soHoChieu = ParamUtil.getString(actionRequest, "soHoChieu").trim();
    userRequest.put("SOHOCHIEU", soHoChieu);

    String ngayCapHoChieu = ParamUtil.getString(actionRequest, "ngayCapHoChieu");
    userRequest.put("NGAYCAPHOCHIEU", ngayCapHoChieu);

    String noiCapHoChieu = ParamUtil.getString(actionRequest, "noiCapHoChieu");
    // If the data is not submitted from client, keep the original value from the object in session
    if (Validator.isNotNull(noiCapHoChieu)) {
        userRequest.put("IDNOICAPHOCHIEU", noiCapHoChieu);
    }

    String ngayHetHanHoChieu = ParamUtil.getString(actionRequest, "ngayHetHanHoChieu");
    userRequest.put("NGAYHETHANHOCHIEU", ngayHetHanHoChieu);

    String ghiChuHoChieu = ParamUtil.getString(actionRequest, "ghiChuHoChieu").trim();
    userRequest.put("GHICHUHOCHIEU", ghiChuHoChieu);

    String gioiTinh = ParamUtil.getString(actionRequest, "gioiTinh");
    if (Validator.isNotNull(gioiTinh)) {
        userRequest.put("IDGIOITINH", gioiTinh);
    }

    String danToc = ParamUtil.getString(actionRequest, "danToc");
    if (Validator.isNotNull(danToc)) {
        userRequest.put("IDDANTOC", danToc);
    }

    String tonGiao = ParamUtil.getString(actionRequest, "tonGiao");
    if (Validator.isNotNull(tonGiao)) {
        userRequest.put("IDTONGIAO", tonGiao);
    }

    String quocTich = ParamUtil.getString(actionRequest, "quocTich");
    if (Validator.isNotNull(quocTich)) {
        userRequest.put("IDQUOCTICH", quocTich);
    }

    String ngaySinh = ParamUtil.getString(actionRequest, "ngaySinh");
    userRequest.put("NGAYSINH", ngaySinh);

    String dtCoDinh = ParamUtil.getString(actionRequest, "dtCoDinh").trim();
    userRequest.put("DIENTHOAICODINH", dtCoDinh);

    String dtDiDong = ParamUtil.getString(actionRequest, "dtDiDong").trim();
    userRequest.put("DIENTHOAIDIDONG", dtDiDong);

    String trinhDoHocVan = ParamUtil.getString(actionRequest, "trinhDoHocVan");
    if (Validator.isNotNull(trinhDoHocVan)) {
        userRequest.put("IDTRINHDOHOCVAN", trinhDoHocVan);
    }

    String soBhyt = ParamUtil.getString(actionRequest, "soBhyt").trim();
    userRequest.put("SOBAOHIEMYTE", soBhyt);

    String ngheNghiep = ParamUtil.getString(actionRequest, "ngheNghiep");
    if (Validator.isNotNull(ngheNghiep)) {
        userRequest.put("IDNGHENGHIEP", ngheNghiep);
    }

    String trinhDoChuyenMon = ParamUtil.getString(actionRequest, "trinhDoChuyenMon");
    if (Validator.isNotNull(trinhDoChuyenMon)) {
        userRequest.put("IDTRINHDOCHUYENMON", trinhDoChuyenMon);
    }

    String tinhTrangHonNhan = ParamUtil.getString(actionRequest, "tinhTrangHonNhan");
    if (Validator.isNotNull(tinhTrangHonNhan)) {
        userRequest.put("IDTINHTRANGHONNHAN", tinhTrangHonNhan);
    }

    String tinhNoiSinh = ParamUtil.getString(actionRequest, "tinhNoiSinh");
    if (Validator.isNotNull(tinhNoiSinh)) {
        userRequest.put("IDTINHTHANHNOISINH", tinhNoiSinh);
    }

    String huyenNoiSinh = ParamUtil.getString(actionRequest, "huyenNoiSinh");
    if (Validator.isNotNull(huyenNoiSinh)) {
        userRequest.put("IDQUANHUYENNOISINH", huyenNoiSinh);
    }

    String xaNoiSinh = ParamUtil.getString(actionRequest, "xaNoiSinh");
    if (Validator.isNotNull(xaNoiSinh)) {
        userRequest.put("IDPHUONGXANOISINH", xaNoiSinh);
    }

    String motaNoisinh = ParamUtil.getString(actionRequest, "motaNoisinh").trim();
    userRequest.put("MOTADIACHINOISINH", motaNoisinh);

    String tinhThuongTru = ParamUtil.getString(actionRequest, "tinhThuongTru");
    if (Validator.isNotNull(tinhThuongTru)) {
        userRequest.put("IDTINHTHANHTHUONGTRU", tinhThuongTru);
    }

    String huyenThuongTru = ParamUtil.getString(actionRequest, "huyenThuongTru");
    if (Validator.isNotNull(huyenThuongTru)) {
        userRequest.put("IDQUANHUYENTHUONGTRU", huyenThuongTru);
    }

    String xaThuongTru = ParamUtil.getString(actionRequest, "xaThuongTru");
    if (Validator.isNotNull(xaThuongTru)) {
        userRequest.put("IDPHUONGXATHUONGTRU", xaThuongTru);
    }

    String motaThuongTru = ParamUtil.getString(actionRequest, "motaThuongTru").trim();
    userRequest.put("MOTADIACHITHUONGTRU", motaThuongTru);

    String tinhHienTai = ParamUtil.getString(actionRequest, "tinhHienTai");
    if (Validator.isNotNull(tinhHienTai)) {
        userRequest.put("IDTINHTHANHHIENTAI", tinhHienTai);
    }

    String huyenHienTai = ParamUtil.getString(actionRequest, "huyenHienTai");
    if (Validator.isNotNull(huyenHienTai)) {
        userRequest.put("IDQUANHUYENHIENTAI", huyenHienTai);
    }

    String xaHienTai = ParamUtil.getString(actionRequest, "xaHienTai");
    if (Validator.isNotNull(xaHienTai)) {
        userRequest.put("IDPHUONGXAHIENTAI", xaHienTai);
    }

    String motaDiachiHienTai = ParamUtil.getString(actionRequest, "motaDiachiHienTai").trim();
    userRequest.put("MOTADIACHIHIENTAI", motaDiachiHienTai);

    String soHoKhau = ParamUtil.getString(actionRequest, "soHoKhau").trim();
    userRequest.put("SOHOKHAU", soHoKhau);

    String chuHo = ParamUtil.getString(actionRequest, "chuHo");
    userRequest.put("CHUHO", chuHo);

    String mstCaNhan = ParamUtil.getString(actionRequest, "mstCaNhan").trim();
    userRequest.put("MASOTHUECANHAN", mstCaNhan);

    String quanHeChuHo = ParamUtil.getString(actionRequest, "quanHeChuHo");
    if (Validator.isNotNull(quanHeChuHo)) {
        userRequest.put("IDQUANHE", quanHeChuHo);
    }

    PortletConfig portletConfig = (PortletConfig) actionRequest
            .getAttribute(JavaConstants.JAVAX_PORTLET_CONFIG);
    SessionMessages.add(actionRequest,
            portletConfig.getPortletName() + SessionMessages.KEY_SUFFIX_HIDE_DEFAULT_ERROR_MESSAGE);

    // Set the data back to session
    actionRequest.getPortletSession().setAttribute("USER_REQUEST_OBJECT", userRequest);

    // Check Ho cong dan
    if (Validator.isNull(hoCongDan)) {
        SessionErrors.add(actionRequest, "vn.dtt.cmon.user.form.endorse.err.hoCongDan");
    }

    // Check ten cong dan
    if (Validator.isNull(tenCongDan)) {
        SessionErrors.add(actionRequest, "vn.dtt.cmon.user.form.endorse.err.tenCongDan");
    }

    // Check so cmnd
    if (!Constaints.isValidCMND(soCmnd)) {
        SessionErrors.add(actionRequest, "vn.dtt.cmon.user.form.endorse.err.soCmnd");
    }

    // Check email
    if (Validator.isNull(email) || !email.contains("@")) {
        SessionErrors.add(actionRequest, "vn.dtt.cmon.user.form.endorse.err.email");
    } else {
        TaiKhoanNguoiDung taiKhoan = TaiKhoanNguoiDungLocalServiceUtil.findByTenDangNhap(email);
        if (taiKhoan != null) {
            SessionErrors.add(actionRequest, "vn.dtt.cmon.user.form.endorse.err.emailDuplicate");
        }
    }

    // Check gioi tinh
    if (Validator.isNull(gioiTinh)) {
        SessionErrors.add(actionRequest, "vn.dtt.cmon.user.form.endorse.err.gioiTinh");
    }

    // Check ngay sinh
    if (Validator.isNull(ngaySinh)) {
        SessionErrors.add(actionRequest, "vn.dtt.cmon.user.form.endorse.err.ngaySinh");
    } else {
        // Validate birth date
        DateFormat df = new SimpleDateFormat(DATE_FORMAT);
        Date birthDate = null;
        df.setLenient(false);
        try {
            birthDate = df.parse(ngaySinh);
        } catch (Exception e) {
            // Error never happen so this exception will be swallow
        }

        if (birthDate.compareTo(new Date()) > 0) {
            SessionErrors.add(actionRequest, "vn.dtt.cmon.user.form.endorse.err.ngaySinh.greaterThanCurrent");
        }
    }

    // ngay cap
    if (Validator.isNull(ngayCapCmnd)) {
        SessionErrors.add(actionRequest, "vn.dtt.cmon.user.form.endorse.err.ngayCapCmnd");
    } else {
        DateFormat df = new SimpleDateFormat(DATE_FORMAT);
        Date birthDate = null;
        df.setLenient(false);
        try {
            birthDate = df.parse(ngayCapCmnd);
        } catch (Exception e) {
            // Error never happen so this exception will be swallow
        }
        if (birthDate.compareTo(new Date()) > 0) {
            SessionErrors.add(actionRequest, "vn.dtt.cmon.user.form.endorse.err.ngayCap.greaterThanCurrent");
        }
    }

    // Check dan toc
    if (Validator.isNull(danToc)) {
        SessionErrors.add(actionRequest, "vn.dtt.cmon.user.form.endorse.err.danToc");
    }

    // Check ton giao
    if (Validator.isNull(tonGiao)) {
        SessionErrors.add(actionRequest, "vn.dtt.cmon.user.form.endorse.err.tonGiao");
    }

    // Check tinh thuong tru
    if (Validator.isNull(tinhThuongTru)) {
        SessionErrors.add(actionRequest, "vn.dtt.cmon.user.form.endorse.err.tinhThuongTru");
    }

    // Check huyen thuong tru
    if (Validator.isNull(huyenThuongTru)) {
        SessionErrors.add(actionRequest, "vn.dtt.cmon.user.form.endorse.err.huyenThuongTru");
    }

    // Check xa thuong tru
    if (Validator.isNull(xaThuongTru)) {
        SessionErrors.add(actionRequest, "vn.dtt.cmon.user.form.endorse.err.xaThuongTru");
    }

    // In case there's error      
    String redirectUrl = ParamUtil.getString(actionRequest, "redirectUrl");
    if (!SessionErrors.isEmpty(actionRequest)) {

        actionResponse.sendRedirect(redirectUrl);

        return;
    }

    // Generate random password for user
    String password = AuthenticateCodeUtil.generateAuthCode().toLowerCase().trim();

    EndorsementBs endorse = new EndorsementBs(actionRequest);

    String fullName = hoCongDan + StringPool.SPACE + tenDem + StringPool.SPACE + tenCongDan;

    try {
        // Update yeu cau dang ky to DB      
        YeuCauDangKyCongDan yeuCau = endorse.updateUserRequest(userRequest);

        // Create portal user
        long userId = endorse.createPortalCitizenUser(yeuCau, password);

        String maCongDan = endorse.citizenExists(hoCongDan, tenDem, tenCongDan, soCmnd, ngaySinh);

        // Create data on cmon_taikhoan nguoidung
        long taiKhoanNguoiDungId = endorse.createTaiKhoan(userId, fullName, email, password);

        // Create citizen
        endorse.createCitizen(yeuCau, taiKhoanNguoiDungId, maCongDan);

        String portalUrl = PortalUtil.getPortalURL(actionRequest);
        endorse.sendEmail(fullName, email, password, portalUrl, actionRequest);

        // Remove sessioj items
        actionRequest.getPortletSession().removeAttribute("PROFILE_PIC");

        actionRequest.getPortletSession().removeAttribute("USER_REQUEST_OBJECT");

        // Redirect to success URL
        //String successUrl = ParamUtil.getString(actionRequest, "successUrl");

        actionRequest.setAttribute("endorseSuccess", "endorseSuccess");
        SessionMessages.add(actionRequest, "endorseSuccess");

    } catch (Exception e) {
        actionRequest.setAttribute("endorseError", "endorseError");
        SessionMessages.add(actionRequest, "endorseError");

        e.printStackTrace();
    }
}

From source file:org.oep.cmon.userreg.portlet.action.UserRegActionPortlet.java

License:Apache License

/**
 * This is function input basic information
 * Version: 1.0//w ww  .j  a va2  s .c om
 *  
 * History: 
 *   DATE        AUTHOR      DESCRIPTION 
 *  ------------------------------------------------- 
 *  3-March-2013  Nam Dinh    Create new
 * @param actionRequest
 * @param actionResponse
 * @throws IOException
 * @throws PortletException
 * @throws PortalException
 * @throws SystemException
 * @throws ParseException
 */
public void inputBasic(ActionRequest actionRequest, ActionResponse actionResponse)
        throws IOException, PortletException, PortalException, SystemException, ParseException {
    // Get the object from session
    Map<String, String> userRequest = (Map<String, String>) actionRequest.getPortletSession()
            .getAttribute("USER_REQUEST_OBJECT");

    // Get all parameters from request
    String hoCongDan = ParamUtil.getString(actionRequest, "ho").trim().toUpperCase();
    userRequest.put("HOCONGDAN", hoCongDan);

    String tenDem = ParamUtil.getString(actionRequest, "dem").trim().toUpperCase();
    userRequest.put("TENDEM", tenDem);

    String tenCongDan = ParamUtil.getString(actionRequest, "ten").trim().toUpperCase();
    userRequest.put("TENCONGDAN", tenCongDan);

    String soCmnd = ParamUtil.getString(actionRequest, "soCmnd").trim();
    userRequest.put("SOCMND", soCmnd);

    String email = ParamUtil.getString(actionRequest, "email").trim();
    userRequest.put("EMAIL", email);

    String ngaySinh = ParamUtil.getString(actionRequest, "ngaySinh").trim();
    userRequest.put("NGAYSINH", ngaySinh);

    String ngayCapCmnd = ParamUtil.getString(actionRequest, "ngayCapCmnd").trim();
    userRequest.put("NGAYCAPCMND", ngayCapCmnd);

    String gioiTinh = ParamUtil.getString(actionRequest, "gioiTinh");
    if (Validator.isNotNull(gioiTinh)) {
        userRequest.put("IDGIOITINH", gioiTinh);
    }

    String danToc = ParamUtil.getString(actionRequest, "danToc");
    if (Validator.isNotNull(danToc)) {
        userRequest.put("IDDANTOC", danToc);
    }

    String tonGiao = ParamUtil.getString(actionRequest, "tonGiao");
    if (Validator.isNotNull(tonGiao)) {
        userRequest.put("IDTONGIAO", tonGiao);
    }

    String tinhThuongTru = ParamUtil.getString(actionRequest, "tinhThuongTru");
    if (Validator.isNotNull(tinhThuongTru)) {
        userRequest.put("IDTINHTHANHTHUONGTRU", tinhThuongTru);
    }

    String huyenThuongTru = ParamUtil.getString(actionRequest, "huyenThuongTru");
    if (Validator.isNotNull(huyenThuongTru)) {
        userRequest.put("IDQUANHUYENTHUONGTRU", huyenThuongTru);
    }

    String xaThuongTru = ParamUtil.getString(actionRequest, "xaThuongTru");
    if (Validator.isNotNull(xaThuongTru)) {
        userRequest.put("IDPHUONGXATHUONGTRU", xaThuongTru);
    }

    String motaThuongTru = ParamUtil.getString(actionRequest, "motaThuongTru").trim();
    userRequest.put("MOTADIACHITHUONGTRU", motaThuongTru);

    // Set the data back to session
    actionRequest.getPortletSession().setAttribute("USER_REQUEST_OBJECT", userRequest);

    // BinhNT add 2013-12-22 
    String reloadcapchar = ParamUtil.getString(actionRequest, "reloadcapchar").trim();
    if (reloadcapchar.trim().compareTo("reloadcapchar") == 0) {
        String redirectUrl = ParamUtil.getString(actionRequest, "redirectUrl");
        actionResponse.sendRedirect(redirectUrl);
        return;
    }
    // End BinhNT Add 2013-12-22
    // Validate captcha
    if (!CheckCaptchaUtil.isTrue(actionRequest, "captcha")) {
        SessionErrors.add(actionRequest, "vn.dtt.cmon.userreg.form.input.err.captcha");
    }

    // Check Ho cong dan
    if (Validator.isNull(hoCongDan)) {
        SessionErrors.add(actionRequest, "vn.dtt.cmon.userreg.form.input.err.hoCongDan");
    }

    // Check ten cong dan
    if (Validator.isNull(tenCongDan)) {
        SessionErrors.add(actionRequest, "vn.dtt.cmon.userreg.form.input.err.tenCongDan");
    }

    // Check so cmnd
    if (Validator.isNull(soCmnd) || !Validator.isNumber(soCmnd)) {
        SessionErrors.add(actionRequest, "vn.dtt.cmon.userreg.form.input.err.soCmnd");
    }

    if (soCmnd.trim().length() < 9 || soCmnd.trim().length() > 12) {
        SessionErrors.add(actionRequest, "err.soCmndVoPhaiNamTrongKhoangTuChinDenMuoiHaiChuSo");
    }

    // Check email
    if (!Validator.isEmailAddress(email)) {
        SessionErrors.add(actionRequest, "vn.dtt.cmon.userreg.form.input.err.email");
    }

    // Check ngay sinh
    if (Validator.isNull(ngaySinh)) {
        SessionErrors.add(actionRequest, "vn.dtt.cmon.userreg.form.input.err.ngaySinh");
    }

    // In case there's error      
    String redirectUrl = ParamUtil.getString(actionRequest, "redirectUrl");

    if (!SessionErrors.isEmpty(actionRequest)) {

        actionResponse.sendRedirect(redirectUrl);

        return;
    }

    // Validate data against DB

    // Validate birth date
    DateFormat df = new SimpleDateFormat(DATE_FORMAT);
    Date birthDate = null;
    df.setLenient(false);
    try {
        birthDate = df.parse(ngaySinh);
    } catch (Exception e) {
        // Error never happen so this exception will be swallow
    }

    if (birthDate.compareTo(new Date()) > 0) {
        SessionErrors.add(actionRequest, "vn.dtt.cmon.userreg.form.input.err.ngaySinh.greaterThanCurrent");
    }

    //      // Check if in DB, there's already user request that not processed yet   
    //      if (this.requestExists(soCmnd)) {
    //         SessionErrors.add(actionRequest, "vn.dtt.cmon.userreg.form.input.err.requestExists");
    //      }

    List<CongDan> congDan = CongDanLocalServiceUtil.findByEmail(email);
    if (congDan.size() > 0) {
        if (this.cmndExists(soCmnd)) {
            SessionErrors.add(actionRequest, "vn.dtt.cmon.userreg.form.input.err.requestExists");
        }
        // Check email if exists in CSMS cong dan
        if (this.emailExistsInCongDan(email)) {
            SessionErrors.add(actionRequest, "vn.dtt.cmon.userreg.form.input.err.email.alreadyOwned");
        }
    }

    if (!SessionErrors.isEmpty(actionRequest)) {
        actionResponse.sendRedirect(redirectUrl);
        return;
    }

    // Check if citizen exists or not
    //String maCongDan = this.citizenExists(hoCongDan, tenDem, tenCongDan, soCmnd, ngaySinh);
    String maCongDan = this.congdanExists(soCmnd, ngaySinh);
    _log.info("ma cong dan:" + maCongDan);
    if (Validator.isNull(maCongDan)) {
        _log.info("chua co thong tin trong csms_congdan");
        // Redirect to input detail confirm
        String inputDetailDialogUrl = ParamUtil.getString(actionRequest, "inputDetailDialogUrl");

        PortletConfig portletConfig = (PortletConfig) actionRequest
                .getAttribute(JavaConstants.JAVAX_PORTLET_CONFIG);
        SessionMessages.add(actionRequest,
                portletConfig.getPortletName() + SessionMessages.KEY_SUFFIX_HIDE_DEFAULT_ERROR_MESSAGE);

        actionResponse.sendRedirect(inputDetailDialogUrl);

        return;
    }

    else {
        CongDan congDan1 = CongDanLocalServiceUtil.findByMa(maCongDan);
        _log.info("congDan1: " + congDan1);

        // Check email if exists in CSMS cong dan
        if (congDan1.getEmail().length() > 0) {
            _log.info("da co tai khoan csms_congdan");
            String accountExistDialog = ParamUtil.getString(actionRequest, "accountExistDialog");

            PortletConfig portletConfig = (PortletConfig) actionRequest
                    .getAttribute(JavaConstants.JAVAX_PORTLET_CONFIG);
            SessionMessages.add(actionRequest,
                    portletConfig.getPortletName() + SessionMessages.KEY_SUFFIX_HIDE_DEFAULT_ERROR_MESSAGE);
            actionResponse.sendRedirect(accountExistDialog);
            return;
        } else {
            _log.info("chua co tai khoan trong csms_congdan");
            String inputDetailDialogUrlExistInCongDan = ParamUtil.getString(actionRequest,
                    "inputDetailDialogUrlExistInCongDan");

            PortletConfig portletConfig = (PortletConfig) actionRequest
                    .getAttribute(JavaConstants.JAVAX_PORTLET_CONFIG);
            SessionMessages.add(actionRequest,
                    portletConfig.getPortletName() + SessionMessages.KEY_SUFFIX_HIDE_DEFAULT_ERROR_MESSAGE);
            actionResponse.sendRedirect(inputDetailDialogUrlExistInCongDan);
            return;

        }

    }

    // Generate authentication code
    //      String authCode = AuthenticateCodeUtil.generateAuthCode();
    //      
    //      // Insert data to yeu cau dang ky cong dan   
    //      this.createAccountRequest(maCongDan, authCode, userRequest, actionRequest);
    //      
    //      String accountCreationUrl = ParamUtil.getString(actionRequest, "accountCreationUrl");
    //      
    //      accountCreationUrl = accountCreationUrl.replace("DUMMY_AUTH_CODE", authCode);
    //      
    //      // Send email here
    //      this.sendAccountConfirmationEmail(hoCongDan, tenDem, tenCongDan, accountCreationUrl, email);
    //      
    //      // Redirect to success page   
    //      String accountRegisterSuccessUrl = ParamUtil.getString(actionRequest, "accountRegisterSuccessUrl");
    //      
    //      // Remove object in session
    //      actionRequest.getPortletSession().removeAttribute("USER_REQUEST_OBJECT");
    //      
    //      PortletConfig portletConfig = (PortletConfig)actionRequest.getAttribute(JavaConstants.JAVAX_PORTLET_CONFIG);
    //      SessionMessages.add(actionRequest,  portletConfig.getPortletName() + SessionMessages.KEY_SUFFIX_HIDE_DEFAULT_ERROR_MESSAGE);
    //      
    //      // Redirect to account register success page
    //      actionResponse.sendRedirect(accountRegisterSuccessUrl);
}

From source file:org.oep.cmon.userreg.portlet.action.UserRegActionPortlet.java

License:Apache License

/**
 * This is function input detail information about cong dan
 * Version: 1.0//from www .  j  a v  a 2 s  .c  o m
 *  
 * History: 
 *   DATE        AUTHOR      DESCRIPTION 
 *  ------------------------------------------------- 
 *  3-March-2013  Nam Dinh    Create new
 * @param actionRequest
 * @param actionResponse
 * @throws IOException
 * @throws PortletException
 * @throws PortalException
 * @throws SystemException
 * @throws ParseException
 */
public void inputDetail(ActionRequest actionRequest, ActionResponse actionResponse)
        throws IOException, PortletException, PortalException, SystemException, ParseException {
    // Get the object from session
    Map<String, String> userRequest = (Map<String, String>) actionRequest.getPortletSession()
            .getAttribute("USER_REQUEST_OBJECT");

    // Get all parameters from request
    String hoCongDan = ParamUtil.getString(actionRequest, "ho").trim().toUpperCase();
    userRequest.put("HOCONGDAN", hoCongDan);

    String tenDem = ParamUtil.getString(actionRequest, "dem").trim().toUpperCase();
    userRequest.put("TENDEM", tenDem);

    String tenCongDan = ParamUtil.getString(actionRequest, "ten").trim().toUpperCase();
    userRequest.put("TENCONGDAN", tenCongDan);

    String soCmnd = ParamUtil.getString(actionRequest, "soCmnd").trim();
    userRequest.put("SOCMND", soCmnd);

    String ngayCapCmnd = ParamUtil.getString(actionRequest, "ngayCapCmnd").trim();
    userRequest.put("NGAYCAPCMND", ngayCapCmnd);

    String noiCapCmnd = ParamUtil.getString(actionRequest, "noiCapCmnd").trim();
    if (Validator.isNotNull(noiCapCmnd)) {
        userRequest.put("IDNOICAPCMND", noiCapCmnd);
    }

    String email = ParamUtil.getString(actionRequest, "email").trim();
    userRequest.put("EMAIL", email);

    //      String soHoChieu = ParamUtil.getString(actionRequest, "soHoChieu").trim();
    //      userRequest.put("SOHOCHIEU", soHoChieu);
    //      
    //      String ngayCapHoChieu = ParamUtil.getString(actionRequest, "ngayCapHoChieu");
    //      userRequest.put("NGAYCAPHOCHIEU", ngayCapHoChieu);
    //      
    //      String noiCapHoChieu = ParamUtil.getString(actionRequest, "noiCapHoChieu").trim();
    //      // If the data is not submitted from client, keep the original value from the object in session
    //      if ( Validator.isNotNull(noiCapHoChieu)) {
    //         userRequest.put("IDNOICAPHOCHIEU", noiCapHoChieu);
    //      }
    //      
    //      String ngayHetHanHoChieu = ParamUtil.getString(actionRequest, "ngayHetHanHoChieu");
    //      userRequest.put("NGAYHETHANHOCHIEU", ngayHetHanHoChieu);
    //      
    //      String ghiChuHoChieu = ParamUtil.getString(actionRequest, "ghiChuHoChieu").trim();
    //      userRequest.put("GHICHUHOCHIEU", ghiChuHoChieu);

    String gioiTinh = ParamUtil.getString(actionRequest, "gioiTinh");
    if (Validator.isNotNull(gioiTinh)) {
        userRequest.put("IDGIOITINH", gioiTinh);
    }

    String danToc = ParamUtil.getString(actionRequest, "danToc");
    if (Validator.isNotNull(danToc)) {
        userRequest.put("IDDANTOC", danToc);
    }

    String tonGiao = ParamUtil.getString(actionRequest, "tonGiao");
    if (Validator.isNotNull(tonGiao)) {
        userRequest.put("IDTONGIAO", tonGiao);
    }

    String quocTich = ParamUtil.getString(actionRequest, "quocTich");
    if (Validator.isNotNull(quocTich)) {
        userRequest.put("IDQUOCTICH", String.valueOf(org.oep.cmon.Constants.VIETNAM));
    }

    String ngaySinh = ParamUtil.getString(actionRequest, "ngaySinh");
    userRequest.put("NGAYSINH", ngaySinh);

    //      String dtCoDinh = ParamUtil.getString(actionRequest, "dtCoDinh").trim();
    //      userRequest.put("DIENTHOAICODINH", dtCoDinh);
    //      
    //      String dtDiDong = ParamUtil.getString(actionRequest, "dtDiDong").trim();
    //      userRequest.put("DIENTHOAIDIDONG", dtDiDong);
    //      
    //      String trinhDoHocVan = ParamUtil.getString(actionRequest, "trinhDoHocVan");
    //      if ( Validator.isNotNull(trinhDoHocVan)) {
    //         userRequest.put("IDTRINHDOHOCVAN", trinhDoHocVan);
    //      }
    //      
    //      String soBhyt = ParamUtil.getString(actionRequest, "soBhyt").trim();
    //      userRequest.put("SOBAOHIEMYTE", soBhyt);
    //      
    //      String ngheNghiep = ParamUtil.getString(actionRequest, "ngheNghiep");
    //      if ( Validator.isNotNull(ngheNghiep)) {
    //         userRequest.put("IDNGHENGHIEP", ngheNghiep);
    //      }
    //      
    //      String trinhDoChuyenMon = ParamUtil.getString(actionRequest, "trinhDoChuyenMon");
    //      if ( Validator.isNotNull(trinhDoChuyenMon)) {
    //         userRequest.put("IDTRINHDOCHUYENMON", trinhDoChuyenMon);
    //      }
    //      
    //      String tinhTrangHonNhan = ParamUtil.getString(actionRequest, "tinhTrangHonNhan");
    //      if ( Validator.isNotNull(tinhTrangHonNhan)) {
    //         userRequest.put("IDTINHTRANGHONNHAN", tinhTrangHonNhan);
    //      }

    //      String tinhNoiSinh = ParamUtil.getString(actionRequest, "tinhNoiSinh");
    //      if ( Validator.isNotNull(tinhNoiSinh)) {
    //         userRequest.put("IDTINHTHANHNOISINH", tinhNoiSinh);
    //      }
    //      
    //      String huyenNoiSinh = ParamUtil.getString(actionRequest, "huyenNoiSinh");
    //      if ( Validator.isNotNull(huyenNoiSinh)) {
    //         userRequest.put("IDQUANHUYENNOISINH", huyenNoiSinh);
    //      }
    //      
    //      String xaNoiSinh = ParamUtil.getString(actionRequest, "xaNoiSinh");
    //      if ( Validator.isNotNull(xaNoiSinh)) {
    //         userRequest.put("IDPHUONGXANOISINH", xaNoiSinh);
    //      }
    //      
    //      String motaNoisinh = ParamUtil.getString(actionRequest, "motaNoisinh").trim();
    //      userRequest.put("MOTADIACHINOISINH", motaNoisinh);

    String tinhThuongTru = ParamUtil.getString(actionRequest, "tinhThuongTru");
    if (Validator.isNotNull(tinhThuongTru)) {
        userRequest.put("IDTINHTHANHTHUONGTRU", tinhThuongTru);
    }

    String huyenThuongTru = ParamUtil.getString(actionRequest, "huyenThuongTru");
    if (Validator.isNotNull(huyenThuongTru)) {
        userRequest.put("IDQUANHUYENTHUONGTRU", huyenThuongTru);
    }

    String xaThuongTru = ParamUtil.getString(actionRequest, "xaThuongTru");
    if (Validator.isNotNull(xaThuongTru)) {
        userRequest.put("IDPHUONGXATHUONGTRU", xaThuongTru);
    }

    String motaThuongTru = ParamUtil.getString(actionRequest, "motaThuongTru").trim();
    userRequest.put("MOTADIACHITHUONGTRU", motaThuongTru);
    //      
    //      String tinhHienTai = ParamUtil.getString(actionRequest, "tinhHienTai");
    //      if ( Validator.isNotNull(tinhHienTai)) {
    //         userRequest.put("IDTINHTHANHHIENTAI", tinhHienTai);
    //      }
    //      
    //      String huyenHienTai = ParamUtil.getString(actionRequest, "huyenHienTai");
    //      if ( Validator.isNotNull(huyenHienTai)) {
    //         userRequest.put("IDQUANHUYENHIENTAI", huyenHienTai);
    //      }
    //      
    //      String xaHienTai = ParamUtil.getString(actionRequest, "xaHienTai");
    //      if ( Validator.isNotNull(xaHienTai)) {
    //         userRequest.put("IDPHUONGXAHIENTAI", xaHienTai);
    //      }

    //      String motaDiachiHienTai = ParamUtil.getString(actionRequest, "motaDiachiHienTai").trim();
    //      userRequest.put("MOTADIACHIHIENTAI", motaDiachiHienTai);      
    //      
    //      String soHoKhau = ParamUtil.getString(actionRequest, "soHoKhau").trim();
    //      userRequest.put("SOHOKHAU", soHoKhau);
    //      
    //      String chuHo = ParamUtil.getString(actionRequest, "chuHo");
    //      userRequest.put("CHUHO", chuHo);
    //      
    //      String mstCaNhan =  ParamUtil.getString(actionRequest, "mstCaNhan").trim();
    //      userRequest.put("MASOTHUECANHAN", mstCaNhan);            
    //      
    //      String quanHeChuHo = ParamUtil.getString(actionRequest, "quanHeChuHo");
    //      if ( Validator.isNotNull(quanHeChuHo)) {
    //         userRequest.put("IDQUANHE", quanHeChuHo);   
    //      }

    // Set the data back to session
    actionRequest.getPortletSession().setAttribute("USER_REQUEST_OBJECT", userRequest);

    PortletConfig portletConfig = (PortletConfig) actionRequest
            .getAttribute(JavaConstants.JAVAX_PORTLET_CONFIG);
    SessionMessages.add(actionRequest,
            portletConfig.getPortletName() + SessionMessages.KEY_SUFFIX_HIDE_DEFAULT_ERROR_MESSAGE);

    // BinhNT add 2013-12-22 
    String reloadcapchar = ParamUtil.getString(actionRequest, "reloadcapchar").trim();
    if (reloadcapchar.trim().compareTo("reloadcapchar") == 0) {

        String redirectUrl = ParamUtil.getString(actionRequest, "redirectUrl");
        actionResponse.sendRedirect(redirectUrl);
        return;
    }
    //      // End BinhNT Add 2013-12-22

    // Validate captcha
    if (!CheckCaptchaUtil.isTrue(actionRequest, "captcha")) {
        SessionErrors.add(actionRequest, "vn.dtt.cmon.userreg.form.input.err.captcha");
    }

    // Check Ho cong dan
    if (Validator.isNull(hoCongDan)) {
        SessionErrors.add(actionRequest, "vn.dtt.cmon.userreg.form.input.err.hoCongDan");
    }

    // Check ten cong dan
    if (Validator.isNull(tenCongDan)) {
        SessionErrors.add(actionRequest, "vn.dtt.cmon.userreg.form.input.err.tenCongDan");
    }

    // Check so cmnd
    if (Validator.isNull(soCmnd) || !Validator.isNumber(soCmnd)) {
        SessionErrors.add(actionRequest, "vn.dtt.cmon.userreg.form.input.err.soCmnd");
    }

    // Check ngay cap CMND
    if (Validator.isNull(ngayCapCmnd)) {
        SessionErrors.add(actionRequest, "vn.dtt.cmon.userreg.form.input.err.ngayCapCmnd");
    }

    long noiCapCmnd1 = ParamUtil.getLong(actionRequest, "noiCapCmnd");
    // Check noi cap cmnd
    if (noiCapCmnd1 == 0) {
        SessionErrors.add(actionRequest, "vn.dtt.cmon.userreg.form.input.err.noiCapCmnd");
    }

    // Check email
    //      if (Validator.isNull(email)) {
    //         SessionErrors.add(actionRequest, "vn.dtt.cmon.userreg.form.input.err.email");
    //      }      

    if (soCmnd.trim().length() < 9 || soCmnd.trim().length() > 12) {
        SessionErrors.add(actionRequest, "err.soCmndVoPhaiNamTrongKhoangTuChinDenMuoiHaiChuSo");
    }

    // Check email
    if (!Validator.isEmailAddress(email)) {
        SessionErrors.add(actionRequest, "vn.dtt.cmon.userreg.form.input.err.email");
    }

    // Check gioi tinh
    if (Validator.isNull(gioiTinh)) {
        SessionErrors.add(actionRequest, "vn.dtt.cmon.userreg.form.input.err.gioiTinh");
    }

    // Check dan toc
    //      if (Validator.isNull(danToc)) {
    //         SessionErrors.add(actionRequest, "vn.dtt.cmon.userreg.form.input.err.danToc");
    //      }
    //      
    //      // Check ton giao
    //      if (Validator.isNull(tonGiao)) {
    //         SessionErrors.add(actionRequest, "vn.dtt.cmon.userreg.form.input.err.tonGiao");
    //      }
    //      
    //      // Check quoc tich
    //      if (Validator.isNull(quocTich)) {
    //         SessionErrors.add(actionRequest, "vn.dtt.cmon.userreg.form.input.err.quocTich");
    //      }
    //      
    // Check ngay sinh
    if (Validator.isNull(ngaySinh)) {
        SessionErrors.add(actionRequest, "vn.dtt.cmon.userreg.form.input.err.ngaySinh");
    }

    // Check tinh trang hon nhan
    //      if (Validator.isNull(tinhTrangHonNhan)) {
    //         SessionErrors.add(actionRequest, "vn.dtt.cmon.userreg.form.input.err.tinhTrangHonNhan");
    //      }
    //      
    //      // Check tinh noi sinh
    //      if (Validator.isNull(tinhNoiSinh)) {
    //         SessionErrors.add(actionRequest, "vn.dtt.cmon.userreg.form.input.err.tinhNoiSinh");
    //      }
    //      
    //      // Check huyen noi sinh
    //      if (Validator.isNull(huyenNoiSinh)) {
    //         SessionErrors.add(actionRequest, "vn.dtt.cmon.userreg.form.input.err.huyenNoiSinh");
    //      }
    //      
    //      // Check phuong xa noi sinh
    //      if (Validator.isNull(xaNoiSinh)) {
    //         SessionErrors.add(actionRequest, "vn.dtt.cmon.userreg.form.input.err.xaNoiSinh");
    //      }

    // Check tinh thuong tru
    if (Validator.isNull(tinhThuongTru)) {
        SessionErrors.add(actionRequest, "vn.dtt.cmon.userreg.form.input.err.tinhThuongTru");
    }

    // Check huyen thuong tru
    if (Validator.isNull(huyenThuongTru)) {
        SessionErrors.add(actionRequest, "vn.dtt.cmon.userreg.form.input.err.huyenThuongTru");
    }

    // Check xa thuong tru
    if (Validator.isNull(xaThuongTru)) {
        SessionErrors.add(actionRequest, "vn.dtt.cmon.userreg.form.input.err.xaThuongTru");
    }
    //      
    //      // Check tinh noi o hien tai
    //      if (Validator.isNull(tinhHienTai)) {
    //         SessionErrors.add(actionRequest, "vn.dtt.cmon.userreg.form.input.err.tinhHienTai");
    //      }
    //      
    //      // Check huyen hien tai
    //      if (Validator.isNull(huyenHienTai)) {
    //         SessionErrors.add(actionRequest, "vn.dtt.cmon.userreg.form.input.err.huyenHienTai");
    //      }
    //      
    //      // Check xa hien tai
    //      if (Validator.isNull(xaHienTai)) {
    //         SessionErrors.add(actionRequest, "vn.dtt.cmon.userreg.form.input.err.xaHienTai");
    //      }

    // Check so ho khau
    //      if (Validator.isNull(soHoKhau)) {
    //         //SessionErrors.add(actionRequest, "vn.dtt.cmon.userreg.form.input.err.soHoKhau");
    //      }

    // Check chu ho
    //      if (Validator.isNull(chuHo)) {
    //         SessionErrors.add(actionRequest, "vn.dtt.cmon.userreg.form.input.err.chuHo");
    //      }
    //      
    //      // Check quan he voi chu ho
    //      if (Validator.isNull(quanHeChuHo)) {
    //         SessionErrors.add(actionRequest, "vn.dtt.cmon.userreg.form.input.err.quanHeChuHo");
    //      }

    // Check mo ta dia chi noi sinh
    //      if (Validator.isNull(motaNoisinh)) {
    //         SessionErrors.add(actionRequest, "vn.dtt.cmon.userreg.form.input.err.motaNoiSinh");
    //      }

    // Check mo ta dia chi thuong tru
    if (Validator.isNull(motaThuongTru)) {
        SessionErrors.add(actionRequest, "vn.dtt.cmon.userreg.form.input.err.motaThuongTru");
    }

    // Check mo ta dia chi hien tai
    //      if (Validator.isNull(motaDiachiHienTai)) {
    //         SessionErrors.add(actionRequest, "vn.dtt.cmon.userreg.form.input.err.motaDiachiHienTai");
    //      }      

    // In case there's error      
    String redirectUrl = ParamUtil.getString(actionRequest, "redirectUrl");
    if (!SessionErrors.isEmpty(actionRequest)) {

        actionResponse.sendRedirect(redirectUrl);

        return;
    }

    // Check data against DB

    // Validate birth date
    DateFormat df = new SimpleDateFormat(DATE_FORMAT);
    Date birthDate = null;
    df.setLenient(false);
    try {
        birthDate = df.parse(ngaySinh);
    } catch (Exception e) {
        // Error never happen so this exception will be swallow
    }

    if (birthDate.compareTo(new Date()) > 0) {
        SessionErrors.add(actionRequest, "vn.dtt.cmon.userreg.form.input.err.ngaySinh.greaterThanCurrent");
    }

    // Check if in DB, there's already user request that not processed yet
    //      if ( this.requestExists(soCmnd)) {
    //         SessionErrors.add(actionRequest, "vn.dtt.cmon.userreg.form.input.err.requestExists");
    //      }

    List<CongDan> congDan = CongDanLocalServiceUtil.findByEmail(email);
    if (congDan.size() > 0) {
        if (this.cmndExists(soCmnd)) {
            SessionErrors.add(actionRequest, "vn.dtt.cmon.userreg.form.input.err.requestExists");
        }
        // Check email if exists in CSMS cong dan
        if (this.emailExistsInCongDan(email)) {
            SessionErrors.add(actionRequest, "vn.dtt.cmon.userreg.form.input.err.email.alreadyOwned");
        }

    }

    if (!SessionErrors.isEmpty(actionRequest)) {

        actionResponse.sendRedirect(redirectUrl);

        return;
    }

    // Check if citizen exists or not
    //String maCongDan = this.citizenExists(hoCongDan, tenDem, tenCongDan, soCmnd, ngaySinh);      
    String maCongDan = this.congdanExists(soCmnd, ngaySinh);

    // Generate authentication code
    //String authCode = AuthenticateCodeUtil.generateAuthCode();
    String authCode = ParamUtil.getString(actionRequest, "authCode");
    // Update yeu cau dang ky to DB      
    //long reqId = this.createUserRequest(maCongDan, authCode, userRequest, actionRequest);
    this.createAccountRequest(maCongDan, authCode, userRequest, actionRequest);
    // Update profile picture
    //this.updateAnhChanDung(reqId, actionRequest);
    actionRequest.getPortletSession().removeAttribute("PROFILE_PIC");

    actionRequest.getPortletSession().removeAttribute("USER_REQUEST_OBJECT");

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

    accountCreationUrl = accountCreationUrl.replace("DUMMY_AUTH_CODE", authCode);

    accountCreationUrl.replace("Userregistrationportlet_WAR_cmonappportlet", "");

    String uri = actionRequest.getScheme() + "://" + actionRequest.getServerName();
    int port = actionRequest.getServerPort();
    String portUrl = String.valueOf(port);
    String friendlyUrl = null;
    if (portUrl.equals("80")) {
        friendlyUrl = uri + "/web/guest/home?p_p_id=Userregistrationportlet_WAR_cmonappportlet&jspPage="
                + URLEncoder.encode("/html/portlet/userreg/account_creation.jsp", "UTF-8") + "&authCode="
                + authCode;
    } else {
        friendlyUrl = uri + ":" + portUrl
                + "/web/guest/home?p_p_id=Userregistrationportlet_WAR_cmonappportlet&jspPage="
                + URLEncoder.encode("/html/portlet/userreg/account_creation.jsp", "UTF-8") + "&authCode="
                + authCode;
    }
    // Send email and redirect
    if (Validator.isNotNull(maCongDan)) {
        SessionErrors.add(actionRequest, "vn.dtt.cmon.userreg.form.input.err.email.alreadyOwned");
        // Send email here
        //this.sendAccountConfirmationEmail(hoCongDan, tenDem, tenCongDan, accountCreationUrl, email, uri);

        // Redirect to success page   
        //String accountRegisterSuccessUrl = ParamUtil.getString(actionRequest, "accountRegisterSuccessUrl");

        // Redirect to account register success page
        //   actionResponse.sendRedirect(accountRegisterSuccessUrl);

        //return;
    }

    // Send email incase of register both citizen and account
    //this.sendCitizenConfirmationEmail(hoCongDan, tenDem, tenCongDan, friendlyUrl, email, uri);   
    String friendlyUrl1 = ParamUtil.getString(actionRequest, "friendlyUrl");
    this.sendCitizenConfirmationEmail(hoCongDan, tenDem, tenCongDan, friendlyUrl1, email, uri, actionRequest);

    // Redirect to success URL
    String citizenRegisterSuccessUrl = ParamUtil.getString(actionRequest, "citizenRegisterSuccessUrl");

    actionResponse.sendRedirect(citizenRegisterSuccessUrl);
    //actionResponse.setRenderParameter("jspPage", citizenRegisterSuccessUrl);
    //actionResponse.setRenderParameter("emailCongDan", email);
}

From source file:org.oep.cmon.userreg.portlet.action.UserRegActionPortlet.java

License:Apache License

/**
 * This is function save YeuCauDangKyCongDan
 * Version: 1.0/*ww w  .j av a2 s .  c  om*/
 *  
 * History: 
 *   DATE        AUTHOR      DESCRIPTION 
 *  ------------------------------------------------- 
 *  3-March-2013  Nam Dinh    Create new
 * @param actionRequest
 * @param httpReq
 * @throws NumberFormatException
 * @throws Exception
 */
public void saveYeuCauDangKyCongDan(ActionRequest actionRequest, ActionResponse httpReq)
        throws NumberFormatException, Exception {

    String soCmnd = ParamUtil.getString(actionRequest, "soCmnd").trim();
    String ngaySinh = ParamUtil.getString(actionRequest, "ngaySinh").trim();

    // email - String
    String email = ParamUtil.getString(actionRequest, "email").trim();
    // ho - String
    String ho = ParamUtil.getString(actionRequest, "ho").trim();
    // email - String
    String dem = ParamUtil.getString(actionRequest, "dem").trim();
    // ho - String
    String ten = ParamUtil.getString(actionRequest, "ten").trim();

    if (validatorsYeuCauDangKyCongDan(actionRequest)) {
        saveYeuCauDangKyCongDanToDB(actionRequest, httpReq);

        String maCongDan = this.congdanExists(soCmnd, ngaySinh);
        // Generate authentication code
        String authCode = AuthenticateCodeUtil.generateAuthCode();

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

        accountCreationUrl = accountCreationUrl.replace("DUMMY_AUTH_CODE", authCode);

        String uri = actionRequest.getScheme() + "://" + actionRequest.getServerName();
        // Send email and redirect
        if (Validator.isNotNull(maCongDan)) {
            // Send email here
            this.sendAccountConfirmationEmail(ho, dem, ten, accountCreationUrl, email, uri);

            // Redirect to success page   
            String accountRegisterSuccessUrl = ParamUtil.getString(actionRequest, "accountRegisterSuccessUrl");

            // Redirect to account register success page
            httpReq.sendRedirect(accountRegisterSuccessUrl);

            return;
        }

        // Send email incase of register both citizen and account
        this.sendCitizenConfirmationEmail(ho, dem, ten, accountCreationUrl, email, uri, actionRequest);

        // Redirect to success URL
        String citizenRegisterSuccessUrl = ParamUtil.getString(actionRequest, "citizenRegisterSuccessUrl");

        httpReq.sendRedirect(citizenRegisterSuccessUrl);

    } else {

        httpReq.setRenderParameter("jspPage", "/html/portlet/userreg/input_detail_exist_congdan.jsp");
    }
    PortletConfig portletConfig = (PortletConfig) actionRequest
            .getAttribute(JavaConstants.JAVAX_PORTLET_CONFIG);
    SessionMessages.add(actionRequest,
            portletConfig.getPortletName() + SessionMessages.KEY_SUFFIX_HIDE_DEFAULT_ERROR_MESSAGE);
}

From source file:org.oep.cmon.util.ComUtils.java

License:Apache License

/** 
 * This is function saveTraoDoi/*  w w w  .  java2s  . com*/
 * 
 * Version: 1.0
 *  
 * History: 
 *   DATE        AUTHOR      DESCRIPTION 
 *  ------------------------------------------------- 
 *  10-April-2013  Nam Dinh    Create new
 * @param resourceRequest
 * @param httpReq
 * @throws NumberFormatException
 * @throws Exception
 */
public static void saveTraoDoi(ActionRequest resourceRequest, ActionResponse httpReq)
        throws NumberFormatException, Exception {
    // hoso - String
    long idHoSo = FormatUtil.convertToLong(ParamUtil.getString(resourceRequest, "hoSoTTHCCongId"));
    String tieuDe = ParamUtil.getString(resourceRequest, "tieuDe").trim();
    String noiDung = ParamUtil.getString(resourceRequest, "noiDung").trim();
    String type = ParamUtil.getString(resourceRequest, "type").trim();
    String quayLaiLink = ParamUtil.getString(resourceRequest, "quayLaiLink").trim();
    String loaiCanBo = ParamUtil.getString(resourceRequest, "loaiCanBo");
    System.err.println("loaiCanBo action:" + loaiCanBo);
    if (validatorsYKienTraoDoi(resourceRequest)) {
        //saveYKienTraoDoiToDB(resourceRequest, httpReq);

        saveYKienTraoDoiVaoDatabase(resourceRequest, httpReq);
        httpReq.setRenderParameter("type", String.valueOf(type));
        httpReq.setRenderParameter("hoSoTTHCCongId", String.valueOf(idHoSo));
        httpReq.setRenderParameter("loaiCanBo", String.valueOf(loaiCanBo));
        httpReq.setRenderParameter("jspPage", "/html/cmon/ykientraodoi/danh_sach_y_kien.jsp");

    } else {
        httpReq.setRenderParameter("tieuDe", String.valueOf(tieuDe));
        httpReq.setRenderParameter("noiDung", String.valueOf(noiDung));
        httpReq.setRenderParameter("hoSoTTHCCongId", String.valueOf(idHoSo));
        httpReq.setRenderParameter("type", String.valueOf(type));
        httpReq.setRenderParameter("quayLaiLink", String.valueOf(quayLaiLink));
        httpReq.setRenderParameter("jspPage", "/html/cmon/ykientraodoi/canbo_traodoi_form.jsp");
    }
    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.util.ComUtils.java

License:Apache License

/** 
 * This is function saveTraoDoiCanBo// w ww  . jav a  2s.  co m
 * 
 * Version: 1.0
 *  
 * History: 
 *   DATE        AUTHOR      DESCRIPTION 
 *  ------------------------------------------------- 
 *  10-April-2013  Nam Dinh    Create new
 * @param resourceRequest
 * @param httpReq
 * @throws NumberFormatException
 * @throws Exception
 */
public static void saveTraoDoiCanBo(ActionRequest resourceRequest, ActionResponse httpReq)
        throws NumberFormatException, Exception {
    // hoso - String
    long idHoSo = FormatUtil.convertToLong(ParamUtil.getString(resourceRequest, "hoSoTTHCCongId"));
    String tieuDe = ParamUtil.getString(resourceRequest, "tieuDe").trim();
    String noiDung = ParamUtil.getString(resourceRequest, "noiDung").trim();
    String type = ParamUtil.getString(resourceRequest, "type").trim();

    long nguoiNhanId = ParamUtil.getLong(resourceRequest, "nguoiNhanId");
    String quayLaiLink = ParamUtil.getString(resourceRequest, "quayLaiLink").trim();

    String loaiCanBo = ParamUtil.getString(resourceRequest, "loaiCanBo");

    if (validatorsYKienTraoDoiCanBo(resourceRequest)) {
        saveYKienTraoDoiCanBoToDB(resourceRequest, httpReq);
        httpReq.setRenderParameter("hoSoTTHCCongId", String.valueOf(idHoSo));
        httpReq.setRenderParameter("type", type);
        httpReq.setRenderParameter("loaiCanBo", String.valueOf(loaiCanBo));
        httpReq.setRenderParameter("jspPage", "/html/cmon/ykientraodoi/danh_sach_y_kien.jsp");

    } else {
        httpReq.setRenderParameter("tieuDe", tieuDe);
        httpReq.setRenderParameter("noiDung", noiDung);
        httpReq.setRenderParameter("type", type);
        httpReq.setRenderParameter("nguoiNhanId", String.valueOf(nguoiNhanId));
        httpReq.setRenderParameter("hoSoTTHCCongId", String.valueOf(idHoSo));
        httpReq.setRenderParameter("quayLaiLink", String.valueOf(quayLaiLink));
        httpReq.setRenderParameter("loaiCanBo", String.valueOf(loaiCanBo));
        httpReq.setRenderParameter("jspPage", "/html/cmon/ykientraodoi/canbo_traodoi_form.jsp");
    }

    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.opencps.sample.department.search.DepartmentSearch.java

License:Open Source License

public DepartmentSearch(PortletRequest portletRequest, int cur, int delta, PortletURL iteratorURL) {

    super(portletRequest, new DepartmentDisplayTerms(portletRequest), new DepartmentSearchTerms(portletRequest),
            DEFAULT_CUR_PARAM, cur, delta, iteratorURL, headerNames, null);

    PortletConfig portletConfig = (PortletConfig) portletRequest
            .getAttribute(JavaConstants.JAVAX_PORTLET_CONFIG);

    DepartmentDisplayTerms displayTerms = (DepartmentDisplayTerms) getDisplayTerms();
    DepartmentSearchTerms searchTerms = (DepartmentSearchTerms) getSearchTerms();

    String portletName = portletConfig.getPortletName();

    iteratorURL.setParameter(DepartmentDisplayTerms.NAME, displayTerms.getName());
    iteratorURL.setParameter(DepartmentDisplayTerms.DESCRIPTION, displayTerms.getDescription());

    iteratorURL.setParameter(DepartmentDisplayTerms.PARENT_ID, String.valueOf(displayTerms.getParentId()));
    iteratorURL.setParameter(DepartmentDisplayTerms.GROUP_ID, String.valueOf(displayTerms.getGroupId()));
    iteratorURL.setParameter(DepartmentDisplayTerms.CREATE_DATE,
            PortletUtil.convertDateToString(displayTerms.getCreateDate(), PortletUtil._VN_DATE_TIME_FORMAT));
    iteratorURL.setParameter(DepartmentDisplayTerms.CREATE_DATE,
            PortletUtil.convertDateToString(displayTerms.getModifiedDate(), PortletUtil._VN_DATE_TIME_FORMAT));
    iteratorURL.setParameter(DepartmentDisplayTerms.USER_NAME, displayTerms.getUserName());

    try {//from  w  w w. ja va2 s. c om
        PortalPreferences preferences = PortletPreferencesFactoryUtil.getPortalPreferences(portletRequest);

        String orderByCol = ParamUtil.getString(portletRequest, "orderByCol");
        String orderByType = ParamUtil.getString(portletRequest, "orderByType");

        if (Validator.isNotNull(orderByCol) && Validator.isNotNull(orderByType)) {

            preferences.setValue(OpenCPSPortletKey.STAFF_MANAGEMENT, "department-order-by-col", orderByCol);
            preferences.setValue(OpenCPSPortletKey.STAFF_MANAGEMENT, "department-order-by-type", orderByType);
        } else {
            orderByCol = preferences.getValue(OpenCPSPortletKey.STAFF_MANAGEMENT, "department-order-by-col",
                    "id");
            orderByType = preferences.getValue(OpenCPSPortletKey.STAFF_MANAGEMENT, "department-order-by-type",
                    "asc");
        }

        OrderByComparator orderByComparator = DepartmentUtil.getDepartmentOrderByComparator(orderByCol,
                orderByType);

        setOrderableHeaders(orderableHeaders);
        setOrderByCol(orderByCol);
        setOrderByType(orderByType);
        setOrderByComparator(orderByComparator);
    } catch (Exception e) {
        _log.error(e);
    }
}

From source file:org.xmlportletfactory.olafk.customer.CustomerPortlet.java

License:Open Source License

public void serveResource(ResourceRequest resourceRequest, ResourceResponse resourceResponse)
        throws PortletException, IOException {
    resourceResponse.setContentType("text/javascript");
    String resourceId = resourceRequest.getResourceID();

    if (Validator.isNotNull(resourceId) && resourceId.length() != 0) {

        if (resourceId.equalsIgnoreCase("exportFullCustomerResourceURL")) {

            ThemeDisplay themeDisplay = (ThemeDisplay) resourceRequest.getAttribute(WebKeys.THEME_DISPLAY);
            Locale locale = themeDisplay.getLocale();
            PortletConfig portletConfig = (PortletConfig) resourceRequest
                    .getAttribute(JavaConstants.JAVAX_PORTLET_CONFIG);

            resourceResponse.setContentType("application/vnd.ms-excel");
            resourceResponse.setProperty("expires", "-1d");
            resourceResponse.setProperty("Pragma", "no-cache");
            resourceResponse.setProperty("Cache-control", "no-cache");
            resourceResponse.addProperty(HttpHeaders.CONTENT_DISPOSITION, "attachment; filename=\" Customer\"");

            try {
                Workbook book = CustomerExporter.generateFullExcel(themeDisplay.getScopeGroupId(),
                        portletConfig, locale);
                OutputStream out = resourceResponse.getPortletOutputStream();
                book.write(out);/*  w  ww . j a  v a2s .  co  m*/
                out.flush();
                out.close();
            } catch (SystemException e) {
                e.printStackTrace();
                throw new PortletException("Export Excel Error", e);
            }
        }

    }
}

From source file:org.xmlportletfactory.olafk.customer.InvoicesPortlet.java

License:Open Source License

public void serveResource(ResourceRequest resourceRequest, ResourceResponse resourceResponse)
        throws PortletException, IOException {
    resourceResponse.setContentType("text/javascript");
    String resourceId = resourceRequest.getResourceID();

    if (Validator.isNotNull(resourceId) && resourceId.length() != 0) {

        if (resourceId.equalsIgnoreCase("exportFullInvoicesResourceURL")) {

            ThemeDisplay themeDisplay = (ThemeDisplay) resourceRequest.getAttribute(WebKeys.THEME_DISPLAY);
            Locale locale = themeDisplay.getLocale();
            PortletConfig portletConfig = (PortletConfig) resourceRequest
                    .getAttribute(JavaConstants.JAVAX_PORTLET_CONFIG);

            resourceResponse.setContentType("application/vnd.ms-excel");
            resourceResponse.setProperty("expires", "-1d");
            resourceResponse.setProperty("Pragma", "no-cache");
            resourceResponse.setProperty("Cache-control", "no-cache");
            resourceResponse.addProperty(HttpHeaders.CONTENT_DISPOSITION, "attachment; filename=\" Invoices\"");

            try {
                Workbook book = InvoicesExporter.generateFullExcel(themeDisplay.getScopeGroupId(),
                        portletConfig, locale);
                OutputStream out = resourceResponse.getPortletOutputStream();
                book.write(out);//ww w.j  ava  2s . com
                out.flush();
                out.close();
            } catch (SystemException e) {
                e.printStackTrace();
                throw new PortletException("Export Excel Error", e);
            }
        }

    }
}