Example usage for com.liferay.portal.kernel.util StringPool UTF8

List of usage examples for com.liferay.portal.kernel.util StringPool UTF8

Introduction

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

Prototype

String UTF8

To view the source code for com.liferay.portal.kernel.util StringPool UTF8.

Click Source Link

Usage

From source file:org.oep.cmon.portlet.doanhnghiep.quanlytaikhoan.action.QuanLyTaiKhoanPortlet.java

License:Apache License

/**
 * This is  function get data HoCaThe//ww w.j a  va2 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 getDataHoCaThe(ActionRequest actionRequest, ActionResponse actionResponse) throws Exception {
    long hoCaTheId = ParamUtil.getLong(actionRequest, "hoCaTheId", 0l);
    DateFormat df = new SimpleDateFormat("dd/MM/yyyy");
    DoanhNghiep hoCaThe = DoanhNghiepLocalServiceUtil.fetchDoanhNghiep(hoCaTheId);

    JSONObject obj = JSONFactoryUtil.getJSONFactory().createJSONObject();
    obj.put("id", hoCaThe.getId());
    obj.put("ten", hoCaThe.getTen());
    obj.put("maGiayPhep", hoCaThe.getSoGCNDKKD());

    obj.put("tinhId", hoCaThe.getDiaChiDoanhNghiepTinhId());
    obj.put("huyenId", hoCaThe.getDiaChiDoanhNghiepHuyenId());
    obj.put("xaId", hoCaThe.getDiaChiDoanhNghiepXaId());

    obj.put("chiTietDiaDiem", hoCaThe.getDiaChiDoanhNghiep());
    obj.put("maSoThue", hoCaThe.getMaSoThue());
    obj.put("ngayDangKy", df.format(hoCaThe.getNgayCapGCNDKKD()));
    obj.put("vonKinhDoanh", hoCaThe.getVonDieuLe());
    obj.put("dienThoai", hoCaThe.getDienThoaiDoanhNghiep());
    obj.put("fax", hoCaThe.getFax());
    obj.put("email", hoCaThe.getEmailDoanhNghiep());
    obj.put("website", hoCaThe.getWebsite());
    obj.put("moTaNgheNghiep", hoCaThe.getMoTaNganhNgheKinhDoanh());

    obj.put("nddId", hoCaThe.getNguoiDaiDienId());
    List<NganhNgheKinhDoanh> listNganhNghe = XacThucDoanhNghiepUtils.getNganhNgheByIdDoanhNghiep(hoCaTheId);
    JSONArray lnn = JSONFactoryUtil.getJSONFactory().createJSONArray();
    for (int i = 0; i < listNganhNghe.size(); i++) {
        JSONObject row = JSONFactoryUtil.getJSONFactory().createJSONObject();
        row.put("id", listNganhNghe.get(i).getId());
        row.put("name", listNganhNghe.get(i).getTen());
        lnn.put(row);
    }
    obj.put("listNganhNghe", lnn);
    HttpServletResponse resourceResponse = PortalUtil.getHttpServletResponse(actionResponse);
    resourceResponse.setContentType(ContentTypes.APPLICATION_JSON);
    resourceResponse.setCharacterEncoding(StringPool.UTF8);
    resourceResponse.getWriter().write(obj.toString());
    resourceResponse.getWriter().close();
}

From source file:org.oep.cmon.portlet.doanhnghiep.quanlytaikhoan.action.QuanLyTaiKhoanPortlet.java

License:Apache License

/**
 * This is  function get data CongDan//from  ww w. j ava  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 getDataCongDan(ActionRequest actionRequest, ActionResponse actionResponse) throws Exception {
    long congDanId = ParamUtil.getLong(actionRequest, "congDanId", 0l);
    DateFormat df = new SimpleDateFormat("dd/MM/yyyy");
    CongDan congDan = CongDanLocalServiceUtil.fetchCongDan(congDanId);

    JSONObject obj = JSONFactoryUtil.getJSONFactory().createJSONObject();

    obj.put("nddId", congDan.getId());
    obj.put("nddTen", congDan.getTenDayDu());
    obj.put("nddNgaySinh", df.format(congDan.getNgaySinh()));
    obj.put("nddGioiTinh", congDan.getGioiTinh());
    obj.put("nddQuocTich", congDan.getQuocTichId());
    obj.put("nddDanToc", congDan.getDanTocId());
    obj.put("nddSoCMND", congDan.getSoCmnd());
    obj.put("nddNgayCapCMND", congDan.getNgayCapCmnd() != null ? df.format(congDan.getNgayCapCmnd()) : "");
    obj.put("nddNoiCapCMND",
            congDan.getNoiCapCmndId() != null ? String.valueOf(congDan.getNoiCapCmndId()) : "");
    obj.put("nddTtTinhId", congDan.getDiaChiThuongTruTinhId());
    obj.put("nddTtHuyenId", congDan.getDiaChiThuongTruHuyenId());
    obj.put("nddTtXaId", congDan.getDiaChiThuongTruXaId());
    obj.put("nddTtMoTaDiaChi", congDan.getDiaChiThuongTru());
    obj.put("nddCohtTinhId", congDan.getDiaChiHienNayTinhId());
    obj.put("nddCohtHuyenId", congDan.getDiaChiHienNayHuyenId());
    obj.put("nddCohtXaId", congDan.getDiaChiHienNayXaId());
    obj.put("nddCohtMoTaChoO", congDan.getDiaChiHienNay());
    obj.put("nddDienThoai", congDan.getDienThoaiCoDinh());
    obj.put("nddFax", congDan.getFax());
    obj.put("nddEmail", congDan.getEmail());
    obj.put("nddWebsite", congDan.getWebsite());

    HttpServletResponse resourceResponse = PortalUtil.getHttpServletResponse(actionResponse);
    resourceResponse.setContentType(ContentTypes.APPLICATION_JSON);
    resourceResponse.setCharacterEncoding(StringPool.UTF8);
    resourceResponse.getWriter().write(obj.toString());
    resourceResponse.getWriter().close();
}

From source file:org.oep.cmon.portlet.doanhnghiep.xacthuc.action.XacThucDoanhNghiepPortlet.java

License:Apache License

public void getDataHoCaThe(ActionRequest actionRequest, ActionResponse actionResponse) throws Exception {
    long hoCaTheId = ParamUtil.getLong(actionRequest, "hoCaTheId", 0l);
    DateFormat df = new SimpleDateFormat("dd/MM/yyyy");
    DoanhNghiep hoCaThe = DoanhNghiepLocalServiceUtil.fetchDoanhNghiep(hoCaTheId);

    JSONObject obj = JSONFactoryUtil.getJSONFactory().createJSONObject();
    obj.put("id", hoCaThe.getId());
    obj.put("ten", hoCaThe.getTen());
    obj.put("maGiayPhep", hoCaThe.getSoGCNDKKD());

    obj.put("tinhId", hoCaThe.getDiaChiDoanhNghiepTinhId());
    obj.put("huyenId", hoCaThe.getDiaChiDoanhNghiepHuyenId());
    obj.put("xaId", hoCaThe.getDiaChiDoanhNghiepXaId());

    obj.put("chiTietDiaDiem", hoCaThe.getDiaChiDoanhNghiep());
    obj.put("maSoThue", hoCaThe.getMaSoThue());
    obj.put("ngayDangKy", df.format(hoCaThe.getNgayCapGCNDKKD()));
    obj.put("vonKinhDoanh", hoCaThe.getVonDieuLe());
    obj.put("dienThoai", hoCaThe.getDienThoaiDoanhNghiep());
    obj.put("fax", hoCaThe.getFax());
    obj.put("email", hoCaThe.getEmailDoanhNghiep());
    obj.put("website", hoCaThe.getWebsite());
    obj.put("moTaNgheNghiep", hoCaThe.getMoTaNganhNgheKinhDoanh());

    obj.put("nddId", hoCaThe.getNguoiDaiDienId());
    List<NganhNgheKinhDoanh> listNganhNghe = XacThucDoanhNghiepUtils.getNganhNgheByIdDoanhNghiep(hoCaTheId);
    JSONArray lnn = JSONFactoryUtil.getJSONFactory().createJSONArray();
    for (int i = 0; i < listNganhNghe.size(); i++) {
        JSONObject row = JSONFactoryUtil.getJSONFactory().createJSONObject();
        row.put("id", listNganhNghe.get(i).getId());
        row.put("name", listNganhNghe.get(i).getTen());
        lnn.put(row);/* w  ww .ja va  2 s  .  c o  m*/
    }
    obj.put("listNganhNghe", lnn);
    HttpServletResponse resourceResponse = PortalUtil.getHttpServletResponse(actionResponse);
    resourceResponse.setContentType(ContentTypes.APPLICATION_JSON);
    resourceResponse.setCharacterEncoding(StringPool.UTF8);
    resourceResponse.getWriter().write(obj.toString());
    resourceResponse.getWriter().close();
}

