Example usage for com.liferay.portal.kernel.servlet SessionErrors iterator

List of usage examples for com.liferay.portal.kernel.servlet SessionErrors iterator

Introduction

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

Prototype

public static Iterator<String> iterator(PortletRequest portletRequest) 

Source Link

Usage

From source file:org.oep.cmon.portlet.document.action.YKienTraoDoiAction.java

License:Apache License

/**
 * This is  function validatorsYKienTraoDoi
 * Version: 1.0/*w w w  .  ja v a  2  s  . c  om*/
 *  
 * History: 
 *   DATE        AUTHOR      DESCRIPTION 
 *  ------------------------------------------------- 
 *  3-March-2013  Nam Dinh    Create new
 * @param actionrequest
 * @return boolean
 */
private boolean validatorsYKienTraoDoi(ActionRequest actionrequest) {
    boolean valid = true;

    // tieuDe - String
    String tieuDe = ParamUtil.getString(actionrequest, "tieuDe").trim();
    if (tieuDe.length() == 0 || tieuDe.length() > 200) {
        SessionErrors.add(actionrequest, "err.tieuDe");
        valid = false;
    }

    // noiDung - String
    String noiDung = ParamUtil.getString(actionrequest, "noiDung").trim();
    if (noiDung.length() == 0) {
        SessionErrors.add(actionrequest, "err.noiDung");
        valid = false;
    }

    if (!valid) {
        FormatUtil.setParams(actionrequest);
        Iterator<String> error = SessionErrors.iterator(actionrequest);
    }
    return valid;
}

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

License:Apache License

/**
 * This is function validator YeuCauDangKyCongDan
 * Version: 1.0//from   ww  w.j  ava2  s  .  c  o m
 *  
 * History: 
 *   DATE        AUTHOR      DESCRIPTION 
 *  ------------------------------------------------- 
 *  3-March-2013  Nam Dinh    Create new
 * @param actionRequest
 * @throws SystemException
 * @return boolean
 */
private static boolean validatorsYeuCauDangKyCongDan(ActionRequest actionRequest) throws SystemException {
    boolean valid = true;

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

    // Check Ho cong dan
    String ho = ParamUtil.getString(actionRequest, "ho").trim();
    if (Validator.isNull(ho)) {
        SessionErrors.add(actionRequest, "vn.dtt.cmon.userreg.form.input.err.hoCongDan");
        valid = false;
    }

    // Check ten cong dan
    String ten = ParamUtil.getString(actionRequest, "ten").trim();
    if (Validator.isNull(ten)) {
        SessionErrors.add(actionRequest, "vn.dtt.cmon.userreg.form.input.err.tenCongDan");
        valid = false;
    }

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

    // Check ngay cap CMND
    String ngayCapCmnd = ParamUtil.getString(actionRequest, "ngayCapCmnd").trim();
    if (Validator.isNull(ngayCapCmnd)) {
        SessionErrors.add(actionRequest, "vn.dtt.cmon.userreg.form.input.err.ngayCapCmnd");
        valid = false;
    }

    // Check noi cap cmnd
    long noiCapCmnd = ParamUtil.getLong(actionRequest, "noiCapCmnd");
    if (noiCapCmnd == 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");
        valid = false;
    }

    // Check email
    String email = ParamUtil.getString(actionRequest, "email").trim();
    if (!Validator.isEmailAddress(email)) {
        SessionErrors.add(actionRequest, "vn.dtt.cmon.userreg.form.input.err.email");
        valid = false;
    }

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

    // Check ngay sinh
    String ngaySinh = ParamUtil.getString(actionRequest, "ngaySinh").trim();
    if (Validator.isNull(ngaySinh)) {
        SessionErrors.add(actionRequest, "vn.dtt.cmon.userreg.form.input.err.ngaySinh");
        valid = false;
    }

    String tinhThuongTru = ParamUtil.getString(actionRequest, "tinhThuongTru");
    String huyenThuongTru = ParamUtil.getString(actionRequest, "huyenThuongTru");
    String xaThuongTru = ParamUtil.getString(actionRequest, "xaThuongTru");

    String motaThuongTru = ParamUtil.getString(actionRequest, "motaThuongTru").trim();
    if (Validator.isNull(motaThuongTru)) {
        SessionErrors.add(actionRequest, "vn.dtt.cmon.userreg.form.input.err.motaThuongTru");
        valid = false;
    }

    if (Validator.isNull(tinhThuongTru)) {
        SessionErrors.add(actionRequest, "vn.dtt.cmon.userreg.form.input.err.tinhThuongTru");
        valid = false;
    }

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

    // Check xa thuong tru
    if (Validator.isNull(xaThuongTru)) {
        SessionErrors.add(actionRequest, "vn.dtt.cmon.userreg.form.input.err.xaThuongTru");
        valid = false;
    }

    // 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");
        valid = false;
    }

    // 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");
    //            }
    //            
    //            // 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 (!valid) {
        FormatUtil.setParams(actionRequest);
        Iterator<String> error = SessionErrors.iterator(actionRequest);
        while (error.hasNext()) {
            _log.info("validate false :" + error.next());

        }
    }
    return valid;
}

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

License:Apache License

/** 
 * This is function validatorsYKienTraoDoi
 * // w  w  w  .  j  a  v a  2 s.com
 * Version: 1.0
 *  
 * History: 
 *   DATE        AUTHOR      DESCRIPTION 
 *  ------------------------------------------------- 
 *  10-April-2013  Nam Dinh    Create new
 * @param actionrequest
 * @throws SystemException
 * @return boolean
 */
