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

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

Introduction

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

Prototype

public static boolean isEmpty(PortletRequest portletRequest) 

Source Link

Usage

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 ww w  .  j a  va 2s  . com*/
 *  
 * 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.core.ssomgt.action.ApplicationManagementPortlet.java

License:Apache License

public void addEditApplication(ActionRequest request, ActionResponse response)
        throws SystemException, PortalException, IOException {

    if (SessionErrors.isEmpty(request)) {
        ServiceContext serviceContext = ServiceContextThreadLocal.getServiceContext();
        UploadRequest uploadRequest = PortalUtil.getUploadPortletRequest(request);
        String appName = ParamUtil.getString(uploadRequest, ApplicationKeys.AddEditAttributes.APP_NAME,
                PortletKeys.TEXT_BOX);// w w  w . j  a  va 2s.  c o  m
        String appCode = ParamUtil.getString(uploadRequest, ApplicationKeys.AddEditAttributes.APP_CODE,
                PortletKeys.TEXT_BOX);
        String appPin = ParamUtil.getString(uploadRequest, ApplicationKeys.AddEditAttributes.APP_PIN,
                PortletKeys.TEXT_BOX);
        String appUrl = ParamUtil.getString(uploadRequest, ApplicationKeys.AddEditAttributes.APP_URL,
                PortletKeys.TEXT_BOX);

        Long editId = ParamUtil.getLong(uploadRequest, ApplicationKeys.AddEditAttributes.EDIT_ID,
                PortletKeys.LONG_DEFAULT);
        OutputBlob bigIconBlob = null;
        OutputBlob smallIconBlob = null;
        try {
            File bigIconFile = uploadRequest.getFile(ApplicationKeys.AddEditAttributes.APP_BIGICON);
            File smallIconFile = uploadRequest.getFile(ApplicationKeys.AddEditAttributes.APP_SMALLICON);
            InputStream bigIconStream = new FileInputStream(bigIconFile);
            InputStream smallIconStream = new FileInputStream(smallIconFile);
            bigIconBlob = new OutputBlob(bigIconStream, bigIconFile.length());
            smallIconBlob = new OutputBlob(smallIconStream, smallIconFile.length());
        } catch (FileNotFoundException ex) {

        }

        Date pingTime = new Date();

        if (editId == PortletKeys.LONG_DEFAULT) {
            ApplicationLocalServiceUtil.addApplication(appCode, appName, appPin, appUrl, bigIconBlob,
                    smallIconBlob, pingTime, serviceContext);
        } else {
            Application application = ApplicationLocalServiceUtil.getApplication(editId);
            if (smallIconBlob != null) {
                application.setAppSmallIcon(smallIconBlob);
            }
            if (bigIconBlob != null) {
                application.setAppBigIcon(bigIconBlob);
            }
            application.setAppCode(appCode);
            application.setAppPin(appPin);
            application.setAppUrl(appUrl);
            application.setPingTime(pingTime);

            ApplicationLocalServiceUtil.updateApplication(application, serviceContext);
        }
    }
    if (!SessionErrors.isEmpty(request)) {
        PortalUtil.copyRequestParameters(request, response);
    } else {
        response.sendRedirect(ParamUtil.getString(request, PortletKeys.REDIRECT_PAGE));
    }
}

From source file:org.oep.core.ssomgt.action.ApplicationManagementPortlet.java

License:Apache License

public void editApplication(ActionRequest request, ActionResponse response)
        throws PortalException, SystemException, IOException {
    long editId = ParamUtil.getLong(request, ApplicationKeys.BaseApplicationAttributes.EDIT_ID,
            PortletKeys.LONG_DEFAULT);//w  w  w.ja v  a 2s  . c  om

    Application application = ApplicationLocalServiceUtil.getApplication(editId);
    setParameterIntoResponse(response, application);

    if (!SessionErrors.isEmpty(request)) {
        response.sendRedirect(ParamUtil.getString(request, PortletKeys.REDIRECT_PAGE));
    } else {
        PortalUtil.copyRequestParameters(request, response);
    }
}