From source file:org.oep.cmon.portlet.doanhnghiep.xacthuc.action.XacThucDoanhNghiepPortlet.java

License:Apache License

public void getDataCongDan(ActionRequest actionRequest, ActionResponse actionResponse) throws Exception {
    long congDanId = ParamUtil.getLong(actionRequest, "congDanId", 0l);
    DateFormat df = new SimpleDateFormat("dd/MM/yyyy");
    CongDan congDan = CongDanLocalServiceUtil.fetchCongDan(congDanId);

    JSONObject obj = JSONFactoryUtil.getJSONFactory().createJSONObject();

    obj.put("nddId", congDan.getId());
    obj.put("nddTen", congDan.getTenDayDu());
    obj.put("nddNgaySinh", df.format(congDan.getNgaySinh()));
    obj.put("nddGioiTinh", congDan.getGioiTinh());
    obj.put("nddQuocTich", congDan.getQuocTichId());
    obj.put("nddDanToc", congDan.getDanTocId());
    obj.put("nddSoCMND", congDan.getSoCmnd());
    obj.put("nddNgayCapCMND", congDan.getNgayCapCmnd() != null ? df.format(congDan.getNgayCapCmnd()) : "");
    obj.put("nddNoiCapCMND", congDan.getNoiCapCmndId() != null ? congDan.getNoiCapCmndId() : 0);
    obj.put("nddTtTinhId", congDan.getDiaChiThuongTruTinhId());
    obj.put("nddTtHuyenId", congDan.getDiaChiThuongTruHuyenId());
    obj.put("nddTtXaId", congDan.getDiaChiThuongTruXaId());
    obj.put("nddTtMoTaDiaChi", congDan.getDiaChiThuongTru());
    obj.put("nddCohtTinhId", congDan.getDiaChiHienNayTinhId());
    obj.put("nddCohtHuyenId", congDan.getDiaChiHienNayHuyenId());
    obj.put("nddCohtXaId", congDan.getDiaChiHienNayXaId());
    obj.put("nddCohtMoTaChoO", congDan.getDiaChiHienNay());
    obj.put("nddDienThoai", congDan.getDienThoaiCoDinh());
    obj.put("nddFax", congDan.getFax());
    obj.put("nddEmail", congDan.getEmail());
    obj.put("nddWebsite", congDan.getWebsite());

    HttpServletResponse resourceResponse = PortalUtil.getHttpServletResponse(actionResponse);
    resourceResponse.setContentType(ContentTypes.APPLICATION_JSON);
    resourceResponse.setCharacterEncoding(StringPool.UTF8);
    resourceResponse.getWriter().write(obj.toString());
    resourceResponse.getWriter().close();
}

