List of usage examples for com.liferay.portal.kernel.servlet SessionErrors isEmpty
public static boolean isEmpty(PortletRequest portletRequest)
From source file:org.oep.cmon.admin.portlet.action.TaiKhoanNguoiDungAction.java
License:Apache License
/** * This is function add or edit TaiKhoanNguoiDung * Version: 1.0//ww w.java 2s . c o m * * History: * DATE AUTHOR DESCRIPTION * ------------------------------------------------- * 3-March-2013 Nam Dinh Create new * @param actionRequest * @param actionResponse * @throws Exception */ public void addEditTaiKhoanNguoiDung(ActionRequest actionRequest, ActionResponse actionResponse) throws Exception { // Get the required parameters // Action mode (0: Insert, 1: Edit); int mode = ParamUtil.getInteger(actionRequest, "mode"); Map<String, String> userRequest = (Map<String, String>) actionRequest.getPortletSession() .getAttribute("USER_REQUEST_TKND_OBJECT"); if (userRequest == null) { userRequest = new HashMap<String, String>(); } String email = ParamUtil.getString(actionRequest, "email").trim(); userRequest.put("email", email); // We use email as login name as well String loginName = email;// ParamUtil.getString(actionRequest, "loginName").trim(); userRequest.put("loginName", loginName); String fullName = ParamUtil.getString(actionRequest, "fullName").trim(); userRequest.put("fullName", fullName); String password = ParamUtil.getString(actionRequest, "password").trim(); userRequest.put("password", password); String trangThai = ParamUtil.getString(actionRequest, "trangThai").trim(); userRequest.put("trangThai", trangThai); String loaiDoiTuong = ParamUtil.getString(actionRequest, "loaiDoiTuong").trim(); userRequest.put("loaiDoiTuong", loaiDoiTuong); String liferayID = ParamUtil.getString(actionRequest, "liferayID").trim(); userRequest.put("TaiKhoanLiferayID", liferayID); // String coQuanQuanLy = ParamUtil.getString(actionRequest, "coQuanQuanLy").trim(); // userRequest.put("coQuanQuanLy", coQuanQuanLy); // Validate parameteter // Set the data back to session actionRequest.getPortletSession().setAttribute("USER_REQUEST_TKND_OBJECT", userRequest); // Check login name if (Validator.isNull(loginName)) { SessionErrors.add(actionRequest, "vn.dtt.cmon.admin.form.add_edit_taikhoannguoidung.err.loginName"); } // Check full name if (Validator.isNull(fullName)) { SessionErrors.add(actionRequest, "vn.dtt.cmon.admin.form.add_edit_taikhoannguoidung.err.fullName"); } // Check password if (mode == INSERT_MODE && Validator.isNull(password)) { SessionErrors.add(actionRequest, "vn.dtt.cmon.admin.form.add_edit_taikhoannguoidung.err.password"); } // Check email if (Validator.isNull(email)) { SessionErrors.add(actionRequest, "vn.dtt.cmon.admin.form.add_edit_taikhoannguoidung.err.email"); } if (Validator.isNotNull(email) && !Validator.isEmailAddress(email)) { SessionErrors.add(actionRequest, "vn.dtt.cmon.admin.form.add_edit_taikhoannguoidung.err.emailNotValid"); } // Check co quan quan ly // if (Validator.isNull(coQuanQuanLy)) { // SessionErrors.add(actionRequest, "vn.dtt.cmon.admin.form.add_edit_taikhoannguoidung.err.coQuanQuanLy"); // } // Check duplicate information if (mode == INSERT_MODE) { if (Validator.isNotNull(loginName)) { TaiKhoanNguoiDung taiKhoan = TaiKhoanNguoiDungLocalServiceUtil.findByTenDangNhap(loginName); if (taiKhoan != null) { SessionErrors.add(actionRequest, "vn.dtt.cmon.admin.form.add_edit_taikhoannguoidung.err.duplicateLoginName"); } } // Check duplicate email List<TaiKhoanNguoiDung> lst = TaiKhoanNguoiDungLocalServiceUtil.findByEmail(email); if (lst.size() > 0) { SessionErrors.add(actionRequest, "vn.dtt.cmon.admin.form.add_edit_taikhoannguoidung.err.duplicateEmail"); } } else { // Get the id long id = Long.parseLong(userRequest.get("id")); if (Validator.isNotNull(loginName)) { TaiKhoanNguoiDung taiKhoan = TaiKhoanNguoiDungLocalServiceUtil.findByTenDangNhap(loginName); if (taiKhoan != null) { // Check if the login name to be updated is already owned by another if (taiKhoan.getId() != id) { SessionErrors.add(actionRequest, "vn.dtt.cmon.admin.form.add_edit_taikhoannguoidung.err.duplicateLoginName"); } } } // Check duplicate email List<TaiKhoanNguoiDung> lst = TaiKhoanNguoiDungLocalServiceUtil.findByEmail(email); if (lst.size() > 0) { // Get the first object in the list TaiKhoanNguoiDung obj = lst.get(0); // Check if the email to be updated is already owned by another if (obj.getId() != id) { SessionErrors.add(actionRequest, "vn.dtt.cmon.admin.form.add_edit_taikhoannguoidung.err.duplicateEmail"); } } } // Redirect String redirectUrl = ParamUtil.getString(actionRequest, "redirectUrl"); if (!SessionErrors.isEmpty(actionRequest)) { actionResponse.sendRedirect(redirectUrl); return; } TaiKhoanNguoiDungBusiness taiKhoanNguoiDungBs = new TaiKhoanNguoiDungBusiness(); TaiKhoanNguoiDung nguoiDung = taiKhoanNguoiDungBs.toEntity(mode, userRequest, actionRequest); long userId = 0; if (nguoiDung.getTrangThai() != 0) { // Create user on LDAP server //remove add user to ldap by liemnn /*boolean status = taiKhoanNguoiDungBs.createUserOnLDAP(nguoiDung.getEmail(), EncryptionUtil.decrypt(nguoiDung.getMatKhau()), nguoiDung.getTenNguoiDung()); if (!status) { SessionErrors.add(actionRequest, "vn.dtt.cmon.admin.form.add_edit_taikhoannguoidung.err.ldap"); actionResponse.sendRedirect(redirectUrl); return; } */ // Create portal user try { userId = taiKhoanNguoiDungBs.createPortalUser(nguoiDung, actionRequest); } catch (Exception es) { es.printStackTrace(); } } // Insert/updatye record here if (mode == INSERT_MODE) { try { new TaiKhoanNguoiDungBusiness().insert(nguoiDung, userId, actionRequest); } catch (Exception e) { e.printStackTrace(); SessionErrors.add(actionRequest, "vn.dtt.cmon.admin.form.add_edit_coquanquanly.err.unKnown"); // Redirect to error page actionResponse.setRenderParameter("jspPage", "/html/portlet/admin/err_page.jsp"); return; } } else { try { if (ConvertUtil.convertToLong(liferayID) > 0) { nguoiDung.setTaiKhoanNguoiDungId(ConvertUtil.convertToLong(liferayID)); } new TaiKhoanNguoiDungBusiness().edit(nguoiDung, EncryptionUtil.encrypt(password), actionRequest); } catch (Exception e) { e.printStackTrace(); SessionErrors.add(actionRequest, "vn.dtt.cmon.admin.form.add_edit_coquanquanly.err.unKnown"); // Redirect to error page actionResponse.setRenderParameter("jspPage", "/html/portlet/admin/err_page.jsp"); return; } } // Remove attribute actionRequest.getPortletSession().removeAttribute("USER_REQUEST_TKND_OBJECT"); // Redirect user if (mode == INSERT_MODE) { // Add success message SessionMessages.add(actionRequest, "success"); actionResponse.sendRedirect(redirectUrl); } else { // Redirect to search screen Map<String, String> searchParam = (Map<String, String>) actionRequest.getPortletSession() .getAttribute("SEARCH_TAI_KHOAN_NGUOI_DUNG_PARAMS"); String searchOption = searchParam.get("searchOption"); String keyWord = searchParam.get("keyWord"); // Do the search this.searchTaiKhoanNguoiDung(searchOption, keyWord, actionRequest, actionResponse); } }
From source file:org.oep.cmon.admin.portlet.action.VaiTroAction.java
License:Apache License
/** * This is function validation input/*from ww w .j a v a 2 s .c om*/ * Version: 1.0 * * History: * DATE AUTHOR DESCRIPTION * ------------------------------------------------- * 3-March-2013 Nam Dinh Create new * @param tenDoiTuongSuDung * @param doiTuongSuDungId * @param actionRequest * @param maDoiTuongSuDung * @return boolean */ private boolean validationInput(String tenDoiTuongSuDung, String doiTuongSuDungId, String maDoiTuongSuDung, ActionRequest actionRequest) { if (maDoiTuongSuDung.trim().length() == 0) { SessionErrors.add(actionRequest, "emptyMaVaiTro"); } if (tenDoiTuongSuDung.trim().length() == 0) { SessionErrors.add(actionRequest, "emptyTenVaiTro"); } // Neu thong tin nhap khac rong if (SessionErrors.isEmpty(actionRequest)) { VaiTro doiTuongSuDung = null; try { // Kiem tra theo Ma try { doiTuongSuDung = null; doiTuongSuDung = VaiTroLocalServiceUtil.findTheoMa(maDoiTuongSuDung); } catch (Exception es) { } if (doiTuongSuDung != null) { if (doiTuongSuDung.getDaXoa() == SetParamUtil.DA_XOA_DEACTIVATE) { return true; } if (doiTuongSuDungId.trim().length() > 0) { if (ConvertUtil.convertToLong(doiTuongSuDungId) != doiTuongSuDung.getId()) { SessionErrors.add(actionRequest, "exitMaVaiTro"); } } else { SessionErrors.add(actionRequest, "exitMaVaiTro"); } } // Kiem tra theo Ten // try { // doiTuongSuDung = null; // doiTuongSuDung = VaiTroLocalServiceUtil.findTheoTen(tenDoiTuongSuDung); // } catch (Exception es) { // } // if (doiTuongSuDung != null) { // if (doiTuongSuDungId.trim().length() > 0) { // if (ConvertUtil.convertToLong(doiTuongSuDungId) != doiTuongSuDung.getId()) { // SessionErrors.add(actionRequest, "exitTenVaiTro"); // } // } else { // SessionErrors.add(actionRequest, "exitTenVaiTro"); // } // } } catch (Exception es) { } } if (SessionErrors.isEmpty(actionRequest)) { return true; } return false; }
From source file:org.oep.cmon.czprofile.portlet.action.CitizenProfileActionPortlet.java
License:Apache License
/** * This is function change password// www .j a v a 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 changePassword(ActionRequest actionRequest, ActionResponse actionResponse) throws Exception { Map<String, String> userRequest = (Map<String, String>) actionRequest.getPortletSession() .getAttribute("USER_REQUEST_OBJECT"); actionRequest.getPortletSession().setAttribute("change_pass", "tab.czprofile.changepass"); // String oldPassword = ParamUtil.getString(actionRequest, "oldPassword").trim(); // userRequest.put("oldPassword", oldPassword); // String newPassword = ParamUtil.getString(actionRequest, "newPassword").trim(); userRequest.put("newPassword", newPassword); String confirmPassword = ParamUtil.getString(actionRequest, "confirmPassword").trim(); userRequest.put("confirmPassword", confirmPassword); User currentUser = PortalUtil.getUser(actionRequest); String redirectUrl = ParamUtil.getString(actionRequest, "redirectUrl"); if (currentUser == null) { SessionErrors.add(actionRequest, "vn.dtt.cmon.czprofile.form.input.err.notLogin"); actionResponse.sendRedirect(redirectUrl); return; } // Validate params // Old password // if (Validator.isNull(oldPassword)) { // SessionErrors.add(actionRequest, "vn.dtt.cmon.czprofile.form.input.err.oldPassword"); // } // New password if (Validator.isNull(newPassword)) { SessionErrors.add(actionRequest, "vn.dtt.cmon.czprofile.form.input.err.newPassword"); } // Confirm password if (Validator.isNull(confirmPassword)) { SessionErrors.add(actionRequest, "vn.dtt.cmon.czprofile.form.input.err.confirmPassword"); } // New pass and confirm pass if (!newPassword.equals(confirmPassword)) { SessionErrors.add(actionRequest, "vn.dtt.cmon.czprofile.form.input.err.oldPassAndNewPass"); } // Check new password and old password long userId = currentUser.getUserId(); // Get tai khoan nguoi dung from liferay TaiKhoanNguoiDung taiKhoan = TaiKhoanNguoiDungLocalServiceUtil.findByTaiKhoanNguoiDungId(userId); // Get the old password String oldDbPassword = taiKhoan.getMatKhau(); // String newEncryptPassword = EncryptionUtil.encrypt(newPassword); // if (oldDbPassword.equals(newEncryptPassword)) { SessionErrors.add(actionRequest, "vn.dtt.cmon.czprofile.form.input.err.newPassSameOldPass"); } // Check old password correct or not if (!SessionErrors.isEmpty(actionRequest)) { actionResponse.sendRedirect(redirectUrl); return; } // TaiKhoanNguoiDungBusiness taiKhoanNguoiDungBs = new TaiKhoanNguoiDungBusiness(); // Create user on LDAP server // if ( ! taiKhoanNguoiDungBs.createUserOnLDAP(taiKhoan.getEmail(), newPassword, taiKhoan.getTenNguoiDung())) { // SessionErrors.add(actionRequest, "vn.dtt.cmon.czprofile.form.input.err.ldap"); // // actionResponse.sendRedirect(redirectUrl); // // return; // } // Update portal user password UserLocalServiceUtil.updatePassword(userId, newPassword, newPassword, false); // Update tai khoan nguoi dung taiKhoan.setMatKhau(newEncryptPassword); TaiKhoanNguoiDungLocalServiceUtil.updateTaiKhoanNguoiDung(taiKhoan); // Remove attribute actionRequest.getPortletSession().removeAttribute("USER_REQUEST_OBJECT"); // Redirect SessionMessages.add(actionRequest, "success"); actionResponse.sendRedirect(redirectUrl); }
From source file:org.oep.cmon.czprofile.portlet.action.CitizenProfileActionPortlet.java
License:Apache License
/** * This is function update detail//from www . j ava2 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 updateDetail(ActionRequest actionRequest, ActionResponse actionResponse) throws Exception { Map<String, String> userRequest = (Map<String, String>) actionRequest.getPortletSession() .getAttribute("USER_REQUEST_OBJECT"); // Get all parameters from request String id = ParamUtil.getString(actionRequest, "id").trim(); if (Validator.isNotNull(id)) { userRequest.put("id", id); } /*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 ghiChuCmnd = ParamUtil.getString(actionRequest, "ghiChuCmnd").trim(); userRequest.put("GHICHUCMND", ghiChuCmnd);*/ String ngayHetHanHoChieuStr = ParamUtil.getString(actionRequest, "ngayHetHanHoChieu"); userRequest.put("NGAYHETHANHOCHIEU", ngayHetHanHoChieuStr); /* 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 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 tinhTrangHonNhan = ParamUtil.getString(actionRequest, "tinhTrangHonNhan"); if (Validator.isNotNull(tinhTrangHonNhan)) { userRequest.put("IDTINHTRANGHONNHAN", tinhTrangHonNhan); } String motaDiachiHienTai = ParamUtil.getString(actionRequest, "motaDiachiHienTai").trim(); userRequest.put("MOTADIACHIHIENTAI", motaDiachiHienTai); // 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); // validate data // Check noi cap cmnd if (Validator.isNull(noiCapCmnd)) { SessionErrors.add(actionRequest, "vn.dtt.cmon.userreg.form.input.err.noiCapCmnd"); } // Check gioi tinh if (Validator.isNull(gioiTinh)) { SessionErrors.add(actionRequest, "vn.dtt.cmon.userreg.form.input.err.gioiTinh"); } // Check tinh trang hon nhan if (Validator.isNull(tinhTrangHonNhan)) { SessionErrors.add(actionRequest, "vn.dtt.cmon.userreg.form.input.err.tinhTrangHonNhan"); } // Check mo ta dia chi hien tai // if (Validator.isNull(motaDiachiHienTai)) { // SessionErrors.add(actionRequest, "vn.dtt.cmon.userreg.form.input.err.motaDiachiHienTai"); // } // Validate ngayHetHanHoChieu Date ngayHetHanHoChieu = null; if (ngayHetHanHoChieuStr != null && !"".equals(ngayHetHanHoChieuStr)) { DateFormat df = new SimpleDateFormat(DATE_FORMAT); df.setLenient(false); try { ngayHetHanHoChieu = df.parse(ngayHetHanHoChieuStr); } catch (Exception e) { SessionErrors.add(actionRequest, "vn.dtt.cmon.userreg.form.input.err.ngayHetHanHoChieu.notValid"); } } // In case there's error String redirectUrl = ParamUtil.getString(actionRequest, "redirectUrl"); if (!SessionErrors.isEmpty(actionRequest)) { actionResponse.sendRedirect(redirectUrl); return; } User currentUser = PortalUtil.getUser(actionRequest); if (currentUser == null) { SessionErrors.add(actionRequest, "vn.dtt.cmon.czprofile.form.input.err.notLogin"); actionResponse.sendRedirect(redirectUrl); return; } CongDan citizen = CongDanLocalServiceUtil.fetchCongDan(Long.parseLong(id)); if (citizen == null) { SessionErrors.add(actionRequest, "vn.dtt.cmon.czprofile.form.input.err.notExist"); actionResponse.sendRedirect(redirectUrl); return; } // Update citizen citizen.setTrinhDoHocVanId(Long.parseLong(trinhDoHocVan)); citizen.setTinhTrangHonNhanId(Long.parseLong(tinhTrangHonNhan)); citizen.setNoiCapCmndId(Long.parseLong(noiCapCmnd)); citizen.setGioiTinh(Integer.parseInt(gioiTinh)); citizen.setDiaChiHienNay(motaDiachiHienTai); citizen.setNgayHetHanHoChieu(ngayHetHanHoChieu); citizen.setSoBaoHiemYTe(soBhyt); CongDanLocalServiceUtil.updateCongDan(citizen); // Remove attribute actionRequest.getPortletSession().removeAttribute("USER_REQUEST_OBJECT"); // Redirect SessionMessages.add(actionRequest, "success"); actionResponse.sendRedirect(redirectUrl); }
From source file:org.oep.cmon.czprofile.portlet.action.CitizenProfileActionPortlet.java
License:Apache License
/** * This is function update CongChuc detail * Version: 1.0// w ww. j a va 2 s. c om * * History: * DATE AUTHOR DESCRIPTION * ------------------------------------------------- * 3-March-2013 Nam Dinh Create new * @param actionRequest * @param actionResponse * @throws Exception */ public void updateCongChucDetail(ActionRequest actionRequest, ActionResponse actionResponse) throws Exception { Map<String, String> userRequest = (Map<String, String>) actionRequest.getPortletSession() .getAttribute("USER_REQUEST_OBJECT"); // Get all parameters from request String id = ParamUtil.getString(actionRequest, "id").trim(); _log.info("======= cong dan Id = " + String.valueOf(id)); if (Validator.isNotNull(id)) { userRequest.put("id", id); } String tenDaydu = ParamUtil.getString(actionRequest, "tenDaydu").trim(); _log.info("======= tenDaydu = " + tenDaydu); if (Validator.isNotNull(tenDaydu)) { userRequest.put("tenDaydu", tenDaydu); } String ngaySinh = ParamUtil.getString(actionRequest, "ngaySinh"); _log.info("======= ngaySinh = " + ngaySinh); userRequest.put("ngaySinh", ngaySinh); String gioiTinh = ParamUtil.getString(actionRequest, "gioiTinh"); _log.info("======= gioiTinh = " + String.valueOf(gioiTinh)); if (Validator.isNotNull(gioiTinh)) { userRequest.put("gioiTinh", gioiTinh); } String soCmnd = ParamUtil.getString(actionRequest, "soCmnd").trim(); _log.info("======= soCmnd = " + soCmnd); if (Validator.isNotNull(tenDaydu)) { userRequest.put("soCmnd", soCmnd); } String ngayCapCmnd = ParamUtil.getString(actionRequest, "ngayCapCmnd"); _log.info("======= ngayCapCmnd = " + String.valueOf(ngayCapCmnd)); userRequest.put("ngayCapCmnd", ngayCapCmnd); String noiCapCmnd = ParamUtil.getString(actionRequest, "noiCapCmnd").trim(); _log.info("======= noiCapCmnd = " + String.valueOf(noiCapCmnd)); if (Validator.isNotNull(noiCapCmnd)) { userRequest.put("noiCapCmnd", noiCapCmnd); } // 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); boolean isValid = validationInput(tenDaydu, ngaySinh, soCmnd, ngayCapCmnd, noiCapCmnd, actionRequest); // In case there's error String redirectUrl = ParamUtil.getString(actionRequest, "redirectUrl"); if (!isValid && !SessionErrors.isEmpty(actionRequest)) { actionResponse.sendRedirect(redirectUrl); return; } User currentUser = PortalUtil.getUser(actionRequest); if (currentUser == null) { SessionErrors.add(actionRequest, "vn.dtt.cmon.czprofile.form.input.err.notLogin"); actionResponse.sendRedirect(redirectUrl); return; } CongChuc congChuc = CongChucLocalServiceUtil.getCongChuc(Long.parseLong(id)); _log.info("======= congChuc info = " + congChuc); if (congChuc == null) { SessionErrors.add(actionRequest, "vn.dtt.cmon.czprofile.form.input.err.notExist"); actionResponse.sendRedirect(redirectUrl); return; } // Update cong chuc; congChuc.setHoVaTen(tenDaydu); //congChuc.setNoiCapCmndId(Long.parseLong(noiCapCmnd)); congChuc.setNgaySinh(ConvertUtil.parseStringToDate(ngaySinh)); congChuc.setGioiTinhId(Integer.parseInt(gioiTinh)); congChuc.setSoCmnd(soCmnd); congChuc.setNgayCapCmnd(ConvertUtil.parseStringToDate(ngayCapCmnd)); congChuc.setNoiCapCmnd(noiCapCmnd); _log.info("======= congChuc info update: = " + congChuc); CongChucLocalServiceUtil.updateCongChuc(congChuc); // Remove attribute actionRequest.getPortletSession().removeAttribute("USER_REQUEST_OBJECT"); // Redirect SessionMessages.add(actionRequest, "success"); actionResponse.sendRedirect(redirectUrl); }
From source file:org.oep.cmon.czprofile.portlet.action.CitizenProfileActionPortlet.java
License:Apache License
/** * This is function validation input//from w w w .j a va 2s .c o m * Version: 1.0 * * History: * DATE AUTHOR DESCRIPTION * ------------------------------------------------- * 3-March-2013 Nam Dinh Create new * @param tenDaydu * @param ngaySinh * @param soCmnd * @param ngayCapCmnd * @param noiCapCmnd * @param actionRequest */ private boolean validationInput(String tenDaydu, String ngaySinh, String soCmnd, String ngayCapCmnd, String noiCapCmnd, ActionRequest actionRequest) { // validate data // Check Ho va ten if (Validator.isNull(tenDaydu)) { SessionErrors.add(actionRequest, "vn.dtt.cmon.czprofile.form.canbo.input.ten.empty"); } if (Validator.isNull(ngaySinh)) { SessionErrors.add(actionRequest, "vn.dtt.cmon.czprofile.form.canbo.input.ngaysinh.empty"); } // Validate ngaySinh Date ngaySinhDt = null; if (ngaySinh != null && !"".equals(ngaySinh)) { DateFormat df = new SimpleDateFormat(DATE_FORMAT); df.setLenient(false); try { ngaySinhDt = df.parse(ngaySinh); } catch (Exception e) { SessionErrors.add(actionRequest, "vn.dtt.cmon.czprofile.form.canbo.input.ngaysinh.invalid"); } } soCmnd = soCmnd.trim(); //String strLeng=String.valueOf(soCmnd.length()); // Check So cmnd if (Validator.isNull(soCmnd)) { SessionErrors.add(actionRequest, "vn.dtt.cmon.czprofile.form.canbo.input.socmnd.empty"); } if ((soCmnd.length() < 9) || (soCmnd.length() > 12)) { SessionErrors.add(actionRequest, "vn.dtt.cmon.czprofile.form.canbo.input.socmnd.invalid"); } if (Validator.isNull(ngayCapCmnd)) { SessionErrors.add(actionRequest, "vn.dtt.cmon.czprofile.form.canbo.input.ngaycap.empty"); } // Validate ngayCCmapnd Date ngayCapCmndDt = null; if (ngayCapCmnd != null && !"".equals(ngayCapCmnd)) { DateFormat df = new SimpleDateFormat(DATE_FORMAT); df.setLenient(false); try { ngayCapCmndDt = df.parse(ngayCapCmnd); } catch (Exception e) { SessionErrors.add(actionRequest, "vn.dtt.cmon.czprofile.form.canbo.input.ngaycap.invalid"); } } // Check noi cap cmnd if (Validator.isNull(noiCapCmnd)) { SessionErrors.add(actionRequest, "vn.dtt.cmon.czprofile.form.canbo.input.noicap.empty"); } if (SessionErrors.isEmpty(actionRequest)) { return true; } return false; }
From source file:org.oep.cmon.portlet.doanhnghiep.quanlytaikhoan.utils.Validators.java
License:Apache License
public static boolean validationInput(ActionRequest request, int mode) { String emailDN = request.getParameter("emailDN"); //Thng tin nguoi dai dien String hoTenNDD = request.getParameter("hoTenNDD"); String ngaySinhNDD = request.getParameter("ngaySinhNDD"); String gioiTinhNDD = request.getParameter("gioiTinhNDD"); String quocTichNDD = request.getParameter("quocTichNDD"); String danTocNDD = request.getParameter("danTocNDD"); String soCMNDNDD = request.getParameter("soCMNDNDD"); String ngayCapCMNDNDD = request.getParameter("ngayCapCMNDNDD"); String noiCapCMNDNDD = request.getParameter("noiCapCMNDNDD"); //Dia chi thuong tru String tinhTTNDD = request.getParameter("tinhTTNDD"); String huyenTTNDD = request.getParameter("huyenTTNDD"); String xaTTNDD = request.getParameter("xaTTNDD"); String moTaTTNDD = request.getParameter("moTaTTNDD"); //Dia chi hien tai String tinhHTNDD = request.getParameter("tinhHTNDD"); String huyenHTNDD = request.getParameter("huyenHTNDD"); String xaHTNDD = request.getParameter("xaHTNDD"); String moTaHTNDD = request.getParameter("moTaHTNDD"); //Ko validator String dienThoaiNDD = request.getParameter("dienThoaiNDD"); String faxNDD = request.getParameter("faxNDD"); String emailNDD = request.getParameter("emailNDD"); String websiteNDD = request.getParameter("websiteNDD"); //End/*from w ww . ja v a 2 s . co m*/ //Thng tin kinh doanh h c th String tenHoCaThe = request.getParameter("tenHoCaThe"); String maGiayPhep = request.getParameter("maGiayPhep"); String tinhId = request.getParameter("tinhId"); String huyenId = request.getParameter("huyenId"); String xaId = request.getParameter("xaId"); String chiTietDiaDiem = request.getParameter("chiTietDiaDiem"); String maSoThue = request.getParameter("maSoThue"); String ngayDangKy = request.getParameter("ngayDangKy"); String vonKinhDoanh = request.getParameter("vonKinhDoanh"); String dienThoai = request.getParameter("dienThoai"); //Ko validator String fax = request.getParameter("fax"); String email = request.getParameter("email"); String website = request.getParameter("website"); //end String moTaNgheNghiep = request.getParameter("moTaNgheNghiep"); String[] nganhNgheDuocChon = ParamUtil.getParameterValues(request, "nganhNgheDuocChon"); //String[] loaiHinhId = request.getParameterValues("loaiHinhId"); // Check email dang nhap /*if (Validator.isNull(emailDN) || emailDN.trim().length() == 0) { SessionErrors.add(request, "emptyMailDangNhap"); }else */ if (emailDN.trim().length() > 50) { //toi da 50 ky tu SessionErrors.add(request, "errorMaxLengMailDangNhap"); } if (!Validator.isEmailAddress(emailDN)) { SessionErrors.add(request, "errorMailKhongDungDinhDang"); } if (mode == 0 && emailExists(emailDN)) { SessionErrors.add(request, "errorEmailDaTonTai"); } /*if (mode == 1) { if(emailExists(emailDN)) SessionErrors.add(request, "errorEmailDaTonTai"); }*/ if (Validator.isNull(hoTenNDD) || hoTenNDD.trim().length() == 0) { SessionErrors.add(request, "emptyhoTenNDD"); } if (Validator.isNull(ngaySinhNDD)) { SessionErrors.add(request, "emptyngaySinhNDD"); } int gioiTinhIdNDD = Integer.parseInt(gioiTinhNDD.trim()); if (gioiTinhIdNDD == 0) { SessionErrors.add(request, "emptygioiTinhNDD"); } int quocTichIdNDD = Integer.parseInt(quocTichNDD.trim()); if (quocTichIdNDD == 0) { SessionErrors.add(request, "emptyquocTichNDD"); } int danTocIdNDD = Integer.parseInt(danTocNDD.trim()); if (danTocIdNDD == 0) { SessionErrors.add(request, "emptydanTocNDD"); } if (soCMNDNDD.trim().length() > 0) { if (!Validator.isNumber(soCMNDNDD.trim())) { SessionErrors.add(request, "cmndNotNumber"); } else if (soCMNDNDD.trim().length() > 12) { SessionErrors.add(request, "cmndOverLimit"); } else { long cmnd = Long.parseLong(soCMNDNDD.trim()); if (cmnd <= 0) { SessionErrors.add(request, "errorsoCMNDNDD"); } else if (soCMNDNDD.trim().length() != 9 && soCMNDNDD.trim().length() != 12) { SessionErrors.add(request, "errorsoCMNDNDD9or12"); } } } else { SessionErrors.add(request, "emptysoCMNDNDD"); } if (Validator.isNull(ngayCapCMNDNDD)) { SessionErrors.add(request, "emptyngayCapCMNDNDD"); } int noiCapCMNDNDDId = Integer.parseInt(noiCapCMNDNDD.trim()); if (noiCapCMNDNDDId == 0) { SessionErrors.add(request, "emptynoiCapCMNDNDD"); } int tinhTTIdNDD = Integer.parseInt(tinhTTNDD.trim()); if (tinhTTIdNDD == 0) { SessionErrors.add(request, "emptytinhTTIdNDD"); } int huyenTTIdNDD = Integer.parseInt(huyenTTNDD.trim()); if (huyenTTIdNDD == 0) { SessionErrors.add(request, "emptyhuyenTTIdNDD"); } int xaTTIdNDD = Integer.parseInt(xaTTNDD.trim()); if (xaTTIdNDD == 0) { SessionErrors.add(request, "emptyxaTTIdNDD"); } if (Validator.isNull(moTaTTNDD) || moTaTTNDD.trim().length() == 0) { SessionErrors.add(request, "emptymoTaTTNDD"); } else if (moTaTTNDD.trim().length() > 100) {//toi da 100 ky tu SessionErrors.add(request, "errorMaxLengmoTaTTNDD"); } int tinhHTIdNDD = Integer.parseInt(tinhHTNDD.trim()); if (tinhHTIdNDD == 0) { SessionErrors.add(request, "emptytinhHTIdNDD"); } int huyenHTIdNDD = Integer.parseInt(huyenHTNDD.trim()); if (huyenHTIdNDD == 0) { SessionErrors.add(request, "emptyhuyenHTIdNDD"); } int xaHTIdNDD = Integer.parseInt(xaHTNDD.trim()); if (xaHTIdNDD == 0) { SessionErrors.add(request, "emptyxaHTIdNDD"); } if (Validator.isNull(moTaHTNDD) || moTaHTNDD.trim().length() == 0) { SessionErrors.add(request, "emptymoTaHTNDD"); } else if (moTaHTNDD.trim().length() > 100) {//toi da 100 ky tu SessionErrors.add(request, "errorMaxLengmoTaHTNDD"); } if (dienThoaiNDD.trim().length() > 15) {//toi da 15 ky tu SessionErrors.add(request, "errorMaxLengdienThoaiNDD"); } else if (!Validator.isNumber(dienThoaiNDD.trim())) { SessionErrors.add(request, "errorNumberdienThoaiNDD"); } if (faxNDD.trim().length() > 15) {//toi da 15 ky tu SessionErrors.add(request, "errorMaxLengfaxNDD"); } else if (!Validator.isNumber(faxNDD.trim())) { SessionErrors.add(request, "errorNumberFax"); } if (emailNDD.trim().length() > 50) {//toi da 50 ky tu SessionErrors.add(request, "errorMaxLengemailNDD"); } if (websiteNDD.trim().length() > 100) {//toi da 100 ky tu SessionErrors.add(request, "errorMaxLengwebsiteNDD"); } if (Validator.isNull(tenHoCaThe) || tenHoCaThe.trim().length() == 0) { SessionErrors.add(request, "emptytenHoCaThe"); } else if (tenHoCaThe.trim().length() > 200) {//toi da 200 ky tu SessionErrors.add(request, "errorMaxLengtenHoCaThe"); } if (Validator.isNull(maGiayPhep) || maGiayPhep.trim().length() == 0) { SessionErrors.add(request, "emptymaGiayPhep"); } else if (maGiayPhep.trim().length() > 20) {//toi da 20 ky tu SessionErrors.add(request, "errorMaxLengmaGiayPhep"); } int tinhIdHCT = Integer.parseInt(tinhId.trim()); if (tinhIdHCT == 0) { SessionErrors.add(request, "emptytinhId"); } int huyenHCT = Integer.parseInt(huyenId.trim()); if (huyenHCT == 0) { SessionErrors.add(request, "emptyhuyenId"); } int xaHCT = Integer.parseInt(xaId.trim()); if (xaHCT == 0) { SessionErrors.add(request, "emptyxaId"); } if (Validator.isNull(chiTietDiaDiem) || chiTietDiaDiem.trim().length() == 0) { SessionErrors.add(request, "emptychiTietDiaDiem"); } else if (chiTietDiaDiem.trim().length() > 200) {//toi da 200 ky tu SessionErrors.add(request, "errorMaxLengchiTietDiaDiem"); } if (Validator.isNull(maSoThue) || maSoThue.trim().length() == 0) { SessionErrors.add(request, "emptymaSoThue"); } else if (maSoThue.trim().length() > 20) {//toi da 20 ky tu SessionErrors.add(request, "errorMaxLengmaSoThue"); } if (Validator.isNull(ngayDangKy)) { SessionErrors.add(request, "emptyngayDangKy"); } if (Validator.isNotNull(vonKinhDoanh)) { String temp = vonKinhDoanh.replaceAll(",", ""); double vonThucHien = Double.parseDouble(temp); if (vonThucHien == 0f) SessionErrors.add(request, "emptyVon"); else if (!ValidateVon(vonKinhDoanh)) { SessionErrors.add(request, "errorVon"); } } else SessionErrors.add(request, "emptyVon"); if (Validator.isNull(dienThoai) || dienThoai.trim().length() == 0) { SessionErrors.add(request, "emptydienThoai"); } else if (dienThoai.trim().length() > 15) {//toi da 15 ky tu SessionErrors.add(request, "errorMaxLengdienThoai"); } if (fax.trim().length() > 15) {//toi da 15 ky tu SessionErrors.add(request, "errorMaxfax"); } if (email.trim().length() > 50) {//toi da 50 ky tu SessionErrors.add(request, "errorMaxemail"); } if (website.trim().length() > 100) {//toi da 100 ky tu SessionErrors.add(request, "errorMaxwebsite"); } if (Validator.isNull(moTaNgheNghiep)) { SessionErrors.add(request, "emptymoTaNgheNghiep"); } if (nganhNgheDuocChon.length == 0) { SessionErrors.add(request, "emptyngheDuocChon"); } if (SessionErrors.isEmpty(request)) { return true; } return false; }
From source file:org.oep.cmon.portlet.doanhnghiep.quanlytaikhoan.utils.Validators.java
License:Apache License
public static boolean validThanhVienSangLap(ActionRequest request) { String hoTenNDD = request.getParameter("tvslTen"); String ngaySinhNDD = request.getParameter("tvslNgaySinh"); String soCMNDNDD = request.getParameter("tvslSoCMND"); String ngayCapCMNDNDD = request.getParameter("tvslNgayCapCMND"); String noiCapCMNDNDD = request.getParameter("tvslNoiCapCMND"); // Dia chi thuong tru String tinhTTNDD = request.getParameter("tvslTtTinhId"); String huyenTTNDD = request.getParameter("tvslTtHuyenId"); String xaTTNDD = request.getParameter("tvslTtXaId"); String moTaTTNDD = request.getParameter("tvslTtMoTaDiaChi"); // Dia chi hien tai String tinhHTNDD = request.getParameter("tvslCohtTinhId"); String huyenHTNDD = request.getParameter("tvslCohtHuyenId"); String xaHTNDD = request.getParameter("tvslCohtXaId"); String moTaHTNDD = request.getParameter("tvslCohtMoTaChoO"); String tvslGiaTri = request.getParameter("tvslGiaTri"); String tvslTyLe = request.getParameter("tvslTyLe"); String tvslLoaiTaiSan = request.getParameter("tvslLoaiTaiSan"); String tvslNgayGopVon = request.getParameter("tvslNgayGopVon"); String tvslGhiChu = request.getParameter("tvslGhiChu"); if (Validator.isNull(hoTenNDD) || hoTenNDD.trim().length() == 0) { SessionErrors.add(request, "emptyhoTenNDD"); } else if (hoTenNDD.trim().length() > 100) {// toi da 100 ky tu SessionErrors.add(request, "errorMaxLengTenNDD"); }//from www. j a va 2 s . c o m if (Validator.isNull(ngaySinhNDD)) { SessionErrors.add(request, "emptyngaySinhNDD"); } if (soCMNDNDD.trim().length() > 0) { if (!Validator.isNumber(soCMNDNDD.trim())) { SessionErrors.add(request, "cmndNotNumber"); } else if (soCMNDNDD.trim().length() > 12) { SessionErrors.add(request, "cmndOverLimit"); } else { long cmnd = Long.parseLong(soCMNDNDD.trim()); if (cmnd <= 0) { SessionErrors.add(request, "errorsoCMNDNDD"); } else if (soCMNDNDD.trim().length() != 9 && soCMNDNDD.trim().length() != 12) { SessionErrors.add(request, "errorsoCMNDNDD9or12"); } } } else { SessionErrors.add(request, "emptysoCMNDNDD"); } if (Validator.isNull(ngayCapCMNDNDD)) { SessionErrors.add(request, "emptyngayCapCMNDNDD"); } int noiCapCMNDNDDId = Integer.parseInt(noiCapCMNDNDD.trim()); if (noiCapCMNDNDDId == 0) { SessionErrors.add(request, "emptynoiCapCMNDNDD"); } int tinhTTIdNDD = Integer.parseInt(tinhTTNDD.trim()); if (tinhTTIdNDD == 0) { SessionErrors.add(request, "emptytinhTTIdNDD"); } int huyenTTIdNDD = Integer.parseInt(huyenTTNDD.trim()); if (huyenTTIdNDD == 0) { SessionErrors.add(request, "emptyhuyenTTIdNDD"); } int xaTTIdNDD = Integer.parseInt(xaTTNDD.trim()); if (xaTTIdNDD == 0) { SessionErrors.add(request, "emptyxaTTIdNDD"); } if (Validator.isNull(moTaTTNDD) || moTaTTNDD.trim().length() == 0) { SessionErrors.add(request, "emptymoTaTTNDD"); } else if (moTaTTNDD.trim().length() > 100) {// toi da 100 ky tu SessionErrors.add(request, "errorMaxLengmoTaTTNDD"); } int tinhHTIdNDD = Integer.parseInt(tinhHTNDD.trim()); if (tinhHTIdNDD == 0) { SessionErrors.add(request, "emptytinhHTIdNDD"); } int huyenHTIdNDD = Integer.parseInt(huyenHTNDD.trim()); if (huyenHTIdNDD == 0) { SessionErrors.add(request, "emptyhuyenHTIdNDD"); } int xaHTIdNDD = Integer.parseInt(xaHTNDD.trim()); if (xaHTIdNDD == 0) { SessionErrors.add(request, "emptyxaHTIdNDD"); } if (Validator.isNull(moTaHTNDD) || moTaHTNDD.trim().length() == 0) { SessionErrors.add(request, "emptymoTaHTNDD"); } else if (moTaHTNDD.trim().length() > 100) {// toi da 100 ky tu SessionErrors.add(request, "errorMaxLengmoTaHTNDD"); } if (Validator.isNull(tvslGiaTri) || tvslGiaTri.trim().length() == 0) { SessionErrors.add(request, "emptyGiaTri"); } else if (!Validator.isNumber(tvslGiaTri)) { SessionErrors.add(request, "notNumberGiaTri"); } if (Validator.isNull(tvslTyLe) || tvslTyLe.trim().length() == 0) { SessionErrors.add(request, "emptyTyLe"); } else { if (tvslTyLe.trim().length() > 5) {// toi da 15 ky tu SessionErrors.add(request, "errorMaxLengTyLe"); } if (!Validator.isNumber(tvslTyLe)) { SessionErrors.add(request, "notNumberTyLe"); } } if (Validator.isNull(tvslLoaiTaiSan) || tvslLoaiTaiSan.trim().length() == 0) { SessionErrors.add(request, "emptyLoaiTaiSan"); } else if (tvslLoaiTaiSan.trim().length() > 200) {// toi da 50 ky tu SessionErrors.add(request, "errorMaxLengLoaiTaiSan"); } if (Validator.isNull(tvslNgayGopVon) || tvslNgayGopVon.trim().length() == 0) {// toi da 100 ky tu SessionErrors.add(request, "emptyNgayGopVon"); } if (Validator.isNotNull(tvslGhiChu)) { if (tvslGhiChu.trim().length() > 255) { SessionErrors.add(request, "errorMaxLengLoaiTaiSan"); } } if (SessionErrors.isEmpty(request)) { return true; } return false; }
From source file:org.oep.cmon.portlet.doanhnghiep.xacthuc.utils.XacThucDoanhNghiepUtils.java
License:Apache License
public static boolean validThanhVienSangLap(ActionRequest request) { String hoTenNDD = request.getParameter("tvslTen"); String ngaySinhNDD = request.getParameter("tvslNgaySinh"); String soCMNDNDD = request.getParameter("tvslSoCMND"); String ngayCapCMNDNDD = request.getParameter("tvslNgayCapCMND"); String noiCapCMNDNDD = request.getParameter("tvslNoiCapCMND"); // Dia chi thuong tru String tinhTTNDD = request.getParameter("tvslTtTinhId"); String huyenTTNDD = request.getParameter("tvslTtHuyenId"); String xaTTNDD = request.getParameter("tvslTtXaId"); String moTaTTNDD = request.getParameter("tvslTtMoTaDiaChi"); // Dia chi hien tai String tinhHTNDD = request.getParameter("tvslCohtTinhId"); String huyenHTNDD = request.getParameter("tvslCohtHuyenId"); String xaHTNDD = request.getParameter("tvslCohtXaId"); String moTaHTNDD = request.getParameter("tvslCohtMoTaChoO"); String tvslGiaTri = request.getParameter("tvslGiaTri"); String tvslTyLe = request.getParameter("tvslTyLe"); String tvslLoaiTaiSan = request.getParameter("tvslLoaiTaiSan"); String tvslNgayGopVon = request.getParameter("tvslNgayGopVon"); String tvslGhiChu = request.getParameter("tvslGhiChu"); if (Validator.isNull(hoTenNDD) || hoTenNDD.trim().length() == 0) { SessionErrors.add(request, "emptyhoTenNDD"); } else if (hoTenNDD.trim().length() > 100) {// toi da 100 ky tu SessionErrors.add(request, "errorMaxLengTenNDD"); }/*from ww w . j a v a2s.c o m*/ if (Validator.isNull(ngaySinhNDD)) { SessionErrors.add(request, "emptyngaySinhNDD"); } if (Validator.isNull(soCMNDNDD) || soCMNDNDD.trim().length() > 0) { if (Validator.isNumber(soCMNDNDD)) { long cmnd = Long.parseLong(soCMNDNDD.trim()); if (cmnd <= 0) { SessionErrors.add(request, "errorsoCMNDNDD"); } else if (soCMNDNDD.trim().length() != 9 && soCMNDNDD.trim().length() != 12) { SessionErrors.add(request, "errorsoCMNDNDD9or12"); } } else { SessionErrors.add(request, "notNumberCMNDNDD"); } } else { SessionErrors.add(request, "emptysoCMNDNDD"); } if (Validator.isNull(ngayCapCMNDNDD)) { SessionErrors.add(request, "emptyngayCapCMNDNDD"); } int noiCapCMNDNDDId = Integer.parseInt(noiCapCMNDNDD.trim()); if (noiCapCMNDNDDId == 0) { SessionErrors.add(request, "emptynoiCapCMNDNDD"); } int tinhTTIdNDD = Integer.parseInt(tinhTTNDD.trim()); if (tinhTTIdNDD == 0) { SessionErrors.add(request, "emptytinhTTIdNDD"); } int huyenTTIdNDD = Integer.parseInt(huyenTTNDD.trim()); if (huyenTTIdNDD == 0) { SessionErrors.add(request, "emptyhuyenTTIdNDD"); } int xaTTIdNDD = Integer.parseInt(xaTTNDD.trim()); if (xaTTIdNDD == 0) { SessionErrors.add(request, "emptyxaTTIdNDD"); } if (Validator.isNull(moTaTTNDD) || moTaTTNDD.trim().length() == 0) { SessionErrors.add(request, "emptymoTaTTNDD"); } else if (moTaTTNDD.trim().length() > 100) {// toi da 100 ky tu SessionErrors.add(request, "errorMaxLengmoTaTTNDD"); } int tinhHTIdNDD = Integer.parseInt(tinhHTNDD.trim()); if (tinhHTIdNDD == 0) { SessionErrors.add(request, "emptytinhHTIdNDD"); } int huyenHTIdNDD = Integer.parseInt(huyenHTNDD.trim()); if (huyenHTIdNDD == 0) { SessionErrors.add(request, "emptyhuyenHTIdNDD"); } int xaHTIdNDD = Integer.parseInt(xaHTNDD.trim()); if (xaHTIdNDD == 0) { SessionErrors.add(request, "emptyxaHTIdNDD"); } if (Validator.isNull(moTaHTNDD) || moTaHTNDD.trim().length() == 0) { SessionErrors.add(request, "emptymoTaHTNDD"); } else if (moTaHTNDD.trim().length() > 100) {// toi da 100 ky tu SessionErrors.add(request, "errorMaxLengmoTaHTNDD"); } if (Validator.isNull(tvslGiaTri) || tvslGiaTri.trim().length() == 0) { SessionErrors.add(request, "emptyGiaTri"); } else if (!Validator.isNumber(tvslGiaTri)) { SessionErrors.add(request, "notNumberGiaTri"); } if (Validator.isNull(tvslTyLe) || tvslTyLe.trim().length() == 0) { SessionErrors.add(request, "emptyTyLe"); } else { if (tvslTyLe.trim().length() > 5) {// toi da 15 ky tu SessionErrors.add(request, "errorMaxLengTyLe"); } if (!Validator.isNumber(tvslTyLe)) { SessionErrors.add(request, "notNumberTyLe"); } } if (Validator.isNull(tvslLoaiTaiSan) || tvslLoaiTaiSan.trim().length() == 0) { SessionErrors.add(request, "emptyLoaiTaiSan"); } else if (tvslLoaiTaiSan.trim().length() > 200) {// toi da 50 ky tu SessionErrors.add(request, "errorMaxLengLoaiTaiSan"); } if (Validator.isNull(tvslNgayGopVon) || tvslNgayGopVon.trim().length() == 0) {// toi da 100 ky tu SessionErrors.add(request, "emptyNgayGopVon"); } if (Validator.isNotNull(tvslGhiChu)) { if (tvslGhiChu.trim().length() > 255) { SessionErrors.add(request, "errorMaxLengLoaiTaiSan"); } } if (SessionErrors.isEmpty(request)) { return true; } return false; }
From source file:org.oep.cmon.portlet.doanhnghiep.xacthuc.utils.XacThucDoanhNghiepUtils.java
License:Apache License
public static boolean validHoCaThe(ActionRequest request) { String taiKhoanDangNhap = request.getParameter("taiKhoanDangNhap"); //Thng tin nguoi dai dien String hoTenNDD = request.getParameter("nddTen"); String ngaySinhNDD = request.getParameter("nddNgaySinh"); String gioiTinhNDD = request.getParameter("nddGioiTinh"); // String quocTichNDD = request.getParameter("nddQuocTich"); // String danTocNDD = request.getParameter("nddDanToc"); String soCMNDNDD = request.getParameter("nddSoCMND"); String ngayCapCMNDNDD = request.getParameter("nddNgayCapCMND"); String noiCapCMNDNDD = request.getParameter("nddNoiCapCMND"); // Dia chi thuong tru String tinhTTNDD = request.getParameter("nddTtTinhId"); String huyenTTNDD = request.getParameter("nddTtHuyenId"); String xaTTNDD = request.getParameter("nddTtXaId"); String moTaTTNDD = request.getParameter("nddTtMoTaDiaChi"); // Dia chi hien tai String tinhHTNDD = request.getParameter("nddCohtTinhId"); String huyenHTNDD = request.getParameter("nddCohtHuyenId"); String xaHTNDD = request.getParameter("nddCohtXaId"); String moTaHTNDD = request.getParameter("nddCohtMoTaChoO"); //Ko validator String dienThoaiNDD = request.getParameter("nddDienThoai"); String faxNDD = request.getParameter("nddFax"); String emailNDD = request.getParameter("nddEmail"); String websiteNDD = request.getParameter("nddWebsite"); //End/*ww w . ja va2 s. c om*/ //Thng tin kinh doanh h c th String tenHoCaThe = request.getParameter("ten"); String maGiayPhep = request.getParameter("maGiayPhep"); String tinhId = request.getParameter("tinhId"); String huyenId = request.getParameter("huyenId"); String xaId = request.getParameter("xaId"); String chiTietDiaDiem = request.getParameter("chiTietDiaDiem"); String maSoThue = request.getParameter("maSoThue"); String ngayDangKy = request.getParameter("ngayDangKy"); String vonKinhDoanh = request.getParameter("vonKinhDoanh"); String dienThoai = request.getParameter("dienThoai"); //Ko validator String fax = request.getParameter("fax"); String email = request.getParameter("email"); String website = request.getParameter("website"); String moTaNgheNghiep = request.getParameter("moTaNgheNghiep"); String[] nganhNgheDuocChon = ParamUtil.getParameterValues(request, "nganhNgheDuocChon"); //end if (Validator.isNull(taiKhoanDangNhap)) { SessionErrors.add(request, "errorEmptyMailDangNhap"); } if (taiKhoanDangNhap.trim().length() > 50) { //toi da 50 ky tu SessionErrors.add(request, "errorMaxLengMailDangNhap"); } if (!Validator.isEmailAddress(taiKhoanDangNhap)) { SessionErrors.add(request, "errorMailKhongDungDinhDang"); } if (emailExists(taiKhoanDangNhap)) { SessionErrors.add(request, "errorEmailDaTonTai"); } if (Validator.isNull(hoTenNDD) || hoTenNDD.trim().length() == 0) { SessionErrors.add(request, "emptyhoTenNDD"); } else if (hoTenNDD.trim().length() > 100) {// toi da 100 ky tu SessionErrors.add(request, "errorMaxLengTenNDD"); } if (Validator.isNull(ngaySinhNDD)) { SessionErrors.add(request, "emptyngaySinhNDD"); } int gioiTinhIdNDD = Integer.parseInt(gioiTinhNDD.trim()); if (gioiTinhIdNDD == 0) { SessionErrors.add(request, "emptygioiTinhNDD"); } // int quocTichIdNDD = Integer.parseInt(quocTichNDD.trim()); // if (quocTichIdNDD ==0) { // SessionErrors.add(request, "emptyquocTichNDD"); // } // // int danTocIdNDD = Integer.parseInt(danTocNDD.trim()); // if (danTocIdNDD ==0) { // SessionErrors.add(request, "emptydanTocNDD"); // } if (Validator.isNull(soCMNDNDD) || soCMNDNDD.trim().length() > 0) { if (Validator.isNumber(soCMNDNDD)) { long cmnd = Long.parseLong(soCMNDNDD.trim()); if (cmnd <= 0) { SessionErrors.add(request, "errorsoCMNDNDD"); } else if (soCMNDNDD.trim().length() != 9 && soCMNDNDD.trim().length() != 12) { SessionErrors.add(request, "errorsoCMNDNDD9or12"); } } else { SessionErrors.add(request, "notNumberCMNDNDD"); } } else { SessionErrors.add(request, "emptysoCMNDNDD"); } if (Validator.isNull(ngayCapCMNDNDD)) { SessionErrors.add(request, "emptyngayCapCMNDNDD"); } int noiCapCMNDNDDId = Integer.parseInt(noiCapCMNDNDD.trim()); if (noiCapCMNDNDDId == 0) { SessionErrors.add(request, "emptynoiCapCMNDNDD"); } int tinhTTIdNDD = Integer.parseInt(tinhTTNDD.trim()); if (tinhTTIdNDD == 0) { SessionErrors.add(request, "emptytinhTTIdNDD"); } int huyenTTIdNDD = Integer.parseInt(huyenTTNDD.trim()); if (huyenTTIdNDD == 0) { SessionErrors.add(request, "emptyhuyenTTIdNDD"); } int xaTTIdNDD = Integer.parseInt(xaTTNDD.trim()); if (xaTTIdNDD == 0) { SessionErrors.add(request, "emptyxaTTIdNDD"); } if (Validator.isNull(moTaTTNDD) || moTaTTNDD.trim().length() == 0) { SessionErrors.add(request, "emptymoTaTTNDD"); } else if (moTaTTNDD.trim().length() > 100) {// toi da 100 ky tu SessionErrors.add(request, "errorMaxLengmoTaTTNDD"); } int tinhHTIdNDD = Integer.parseInt(tinhHTNDD.trim()); if (tinhHTIdNDD == 0) { SessionErrors.add(request, "emptytinhHTIdNDD"); } int huyenHTIdNDD = Integer.parseInt(huyenHTNDD.trim()); if (huyenHTIdNDD == 0) { SessionErrors.add(request, "emptyhuyenHTIdNDD"); } int xaHTIdNDD = Integer.parseInt(xaHTNDD.trim()); if (xaHTIdNDD == 0) { SessionErrors.add(request, "emptyxaHTIdNDD"); } if (Validator.isNull(moTaHTNDD) || moTaHTNDD.trim().length() == 0) { SessionErrors.add(request, "emptymoTaHTNDD"); } else if (moTaHTNDD.trim().length() > 100) {// toi da 100 ky tu SessionErrors.add(request, "errorMaxLengmoTaHTNDD"); } if (dienThoaiNDD.trim().length() > 15) {//toi da 15 ky tu SessionErrors.add(request, "errorMaxLengdienThoaiNDD"); } if (faxNDD.trim().length() > 15) {//toi da 15 ky tu SessionErrors.add(request, "errorMaxLengfaxNDD"); } if (emailNDD.trim().length() > 50) {//toi da 50 ky tu SessionErrors.add(request, "errorMaxLengemailNDD"); } if (websiteNDD.trim().length() > 100) {//toi da 100 ky tu SessionErrors.add(request, "errorMaxLengwebsiteNDD"); } if (Validator.isNull(tenHoCaThe) || tenHoCaThe.trim().length() == 0) { SessionErrors.add(request, "emptytenHoCaThe"); } else if (tenHoCaThe.trim().length() > 200) {//toi da 200 ky tu SessionErrors.add(request, "errorMaxLengtenHoCaThe"); } if (Validator.isNull(maGiayPhep) || maGiayPhep.trim().length() == 0) { SessionErrors.add(request, "emptymaGiayPhep"); } else if (maGiayPhep.trim().length() > 20) {//toi da 20 ky tu SessionErrors.add(request, "errorMaxLengmaGiayPhep"); } int tinhIdHCT = Integer.parseInt(tinhId.trim()); if (tinhIdHCT == 0) { SessionErrors.add(request, "emptytinhId"); } int huyenHCT = Integer.parseInt(huyenId.trim()); if (huyenHCT == 0) { SessionErrors.add(request, "emptyhuyenId"); } int xaHCT = Integer.parseInt(xaId.trim()); if (xaHCT == 0) { SessionErrors.add(request, "emptyxaId"); } if (Validator.isNull(chiTietDiaDiem) || chiTietDiaDiem.trim().length() == 0) { SessionErrors.add(request, "emptychiTietDiaDiem"); } else if (chiTietDiaDiem.trim().length() > 200) {//toi da 200 ky tu SessionErrors.add(request, "errorMaxLengchiTietDiaDiem"); } if (Validator.isNull(maSoThue) || maSoThue.trim().length() == 0) { SessionErrors.add(request, "emptymaSoThue"); } else if (maSoThue.trim().length() > 20) {//toi da 20 ky tu SessionErrors.add(request, "errorMaxLengmaSoThue"); } if (Validator.isNull(ngayDangKy)) { SessionErrors.add(request, "emptyngayDangKy"); } if (Validator.isNotNull(vonKinhDoanh)) { String temp = vonKinhDoanh.replaceAll(",", ""); double vonThucHien = Double.parseDouble(temp); if (vonThucHien == 0f) { SessionErrors.add(request, "emptyVon"); } else if (!ValidateVon(vonKinhDoanh)) { SessionErrors.add(request, "errorVon"); } } else { SessionErrors.add(request, "emptyVon"); } if (Validator.isNull(dienThoai) || dienThoai.trim().length() == 0) { SessionErrors.add(request, "emptydienThoai"); } else if (dienThoai.trim().length() > 15) {//toi da 15 ky tu SessionErrors.add(request, "errorMaxLengdienThoai"); } if (fax.trim().length() > 15) {//toi da 15 ky tu SessionErrors.add(request, "errorMaxfax"); } if (email.trim().length() > 50) {//toi da 50 ky tu SessionErrors.add(request, "errorMaxemail"); } if (website.trim().length() > 100) {//toi da 100 ky tu SessionErrors.add(request, "errorMaxwebsite"); } if (Validator.isNull(moTaNgheNghiep)) { SessionErrors.add(request, "emptymoTaNgheNghiep"); } if (nganhNgheDuocChon.length == 0) { SessionErrors.add(request, "emptyngheDuocChon"); } if (SessionErrors.isEmpty(request)) { return true; } return false; }