From source file:org.oep.core.ssomgt.action.AppRolePortlet.java

License:Apache License

public void addEditAppRole(ActionRequest request, ActionResponse response)
        throws SystemException, PortalException, IOException {

    if (SessionErrors.isEmpty(request)) {
        ServiceContext serviceContext = ServiceContextThreadLocal.getServiceContext();
        long applicationId = ParamUtil.getLong(request, AppRoleKeys.AddEditAttributes.APPLICATION_ID,
                PortletKeys.LONG_DEFAULT);
        String roleCode = ParamUtil.getString(request, AppRoleKeys.AddEditAttributes.ROLE_CODE,
                PortletKeys.TEXT_BOX);/*w w w . jav a2  s  .com*/
        String roleName = ParamUtil.getString(request, AppRoleKeys.AddEditAttributes.ROLE_NAME,
                PortletKeys.TEXT_BOX);

        Long editId = ParamUtil.getLong(request, AppRoleKeys.AddEditAttributes.EDIT_ID,
                PortletKeys.LONG_DEFAULT);
        if (editId == PortletKeys.LONG_DEFAULT) {
            AppRoleLocalServiceUtil.addAppRole(applicationId, roleCode, roleName, serviceContext);
        } else {
            AppRoleLocalServiceUtil.updateAppRole(editId, applicationId, roleCode, roleName, serviceContext);
        }
    }
    if (!SessionErrors.isEmpty(request)) {
        PortalUtil.copyRequestParameters(request, response);
    } else {
        response.sendRedirect(ParamUtil.getString(request, PortletKeys.REDIRECT_PAGE));
    }
}

From source file:org.oep.core.ssomgt.action.AppRolePortlet.java

License:Apache License

public void editAppRole(ActionRequest request, ActionResponse response)
        throws PortalException, SystemException, IOException {
    long editId = ParamUtil.getLong(request, AppRoleKeys.AddEditAttributes.EDIT_ID, PortletKeys.LONG_DEFAULT);

    AppRole appRole = AppRoleLocalServiceUtil.getAppRole(editId);
    setParameterIntoResponse(response, appRole);

    if (!SessionErrors.isEmpty(request)) {
        response.sendRedirect(ParamUtil.getString(request, PortletKeys.REDIRECT_PAGE));
    } else {//from www  .java 2  s .  com
        PortalUtil.copyRequestParameters(request, response);
    }
}

From source file:org.oep.ssomgt.action.ApplicationManagementPortlet.java

License:Apache License