private static boolean validatorsYKienTraoDoi(ActionRequest actionrequest) throws SystemException {
    boolean valid = true;
    // tieuDe - String
    String tieuDe = ParamUtil.getString(actionrequest, "tieuDe").trim();
    if (tieuDe.length() == 0 || tieuDe.length() > 200) {
        SessionErrors.add(actionrequest, "err.tieuDe");
        valid = false;
    }
    // noiDung - String
    String noiDung = ParamUtil.getString(actionrequest, "noiDung").trim();
    if (noiDung.length() == 0) {
        SessionErrors.add(actionrequest, "err.noiDung");
        valid = false;
    }

    //         HoSoTTHCCong hoSoTTHCCong = null;
    //         long hoSoTTHCCongId = ConvertUtil.convertToLong(ParamUtil.getString(actionrequest, "hoSoTTHCCongId"));
    //         
    //         if(hoSoTTHCCongId >0){
    //            hoSoTTHCCong = HoSoTTHCCongLocalServiceUtil.fetchHoSoTTHCCong(hoSoTTHCCongId);
    //         }
    //         List<CongChuc> tiepNhanlist = null;
    //         if (hoSoTTHCCong.getCoQuanTiepNhanId() >0){
    //            tiepNhanlist = CongChucLocalServiceUtil.listCanBoTiepNhan(hoSoTTHCCong.getCoQuanTiepNhanId(), 0, 500);
    //         }
    //         
    //         if (hoSoTTHCCong.getCanBoTiepNhanId() == null && tiepNhanlist.size() ==0){
    //            SessionErrors.add(actionrequest, "err.nguoiNhan");
    //            valid = false;
    //         } 

    if (!valid) {
        FormatUtil.setParams(actionrequest);
        Iterator<String> error = SessionErrors.iterator(actionrequest);
    }
    return valid;
}

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

License:Apache License

/** 
 * This is function validatorsYKienTraoDoiCanBo
 * // ww  w  . ja v a2 s  . c om
 * Version: 1.0
 *  
 * History: 
 *   DATE        AUTHOR      DESCRIPTION 
 *  ------------------------------------------------- 
 *  10-April-2013  Nam Dinh    Create new
 * @param actionrequest
 * @throws SystemException
 * @throws NoSuchTaiKhoanNguoiDungException
 */
private static boolean validatorsYKienTraoDoiCanBo(ActionRequest actionrequest)
        throws SystemException, NoSuchTaiKhoanNguoiDungException {
    boolean valid = true;
    HoSoTTHCCong hoSoTTHCCong = null;
    long hoSoTTHCCongId = ConvertUtil.convertToLong(ParamUtil.getString(actionrequest, "hoSoTTHCCongId"));

    if (hoSoTTHCCongId > 0) {
        hoSoTTHCCong = HoSoTTHCCongLocalServiceUtil.fetchHoSoTTHCCong(hoSoTTHCCongId);
    }

    // nguoiNhanId - String
    long nguoiNhanId = ParamUtil.getLong(actionrequest, "nguoiNhanId");
    //            if (nguoiNhanId == 0 ) {
    //               SessionErrors.add(actionrequest, "err.nguoiNhanId");
    //               valid = false;
    //            } 
    //            else if (nguoiNhanId==1){
    //               if (hoSoTTHCCong.getCongDanNopId() == null){
    //                  SessionErrors.add(actionrequest, "err.congDanNopId");
    //                  valid = false;
    //               }
    //               else {
    //                  TaiKhoanNguoiDung taiKhoanNguoiDung = TaiKhoanNguoiDungLocalServiceUtil.fetchTaiKhoanNguoiDung(hoSoTTHCCong.getCongDanNopId());
    //                  //TaiKhoanNguoiDung taiKhoanNguoiDung = TaiKhoanNguoiDungLocalServiceUtil.findByTaiKhoanNguoiDungId(hoSoTTHCCong.getCongDanNopId());
    //                  if (taiKhoanNguoiDung == null  ){
    //                     SessionErrors.add(actionrequest, "err.congDanNopId");
    //                     valid = false;
    //                  }
    //               }
    //            } 
    //            else if (nguoiNhanId==2){
    //               if (hoSoTTHCCong.getCanBoXuLyHienThoiId() == null){
    //                  SessionErrors.add(actionrequest, "err.canBoXuLyHienThoiId");
    //                  valid = false;
    //               } 
    //               else {
    //                  TaiKhoanNguoiDung taiKhoanNguoiDung = TaiKhoanNguoiDungLocalServiceUtil.fetchTaiKhoanNguoiDung(hoSoTTHCCong.getCanBoXuLyHienThoiId());
    //                  if (taiKhoanNguoiDung == null ){
    //                     SessionErrors.add(actionrequest, "err.canBoXuLyHienThoiId");
    //                     valid = false;
    //                  }
    //               }
    //            }

    // tieuDe - String
    String tieuDe = ParamUtil.getString(actionrequest, "tieuDe").trim();
    if (tieuDe.length() == 0 || tieuDe.length() > 200) {
        SessionErrors.add(actionrequest, "err.tieuDe");
        valid = false;
    }
    // noiDung - String
    String noiDung = ParamUtil.getString(actionrequest, "noiDung").trim();
    if (noiDung.length() == 0) {
        SessionErrors.add(actionrequest, "err.noiDung");
        valid = false;
    }
    if (!valid) {
        FormatUtil.setParams(actionrequest);
        Iterator<String> error = SessionErrors.iterator(actionrequest);
    }
    return valid;
}