From source file:org.oep.egovcore.portlet.AjaxMVCPortlet.java

License:Apache License

/**
  * This is fucntion serveResource/*from   w w w  .  jav a2s .c  om*/
  * Version: 1.0
  *  
  * History: 
  *   DATE        AUTHOR      DESCRIPTION 
  *  ------------------------------------------------- 
  *  3-March-2013  Nam Dinh    Create new
  * @param ResourceRequest request, ResourceResponse response
  * @return void
  */
public final void serveResource(ResourceRequest request, ResourceResponse response)
        throws IOException, PortletException {

    // Tn method
    String methodName = request.getResourceID();
    int status = AjaxResponse.STATUS_OK;
    Method method = null;
    String contentType = request.getContentType();
    UploadPortletRequest urequest = null;
    AjaxResponse ajaxResponse = new AjaxResponse(response);
    ;
    if (contentType != null && contentType.contains(ContentTypes.MULTIPART_FORM_DATA)) {
        urequest = PortalUtil.getUploadPortletRequest(request);
        if (urequest == null) {
            _log.error("UPLOADED FILES GET OVER THE LIMIT OF PORTAL");
            return;
        }
    }

    // Get the method and invoke it
    try {
        if (urequest != null) {

            urequest.setAttribute(KEY_AJAX_RESPONSE, ajaxResponse);

            if (LiferayURL.isAjaxRequest(urequest)) {
                method = this.getClass().getMethod(methodName, UploadPortletRequest.class, AjaxResponse.class);
                method.invoke(this, urequest, ajaxResponse);
            } else {
                method = this.getClass().getMethod(methodName, UploadPortletRequest.class,
                        ResourceResponse.class);
                method.invoke(this, urequest, response);
            }

        } else {

            request.setAttribute(KEY_AJAX_RESPONSE, ajaxResponse);

            if (LiferayURL.isAjaxRequest(request)) {
                method = this.getClass().getMethod(methodName, ResourceRequest.class, AjaxResponse.class);
                method.invoke(this, request, ajaxResponse);
            } else {
                method = this.getClass().getMethod(methodName, ResourceRequest.class, ResourceResponse.class);
                method.invoke(this, request, response);
            }

        }
    } catch (Exception e) {

        // Exception do method nm ra
        if (urequest != null) {
            if (e instanceof InvocationTargetException) {
                handleException(((InvocationTargetException) e).getTargetException(), urequest, response);
            } else {
                handleException(e, urequest, response);
            }
        } else {
            if (e instanceof InvocationTargetException) {
                handleException(((InvocationTargetException) e).getTargetException(), request, response);
            } else {
                handleException(e, request, response);
            }
        }

        status = AjaxResponse.STATUS_EXCEPTION;
    }

    if (ajaxResponse.isUsed()) {
        ajaxResponse.setStatus(status);
        PrintWriter writer = response.getWriter();
        response.setCharacterEncoding(StringPool.UTF8);
        if (urequest != null) {
            response.setContentType(ContentTypes.TEXT_HTML);
        } else {
            response.setContentType(ContentTypes.APPLICATION_JSON);
        }
        writer.write(ajaxResponse.getOutput().toString());
        writer.flush();
        writer.close();
    }
}

From source file:org.xcolab.commons.utils.PwdEncryptor.java

License:Open Source License

private static byte[] _getSaltFromBCrypt(String bcryptString) throws PwdEncryptorException {

    byte[] saltBytes = null;

    try {// w  ww . j a va2s . com
        if (Validator.isNull(bcryptString)) {
            String salt = BCrypt.gensalt();

            saltBytes = salt.getBytes(StringPool.UTF8);
        } else {
            String salt = bcryptString.substring(0, 29);

            saltBytes = salt.getBytes(StringPool.UTF8);
        }
    } catch (UnsupportedEncodingException uee) {
        throw new PwdEncryptorException("Unable to extract salt from encrypted password: " + uee.getMessage());
    }

    return saltBytes;
}