public void addEditApplication(ActionRequest request, ActionResponse response)
        throws SystemException, PortalException, IOException {
    UploadRequest uploadRequest = PortalUtil.getUploadPortletRequest(request);
    validateParamsIntoSessionError(uploadRequest, request);

    String appName = null;//from w  w  w .  j a  v  a2  s. c  om
    String appCode = null;
    String appPin = null;
    String appUrl = null;
    String publicKey = null;

    if (SessionErrors.isEmpty(request)) {
        ServiceContext serviceContext = ServiceContextThreadLocal.getServiceContext();
        appName = ParamUtil.getString(uploadRequest, ApplicationKeys.AddEditAttributes.APP_NAME,
                PortletKeys.TEXT_BOX);
        appCode = ParamUtil.getString(uploadRequest, ApplicationKeys.AddEditAttributes.APP_CODE,
                PortletKeys.TEXT_BOX);
        appPin = ParamUtil.getString(uploadRequest, ApplicationKeys.AddEditAttributes.APP_PIN,
                PortletKeys.TEXT_BOX);
        appUrl = ParamUtil.getString(uploadRequest, ApplicationKeys.AddEditAttributes.APP_URL,
                PortletKeys.TEXT_BOX);
        publicKey = ParamUtil.getString(uploadRequest, ApplicationKeys.AddEditAttributes.PUBLICKEY,
                PortletKeys.TEXT_BOX);

        Long editId = ParamUtil.getLong(uploadRequest, ApplicationKeys.AddEditAttributes.EDIT_ID,
                PortletKeys.LONG_DEFAULT);
        OutputBlob bigIconBlob = null;
        OutputBlob smallIconBlob = null;
        try {
            File bigIconFile = uploadRequest.getFile(ApplicationKeys.AddEditAttributes.APP_BIGICON);
            File smallIconFile = uploadRequest.getFile(ApplicationKeys.AddEditAttributes.APP_SMALLICON);
            InputStream bigIconStream = new FileInputStream(bigIconFile);
            InputStream smallIconStream = new FileInputStream(smallIconFile);
            bigIconBlob = new OutputBlob(bigIconStream, bigIconFile.length());
            smallIconBlob = new OutputBlob(smallIconStream, smallIconFile.length());
        } catch (NullPointerException ex) {
            SessionErrors.add(request,
                    ApplicationKeys.ErrorMessageKeys.ORG_OEP_SSOMGT_PORTLET_APPLICATIONMANAGEMENT_APPICONNULL);
        } catch (FileNotFoundException ex) {

        }

        Date pingTime = new Date();
        if (editId == PortletKeys.LONG_DEFAULT) {
            if (smallIconBlob != null && bigIconBlob != null) {
                ApplicationLocalServiceUtil.addApplication(appCode, appName, appPin, appUrl, bigIconBlob,
                        smallIconBlob, pingTime, publicKey, serviceContext);
                SessionMessages.add(request,
                        ApplicationKeys.SuccessMessageKeys.ORG_OEP_SSOMGT_PORTLET_APPLICATION_SUCCESS_ADDNEW);
            } else {
                ApplicationLocalServiceUtil.addApplication(appCode, appName, appPin, appUrl, pingTime,
                        publicKey, serviceContext);
                SessionMessages.add(request,
                        ApplicationKeys.SuccessMessageKeys.ORG_OEP_SSOMGT_PORTLET_APPLICATION_SUCCESS_ADDNEW);
            }
        } else {
            Application application = ApplicationLocalServiceUtil.getApplication(editId);
            if (smallIconBlob != null) {
                application.setAppSmallIcon(smallIconBlob);
            }
            if (bigIconBlob != null) {
                application.setAppBigIcon(bigIconBlob);
            }
            application.setAppCode(appCode);
            application.setAppPin(appPin);
            application.setAppUrl(appUrl);
            application.setPingTime(pingTime);

            ApplicationLocalServiceUtil.updateApplication(application, serviceContext);
            SessionMessages.add(request,
                    ApplicationKeys.SuccessMessageKeys.ORG_OEP_SSOMGT_PORTLET_APPLICATION_SUCCESS_UPDATE);
        }
    }
    SessionMessages.add(request,
            PortalUtil.getPortletId(request) + SessionMessages.KEY_SUFFIX_HIDE_DEFAULT_ERROR_MESSAGE);
    if (!SessionErrors.isEmpty(request)) {
        appName = ParamUtil.getString(uploadRequest, ApplicationKeys.AddEditAttributes.APP_NAME,
                PortletKeys.TEXT_BOX);
        appCode = ParamUtil.getString(uploadRequest, ApplicationKeys.AddEditAttributes.APP_CODE,
                PortletKeys.TEXT_BOX);
        appPin = ParamUtil.getString(uploadRequest, ApplicationKeys.AddEditAttributes.APP_PIN,
                PortletKeys.TEXT_BOX);
        appUrl = ParamUtil.getString(uploadRequest, ApplicationKeys.AddEditAttributes.APP_URL,
                PortletKeys.TEXT_BOX);
        response.setRenderParameter(ApplicationKeys.AddEditAttributes.APP_NAME, appName);
        response.setRenderParameter(ApplicationKeys.AddEditAttributes.APP_CODE, appCode);
        response.setRenderParameter(ApplicationKeys.AddEditAttributes.APP_PIN, appPin);
        response.setRenderParameter(ApplicationKeys.AddEditAttributes.APP_URL, appUrl);

        PortalUtil.copyRequestParameters(request, response);
    } else {
        response.sendRedirect(ParamUtil.getString(request, PortletKeys.REDIRECT_PAGE));
    }
}

