List of usage examples for com.liferay.portal.kernel.servlet SessionMessages add
public static void add(PortletRequest portletRequest, String key)
From source file:org.oep.cmon.ttthanhtoan.portlet.action.ThongTinThanhToanPortlet.java
License:Apache License
/** * This is function xacNhanNopTien/*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 actionRequest * @param actionResponse * @throws Exception */ public void xacNhanNopTien(ActionRequest actionRequest, ActionResponse actionResponse) { try { Long hoSoTTHCCongId = ParamUtil.getLong(actionRequest, "hoSoTTHCCongId"); // HoSoTTHCCong hoSoTTHCCong = HoSoTTHCCongLocalServiceUtil.getHoSoTTHCCong(hoSoTTHCCongId); Long thongTinThanhToanId = ParamUtil.getLong(actionRequest, "thongTinThanhToanId"); Long typePhi = ParamUtil.getLong(actionRequest, "typePhi"); Long loaiThanhToan = ParamUtil.getLong(actionRequest, "loaithanhtoan"); ThongTinThanhToan thongTinThanhToan = null; boolean isNew = false; if (thongTinThanhToanId == null || thongTinThanhToanId == 0) { thongTinThanhToan = new ThongTinThanhToanClp(); thongTinThanhToanId = CounterLocalServiceUtil.increment(ThongTinThanhToan.class.getName()); thongTinThanhToan.setId(thongTinThanhToanId); thongTinThanhToan.setHoSoTTHCCongId(hoSoTTHCCongId); thongTinThanhToan.setLoaiPhi(typePhi); // thongTinThanhToan.setLoaiThanhToan(loaiThanhToan); thongTinThanhToan.setNguoiTao(PortalUtil.getUser(actionRequest).getFullName()); thongTinThanhToan.setNgayTao(new Date()); thongTinThanhToan.setNgayThuTien(new Date()); isNew = true; } else { thongTinThanhToan = ThongTinThanhToanLocalServiceUtil.getThongTinThanhToan(thongTinThanhToanId); } // set loai thanh toan thongTinThanhToan.setLoaiThanhToan(loaiThanhToan); // Set "nguoi nop tien" String tenNguoiNopTien = ParamUtil.getString(actionRequest, "nguoinoptien"); if (tenNguoiNopTien != null || !"".equals(tenNguoiNopTien)) { thongTinThanhToan.setTenNguoiNopTien(tenNguoiNopTien); } // Set "ngay thu tien" Date ngayThuTien = ParamUtil.getDate(actionRequest, "ngaythutien", dateType); if (ngayThuTien == null) { thongTinThanhToan.setNgayThuTien(ngayThuTien); } // Set "can bo xac nhan" thongTinThanhToan.setTenCanBoNhanTien(ParamUtil.getString(actionRequest, "canboxacnhan")); // Set "so tien" if (ParamUtil.getLong(actionRequest, "sotien") > 0) { thongTinThanhToan.setSoTien(ParamUtil.getLong(actionRequest, "sotien")); } // Set "xac nhan" Integer xacNhan = ParamUtil.getInteger(actionRequest, "xacnhan"); if (actionRequest.getParameter("xacnhan") == null) { // mark da xac nhan: handle for "nop tien mat" xacNhan = 1; } thongTinThanhToan.setXacNhan(xacNhan); // Set "ngay xac nhan" Date ngayXacNhan = ParamUtil.getDate(actionRequest, "ngayxacnhan", dateType); if (ngayXacNhan == null) { ngayXacNhan = new Date(); } thongTinThanhToan.setNgayXacNhan(ngayXacNhan); // Set "Y kien" if (ParamUtil.getString(actionRequest, "ykien") != null || !"".equals(ParamUtil.getString(actionRequest, "ykien"))) { thongTinThanhToan.setYKien(ParamUtil.getString(actionRequest, "ykien")); } // add new record if (isNew) { ThongTinThanhToanLocalServiceUtil.addThongTinThanhToan(thongTinThanhToan); } else { // update data ThongTinThanhToanLocalServiceUtil.updateThongTinThanhToan(thongTinThanhToan); } // response data actionResponse.setRenderParameter("hoSoTTHCCongId", hoSoTTHCCongId.toString()); actionResponse.setRenderParameter("thongTinThanhToanId", thongTinThanhToanId.toString()); actionResponse.setRenderParameter("typePhi", typePhi.toString()); SessionMessages.add(actionRequest, "successUpdateTTTK"); actionResponse.setRenderParameter("parentUrl", ParamUtil.getString(actionRequest, "parentUrl")); // set status submit's ok actionResponse.setRenderParameter("submitStatus", "1"); actionResponse.setRenderParameter("jspPage", ParamUtil.getString(actionRequest, "targetPage")); } catch (Exception e) { e.printStackTrace(); SessionErrors.add(actionRequest, "errorUpdateTTTK"); actionResponse.setRenderParameter("jspPage", ParamUtil.getString(actionRequest, "targetPage")); } }
From source file:org.oep.cmon.user.portlet.action.UserEndorsePortlet.java
License:Apache License
/** * This is function Citizen endorsement/*from w w w .j a v a 2 s . co 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.user.portlet.action.UserEndorsePortlet.java
License:Apache License
/** * This is function huyDangKy/*from w w w . ja v a 2s .c om*/ * Version: 1.0 * * History: * DATE AUTHOR DESCRIPTION * ------------------------------------------------- * 3-March-2013 Nam Dinh Create new * @param actionRequest * @param actionResponse * @throws Exception */ public void huyDangKy(ActionRequest actionRequest, ActionResponse actionResponse) throws Exception { try { // Update yeu cau dang ky to DB Map<String, String> userRequest = (Map<String, String>) actionRequest.getPortletSession() .getAttribute("USER_REQUEST_OBJECT"); long reqId = 0; if (userRequest != null && !userRequest.isEmpty()) { reqId = Long.parseLong(userRequest.get("ID")); } if (reqId == 0) { reqId = ParamUtil.getLong(actionRequest, "yeuCauId"); } YeuCauDangKyCongDan yeuCau = YeuCauDangKyCongDanLocalServiceUtil.fetchYeuCauDangKyCongDan(reqId); yeuCau.setXoa(1); yeuCau = YeuCauDangKyCongDanLocalServiceUtil.updateYeuCauDangKyCongDan(yeuCau); EndorsementBs endorse = new EndorsementBs(actionRequest); String portalUrl = PortalUtil.getPortalURL(actionRequest); endorse.sendEmailHuyDK(yeuCau.getHoVaTen(), yeuCau.getEmail(), portalUrl, actionRequest); actionRequest.getPortletSession().removeAttribute("USER_REQUEST_OBJECT"); actionRequest.setAttribute("huySuccess", "huySuccess"); SessionMessages.add(actionRequest, "huySuccess"); } catch (Exception e) { actionRequest.setAttribute("endorseError", "endorseError"); SessionMessages.add(actionRequest, "endorseError"); e.printStackTrace(); } }
From source file:org.oep.cmon.user.portlet.action.UserEndorsePortlet.java
License:Apache License
/** * This is function endorseInList/*w w w . ja v a 2 s.c om*/ * Version: 1.0 * * History: * DATE AUTHOR DESCRIPTION * ------------------------------------------------- * 3-March-2013 Nam Dinh Create new * @param actionRequest * @param actionResponse * @throws Exception */ public void endorseInList(ActionRequest actionRequest, ActionResponse actionResponse) throws Exception { long yeuCauId = ParamUtil.getLong(actionRequest, "yeuCauId"); YeuCauDangKyCongDan yeuCau = YeuCauDangKyCongDanLocalServiceUtil.fetchYeuCauDangKyCongDan(yeuCauId); try { // Generate random password for user String password = AuthenticateCodeUtil.generateAuthCode().toLowerCase().trim(); EndorsementBs endorse = new EndorsementBs(actionRequest); // update yeucau yeuCau.setTrangThaiYeuCau(StringUtil.TRANG_THAI_YEU_CAU_DK_CONG_DAN_DA_CHUNG_THUC); // Endorsed YeuCauDangKyCongDanLocalServiceUtil.updateYeuCauDangKyCongDan(yeuCau); String ho = yeuCau.getHoCongDan(); String dem = yeuCau.getTenDem(); String ten = yeuCau.getTenCongDan(); String email = yeuCau.getEmail(); String fullName = ho + StringPool.SPACE + dem + StringPool.SPACE + ten; TaiKhoanNguoiDung taiKhoan = TaiKhoanNguoiDungLocalServiceUtil.findByTenDangNhap(email); if (taiKhoan != null) { SessionMessages.add(actionRequest, "emailDuplicate"); return; } // Create portal user long userId = endorse.createPortalCitizenUser(yeuCau, password); String maCongDan = endorse.citizenExists(ho, dem, ten, yeuCau.getSoCmnd(), ConvertUtil.parseDateToTring(yeuCau.getNgaySinh())); // 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); actionRequest.setAttribute("endorseSuccess", "endorseSuccess"); SessionMessages.add(actionRequest, "endorseSuccess"); } catch (Exception ex) { actionRequest.setAttribute("endorseError", "endorseError"); SessionMessages.add(actionRequest, "endorseError"); ex.printStackTrace(); } }
From source file:org.oep.cmon.userreg.portlet.action.UserRegActionPortlet.java
License:Apache License
/** * This is function input basic information * Version: 1.0/*from ww w.j a v a 2s . 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 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 w w w . j a v a 2 s .co 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//from w w w. j a v a 2 s. c o m * * 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 . j a va 2 s. c o 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 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//from w ww.j ava 2 s . c o 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.oep.core.logging.action.UserActivityAction.java
License:Apache License
public void deactivateUser(ActionRequest actionRequest, ActionResponse actionResponse) throws IOException, PortletException { long userId = ParamUtil.getLong(actionRequest, "userId"); try {/*from w w w .jav a 2s.c om*/ UserLocalServiceUtil.updateStatus(userId, WorkflowConstants.STATUS_INACTIVE); SessionMessages.add(actionRequest, "org.oep.useractivity.success.deactive"); } catch (Exception e) { SessionErrors.add(actionRequest, "org.oep.useractivity.error.operation.fail"); } actionResponse.sendRedirect(ParamUtil.getString(actionRequest, PortletKeys.REDIRECT_PAGE)); }