From source file:org.oep.ssomgt.action.AppRolePortlet.java

License:Apache License

public void addEditAppRole2JobPos(ActionRequest request, ActionResponse response)
        throws SystemException, PortalException, IOException {
    if (SessionErrors.isEmpty(request)) {
        ServiceContext serviceContext = ServiceContextThreadLocal.getServiceContext();
        long appRoleId = ParamUtil.getLong(request, AppRole2JobPosKeys.AddEditAttributes.APPROLE_ID,
                PortletKeys.LONG_DEFAULT);
        long jobPosId = ParamUtil.getLong(request, AppRole2JobPosKeys.AddEditAttributes.JOBPOS_ID,
                PortletKeys.LONG_DEFAULT);

        Long editId = ParamUtil.getLong(request, AppRole2JobPosKeys.AddEditAttributes.EDIT_ID,
                PortletKeys.LONG_DEFAULT);
        if (editId == PortletKeys.LONG_DEFAULT) {
            AppRole2JobPosLocalServiceUtil.addAppRole2JobPos(appRoleId, jobPosId, serviceContext);
            SessionMessages.add(request,
                    AssignRoleKeys.SuccessMessageKeys.ORG_OEP_SSOMGT_PORTLET_APPROLE_ASSIGNROLE2JOBPOS_SUCCESS_ADDNEW);
        } else {// ww w  .j  ava2s.  c  om
        }
    }
    SessionMessages.add(request,
            PortalUtil.getPortletId(request) + SessionMessages.KEY_SUFFIX_HIDE_DEFAULT_ERROR_MESSAGE);
    if (!SessionErrors.isEmpty(request)) {
        PortalUtil.copyRequestParameters(request, response);
    } else {
        response.sendRedirect(ParamUtil.getString(request, PortletKeys.REDIRECT_PAGE));
    }
}

From source file:org.oep.ssomgt.action.AppRolePortlet.java

License:Apache License

public void addEditAppRole2Employee(ActionRequest request, ActionResponse response)
        throws SystemException, PortalException, IOException {
    if (SessionErrors.isEmpty(request)) {
        ServiceContext serviceContext = ServiceContextThreadLocal.getServiceContext();
        long appRoleId = ParamUtil.getLong(request, AppRole2JobPosKeys.AddEditAttributes.APPROLE_ID,
                PortletKeys.LONG_DEFAULT);
        long employeeId = ParamUtil.getLong(request, AppRole2EmployeeKeys.AddEditAttributes.EMPLOYEE_ID,
                PortletKeys.LONG_DEFAULT);

        Long editId = ParamUtil.getLong(request, AppRole2EmployeeKeys.AddEditAttributes.EDIT_ID,
                PortletKeys.LONG_DEFAULT);
        if (editId == PortletKeys.LONG_DEFAULT) {
            Employee employee = EmployeeLocalServiceUtil.getEmployee(employeeId);
            AppRole2EmployeeLocalServiceUtil.addAppRole2Employee(appRoleId, employeeId, serviceContext);
            AppRole role = AppRoleLocalServiceUtil.getAppRole(appRoleId);
            try {
                UserSync userSync = UserSyncLocalServiceUtil.findByApplicationEmployee(role.getApplicationId(),
                        employeeId);//from   www .j a  v  a2  s  . c o  m
                String roles = userSync.getRoles();
                userSync.setCheckpoint(new Date());
                if (!roles.contains(role.getRoleCode())) {
                    if (roles.equals(""))
                        roles = role.getRoleCode();
                    else
                        roles += "," + role.getRoleCode();
                } else {

                }
                UserSyncLocalServiceUtil.updateUserSync(userSync);
            } catch (Exception e) {
                e.printStackTrace();
                User user = UserLocalServiceUtil.getUser(employee.getMappingUserId());
                UserSyncLocalServiceUtil.addUserSync(role.getApplicationId(), employeeId,
                        employee.getMappingUserId(), user.getScreenName(), user.getScreenName(),
                        employee.getFullName(), user.getEmailAddress(), user.getPassword(), 1,
                        role.getRoleCode(), new Date(), null);
            }
            SessionMessages.add(request,
                    AssignRoleKeys.SuccessMessageKeys.ORG_OEP_SSOMGT_PORTLET_APPROLE_ASSIGNROLE2EMPLOYEE_SUCCESS_ADDNEW);
        } else {
        }
    }
    SessionMessages.add(request,
            PortalUtil.getPortletId(request) + SessionMessages.KEY_SUFFIX_HIDE_DEFAULT_ERROR_MESSAGE);
    if (!SessionErrors.isEmpty(request)) {
        PortalUtil.copyRequestParameters(request, response);
    } else {
        response.sendRedirect(ParamUtil.getString(request, PortletKeys.REDIRECT_PAGE));
    }
}

From source file:org.oep.ssomgt.action.AppRolePortlet.java

License:Apache License

public void addEditAppRole(ActionRequest request, ActionResponse response)
        throws SystemException, PortalException, IOException {
    validateParamsIntoSessionError(request);

    if (SessionErrors.isEmpty(request)) {
        ServiceContext serviceContext = ServiceContextThreadLocal.getServiceContext();
        long applicationId = ParamUtil.getLong(request, AppRoleKeys.AddEditAttributes.APPLICATION_ID,
                PortletKeys.LONG_DEFAULT);
        String roleCode = ParamUtil.getString(request, AppRoleKeys.AddEditAttributes.ROLE_CODE,
                PortletKeys.TEXT_BOX);//w  w  w.  j a va  2s  .c  o  m
        String roleName = ParamUtil.getString(request, AppRoleKeys.AddEditAttributes.ROLE_NAME,
                PortletKeys.TEXT_BOX);

        Long editId = ParamUtil.getLong(request, AppRoleKeys.AddEditAttributes.EDIT_ID,
                PortletKeys.LONG_DEFAULT);
        if (editId == PortletKeys.LONG_DEFAULT) {
            AppRoleLocalServiceUtil.addAppRole(applicationId, roleCode, roleName, serviceContext);
            SessionMessages.add(request,
                    AppRoleKeys.SuccessMessageKeys.ORG_OEP_SSOMGT_PORTLET_APPROLE_SUCCESS_ADDNEW);
        } else {
            AppRoleLocalServiceUtil.updateAppRole(editId, applicationId, roleCode, roleName, serviceContext);
            SessionMessages.add(request,
                    AppRoleKeys.SuccessMessageKeys.ORG_OEP_SSOMGT_PORTLET_APPROLE_SUCCESS_UPDATE);
        }
    }
    SessionMessages.add(request,
            PortalUtil.getPortletId(request) + SessionMessages.KEY_SUFFIX_HIDE_DEFAULT_ERROR_MESSAGE);
    if (!SessionErrors.isEmpty(request)) {
        PortalUtil.copyRequestParameters(request, response);
    } else {
        response.sendRedirect(ParamUtil.getString(request, PortletKeys.REDIRECT_PAGE));
    }
}

From source file:org.oep.ssomgt.action.AppRolePortlet.java

License:Apache License

public void editAppRole(ActionRequest request, ActionResponse response)
        throws PortalException, SystemException, IOException {
    long editId = ParamUtil.getLong(request, AppRoleKeys.AddEditAttributes.EDIT_ID, PortletKeys.LONG_DEFAULT);

    AppRole appRole = AppRoleLocalServiceUtil.getAppRole(editId);
    setParameterIntoResponse(response, appRole);

    if (!SessionErrors.isEmpty(request)) {
        response.sendRedirect(ParamUtil.getString(request, PortletKeys.REDIRECT_PAGE));
        SessionMessages.add(request,//from  www. j av a2s  . c om
                AppRoleKeys.SuccessMessageKeys.ORG_OEP_SSOMGT_PORTLET_APPROLE_SUCCESS_UPDATE);
    } else {
        PortalUtil.copyRequestParameters(request, response);
    }
}