List of usage examples for com.liferay.portal.kernel.util StringPool UTF8
String UTF8
To view the source code for com.liferay.portal.kernel.util StringPool UTF8.
Click Source Link
From source file:it.smc.calendar.sync.caldav.CalendarBookingResourceImpl.java
License:Open Source License
@Override public InputStream getContentAsStream() throws WebDAVException { try {/* w ww . j a va2 s. c om*/ String data = CalendarBookingServiceUtil.exportCalendarBooking(_calendarBooking.getCalendarBookingId(), CalendarDataFormat.ICAL.getValue()); return new UnsyncByteArrayInputStream(data.getBytes(StringPool.UTF8)); } catch (Exception e) { throw new WebDAVException(e); } }
From source file:it.smc.calendar.sync.caldav.CalendarResourceImpl.java
License:Open Source License
@Override public InputStream getContentAsStream() throws WebDAVException { try {//from w ww . j av a 2 s .c o m String data = CalendarServiceUtil.exportCalendar(_calendar.getCalendarId(), CalendarDataFormat.ICAL.getValue()); return new UnsyncByteArrayInputStream(data.getBytes(StringPool.UTF8)); } catch (Exception e) { throw new WebDAVException(e); } }
From source file:jorgediazest.missingrefchecker.portlet.MissingReferencesCheckerPortlet.java
License:Open Source License
@SuppressWarnings("unchecked") public void doView(RenderRequest renderRequest, RenderResponse renderResponse) throws IOException, PortletException { PortletConfig portletConfig = (PortletConfig) renderRequest .getAttribute(JavaConstants.JAVAX_PORTLET_CONFIG); List<String> outputList = null; List<MissingRefInfo> listMissingRefInfo = (List<MissingRefInfo>) renderRequest .getAttribute("missingReferencesList"); if (listMissingRefInfo != null) { outputList = MissingRefCheckerOutput.generateCSVOutputCheckReferences(portletConfig, renderRequest.getLocale(), listMissingRefInfo); }/*from www . jav a 2 s .c om*/ Map<Reference, Reference> references = (Map<Reference, Reference>) renderRequest .getAttribute("referencesMap"); if (references != null) { outputList = MissingRefCheckerOutput.generateCSVOutputMappingList(portletConfig, renderRequest.getLocale(), references); } String outputScript = OutputUtils.listStringToString(outputList); FileEntry exportCsvFileEntry = null; try { InputStream inputStream = null; if (Validator.isNotNull(outputScript)) { inputStream = new ByteArrayInputStream(outputScript.getBytes(StringPool.UTF8)); } String portletId = portletConfig.getPortletName(); Repository repository = OutputUtils.getPortletRepository(portletId); OutputUtils.cleanupPortletFileEntries(repository, 8 * 60); long userId = PortalUtil.getUserId(renderRequest); String fileName = "missing-references_output_" + userId + "_" + System.currentTimeMillis() + ".csv"; exportCsvFileEntry = OutputUtils.addPortletFileEntry(repository, inputStream, userId, fileName, "text/plain"); if (exportCsvFileEntry != null) { ResourceURL exportCsvResourceURL = renderResponse.createResourceURL(); exportCsvResourceURL.setResourceID(exportCsvFileEntry.getTitle()); renderRequest.setAttribute("exportCsvResourceURL", exportCsvResourceURL.toString()); } } catch (Exception e) { _log.error(e, e); } super.doView(renderRequest, renderResponse); }
From source file:jorgediazest.stagingchecker.portlet.StagingCheckerPortlet.java
License:Open Source License
public void doView(RenderRequest renderRequest, RenderResponse renderResponse) throws IOException, PortletException { PortletConfig portletConfig = (PortletConfig) renderRequest .getAttribute(JavaConstants.JAVAX_PORTLET_CONFIG); List<String> outputList = StagingCheckerOutput.generateCSVOutput(portletConfig, renderRequest); String outputScript = OutputUtils.listStringToString(outputList); FileEntry exportCsvFileEntry = null; try {/* w ww .j av a 2s .c o m*/ InputStream inputStream = null; if (Validator.isNotNull(outputScript)) { inputStream = new ByteArrayInputStream(outputScript.getBytes(StringPool.UTF8)); } String portletId = portletConfig.getPortletName(); Repository repository = OutputUtils.getPortletRepository(portletId); OutputUtils.cleanupPortletFileEntries(repository, 8 * 60); long userId = PortalUtil.getUserId(renderRequest); String fileName = "staging-checker_output_" + userId + "_" + System.currentTimeMillis() + ".csv"; exportCsvFileEntry = OutputUtils.addPortletFileEntry(repository, inputStream, userId, fileName, "text/plain"); if (exportCsvFileEntry != null) { ResourceURL exportCsvResourceURL = renderResponse.createResourceURL(); exportCsvResourceURL.setResourceID(exportCsvFileEntry.getTitle()); renderRequest.setAttribute("exportCsvResourceURL", exportCsvResourceURL.toString()); } } catch (Exception e) { _log.error(e, e); } try { List<Long> siteGroupIds = this.getSiteGroupIds(); renderRequest.setAttribute("groupIdList", siteGroupIds); List<String> groupDescriptionList = getSiteGroupDescriptions(siteGroupIds); renderRequest.setAttribute("groupDescriptionList", groupDescriptionList); } catch (SystemException se) { throw new PortletException(se); } try { List<Model> modelList = this.getModelList(); renderRequest.setAttribute("modelList", modelList); } catch (SystemException se) { throw new PortletException(se); } int numberOfThreads = getNumberOfThreads(renderRequest); renderRequest.setAttribute("numberOfThreads", numberOfThreads); super.doView(renderRequest, renderResponse); }
From source file:org.joget.plugin.liferay.util.PasswordEncrypt.java
License:Open Source License
private static byte[] _getSaltFromBCrypt(String bcryptString) { byte[] saltBytes = null; try {/*from ww w. ja v a2 s . c om*/ 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) { } return saltBytes; }
From source file:org.oep.cmon.portlet.admin.congchuc.action.CongChucPortlet.java
License:Apache License
/** * This is function save CoQuanQuanLy//www .j a v a 2 s . c om * Version: 1.0 * * History: * DATE AUTHOR DESCRIPTION * ------------------------------------------------- * 3-March-2013 Nam Dinh Create new * @param request * @param response * @throws Exception */ public void saveCoQuanQuanLy(ActionRequest request, ActionResponse response) throws Exception { String type = ParamUtil.getString(request, "type", ""); String searchInputText = ParamUtil.getString(request, "searchInputText", ""); String parentId = ParamUtil.getString(request, "parentId", ""); List<String> errors = CongChucUtils.validCoQuanQuanLy(request); Map<String, String> userRequest = CongChucUtils.getMapCQQLFromRequest(request); if (errors.isEmpty()) { request.setAttribute("searchInputText", URLDecoder.decode(searchInputText, StringPool.UTF8)); if (type.equals("add")) { try { CongChucUtils.insertCoQuanQuanLy(userRequest, request); SessionMessages.add(request, "coquanquanly.success.create"); } catch (Exception e) { response.setRenderParameter("jspPage", PageError); } } else { try { CongChucUtils.updateCoQuanQuanLy(userRequest, request); SessionMessages.add(request, "coquanquanly.success.update"); } catch (Exception e) { response.setRenderParameter("jspPage", PageError); } } } else { for (int i = 0; i < errors.size(); i++) { SessionErrors.add(request, errors.get(i)); } List<CapCoQuanQuanLy> listCapCoQuanQuanLy = CapCoQuanQuanLyLocalServiceUtil.findByTrangThai(0); request.setAttribute("CQQL_OBJECT", userRequest); request.setAttribute("listCapCoQuanQuanLy", listCapCoQuanQuanLy); request.setAttribute("searchInputText", searchInputText); response.setRenderParameter("jspPage", createCoQuanQuanLyJSP); } request.setAttribute("type", type); request.setAttribute("parentId", parentId); }
From source file:org.oep.cmon.portlet.admin.congchuc.action.CongChucPortlet.java
License:Apache License
/** * This is function delete CoQuanQuanLy * Version: 1.0/* www .java 2s. c o m*/ * * History: * DATE AUTHOR DESCRIPTION * ------------------------------------------------- * 3-March-2013 Nam Dinh Create new * @param request * @param response * @throws Exception */ public void deleteCoQuanQuanLy(ActionRequest request, ActionResponse response) throws Exception { long id = ParamUtil.getLong(request, "coQuanQuanLyId"); String searchInputText = URLDecoder.decode(ParamUtil.getString(request, "searchInputText", ""), StringPool.UTF8); String parentId = ParamUtil.getString(request, "parentId", ""); request.setAttribute("searchInputText", searchInputText); request.setAttribute("parentId", parentId); List<CoQuanQuanLy> lst = CoQuanQuanLyLocalServiceUtil.findByParentId(id, 0); List<CongChuc> lcc = CongChucLocalServiceUtil.listCongChuc(id, "", 0, 1); if (lst.size() > 0) { SessionErrors.add(request, "coquanquanly.err.childExists"); return; } if (lcc.size() > 0) { SessionErrors.add(request, "coquanquanly.err.congChucExists"); return; } try { List<ChucVu2VaiTro> listChucVu2VaiTro = ChucVu2VaiTroLocalServiceUtil.findByIdCoQuanQuanLy(id); for (int i = 0; i < listChucVu2VaiTro.size(); i++) { ChucVu2VaiTroLocalServiceUtil.deleteChucVu2VaiTro(listChucVu2VaiTro.get(i)); } CongChucUtils.delete(id); SessionMessages.add(request, "coquanquanly.success.delete"); } catch (Exception e) { e.printStackTrace(); SessionErrors.add(request, "coquanquanly.err.unKnown"); return; } }
From source file:org.oep.cmon.portlet.admin.congchuc.action.CongChucPortlet.java
License:Apache License
/** * This is function save CongChuc/*from w w w . j a v a2s . 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 saveCongChuc(ActionRequest actionRequest, ActionResponse actionResponse) throws Exception { String coQuanQuanLyId = ParamUtil.getString(actionRequest, "coQuanQuanLyId", ""); String maOrTenOrEmail = ParamUtil.getString(actionRequest, "maOrTenOrEmail", ""); String emailForm = ParamUtil.getString(actionRequest, "email", ""); String tab = ParamUtil.getString(actionRequest, "tab", "CC"); long id = ParamUtil.getLong(actionRequest, "id", 0); User currentUser = PortalUtil.getUser(actionRequest); if (currentUser == null) { SessionErrors.add(actionRequest, "not.login.error"); } CongChuc congChuc = null; if (id > 0) { congChuc = CongChucLocalServiceUtil.fetchCongChuc(id); } else { congChuc = new CongChucClp(); } try { congChuc = this.getCongChucFormHtml(congChuc, actionRequest); } catch (Exception e1) { e1.printStackTrace(); } TaiKhoanNguoiDung taiKhoan = new TaiKhoanNguoiDungClp(); CoQuanQuanLy coQuanQuanLy = CoQuanQuanLyLocalServiceUtil.fetchCoQuanQuanLy(congChuc.getCoQuanQuanLyId()); ChucVu chucVu = null; if (congChuc.getChucVuId() > 0) { chucVu = ChucVuLocalServiceUtil.getChucVu(congChuc.getChucVuId()); } List<String> errors = CongChucUtils.validCongChuc(actionRequest); if (errors.isEmpty() && currentUser != null) { String password = (ParamUtil.getString(actionRequest, "password", "")); String rePassword = ParamUtil.getString(actionRequest, "rePassword", ""); String email = (ParamUtil.getString(actionRequest, "email", "")); boolean flag = true; if (id == 0) { //truong hop them moi flag = LiferayUtils.addUser(congChuc.getHoVaTen(), email, password, rePassword, currentUser.getUserId(), currentUser.getCompanyId()); if (flag) { User user = UserLocalServiceUtil.getUserByEmailAddress(currentUser.getCompanyId(), email); try { String loaiDoiTuongId = ThamSoLocalServiceUtil.getValue("LDT_CANBO"); taiKhoan.setId( CounterLocalServiceUtil.increment(TaoCongDanBusiness.TAIKHOANNGUOIDUNG_SEQUENCE)); taiKhoan.setTaiKhoanNguoiDungId(user.getUserId()); taiKhoan.setNgayTao(new Date()); taiKhoan.setNguoiTao(currentUser.getFullName()); taiKhoan.setTenNguoiDung(congChuc.getHoVaTen()); taiKhoan.setTenDangNhap(email); taiKhoan.setLoaiDoiTuongId(Long.valueOf(loaiDoiTuongId)); taiKhoan.setEmail(email); taiKhoan.setMatKhau(CongChucUtils.md5(password)); taiKhoan.setTrangThai(1); TaiKhoanNguoiDung taiKhoanResult = TaiKhoanNguoiDungLocalServiceUtil .addTaiKhoanNguoiDung(taiKhoan); if (taiKhoanResult != null) { try { congChuc.setId(CounterLocalServiceUtil.increment("cmon_congchuc")); congChuc.setNgayTao(new Date()); congChuc.setTaiKhoanNguoiDungId(taiKhoanResult.getId()); congChuc.setNguoiTao(currentUser.getFullName()); CongChuc congChucReturn = CongChucLocalServiceUtil.addCongChuc(congChuc); if (chucVu != null) { CongChucUtils.ganChucVuToCanBo(congChucReturn, coQuanQuanLy, chucVu); } SessionMessages.add(actionRequest, "insert.success"); actionRequest.setAttribute("coQuanQuanLyId", String.valueOf(coQuanQuanLyId)); actionRequest.setAttribute("maOrTenOrEmail", URLDecoder.decode(maOrTenOrEmail, StringPool.UTF8)); actionRequest.setAttribute("tab", tab); } catch (Exception e) { TaiKhoanNguoiDungLocalServiceUtil.deleteTaiKhoanNguoiDung(taiKhoanResult); UserLocalServiceUtil.deleteUser(user); actionResponse.setRenderParameter("jspPage", PageError); return; } } } catch (Exception e) { UserLocalServiceUtil.deleteUser(user); actionResponse.setRenderParameter("jspPage", PageError); return; } } else { actionResponse.setRenderParameter("jspPage", PageError); return; } } else { //Truong hop chinh sua try { taiKhoan = TaiKhoanNguoiDungLocalServiceUtil .fetchTaiKhoanNguoiDung(congChuc.getTaiKhoanNguoiDungId()); User user = UserLocalServiceUtil.fetchUser(taiKhoan.getTaiKhoanNguoiDungId()); if (user == null) { LiferayUtils.addUser(congChuc.getHoVaTen(), email, "huynq", "huynq", currentUser.getUserId(), currentUser.getCompanyId()); user = UserLocalServiceUtil.getUserByEmailAddress(currentUser.getCompanyId(), taiKhoan.getEmail()); } else { user.setFirstName(congChuc.getHoVaTen()); user.setEmailAddress(email); user.setModifiedDate(new Date()); UserLocalServiceUtil.updateUser(user); } CongChuc currentCongChuc = CongChucLocalServiceUtil.fetchCongChuc(id); if (chucVu != null) { CongChucUtils.xoaChucVuToCanBo(currentCongChuc, CoQuanQuanLyLocalServiceUtil .fetchCoQuanQuanLy(currentCongChuc.getCoQuanQuanLyId())); CongChucUtils.ganChucVuToCanBo(congChuc, coQuanQuanLy, chucVu); } else { CongChucUtils.xoaChucVuToCanBo(currentCongChuc, CoQuanQuanLyLocalServiceUtil .fetchCoQuanQuanLy(currentCongChuc.getCoQuanQuanLyId())); } taiKhoan.setNgaySua(new Date()); taiKhoan.setNguoiSua(currentUser.getFullName()); taiKhoan.setTenNguoiDung(congChuc.getHoVaTen()); taiKhoan.setTenDangNhap(email); taiKhoan.setEmail(email); taiKhoan.setTaiKhoanNguoiDungId(user.getUserId()); TaiKhoanNguoiDung taiKhoanResult = TaiKhoanNguoiDungLocalServiceUtil .updateTaiKhoanNguoiDung(taiKhoan); congChuc.setNgaySua(new Date()); congChuc.setTaiKhoanNguoiDungId(taiKhoanResult.getId()); congChuc.setNguoiSua(currentUser.getFullName()); CongChucLocalServiceUtil.updateCongChuc(congChuc); SessionMessages.add(actionRequest, "update.success"); actionRequest.setAttribute("coQuanQuanLyId", String.valueOf(coQuanQuanLyId)); actionRequest.setAttribute("maOrTenOrEmail", URLDecoder.decode(maOrTenOrEmail, StringPool.UTF8)); actionRequest.setAttribute("tab", tab); } catch (Exception e) { actionResponse.setRenderParameter("jspPage", PageError); return; } } } else { for (int i = 0; i < errors.size(); i++) { SessionErrors.add(actionRequest, errors.get(i)); } actionRequest.setAttribute("coQuanQuanLyId", String.valueOf(coQuanQuanLyId)); actionRequest.setAttribute("maOrTenOrEmail", maOrTenOrEmail); actionRequest.setAttribute("emailForm", emailForm); actionRequest.setAttribute("congChuc", congChuc); actionRequest.setAttribute("taiKhoan", taiKhoan); actionRequest.setAttribute("coQuanQuanLy", coQuanQuanLy); actionResponse.setRenderParameter("jspPage", PageEditCongChuc); } }
From source file:org.oep.cmon.portlet.admin.congchuc.action.CongChucPortlet.java
License:Apache License
/** * This is function delete CongChuc/*from w w w. jav a2s . co m*/ * Version: 1.0 * * History: * DATE AUTHOR DESCRIPTION * ------------------------------------------------- * 3-March-2013 Nam Dinh Create new * @param actionRequest * @param actionResponse * @throws UnsupportedEncodingException */ public void deleteCongChuc(ActionRequest actionRequest, ActionResponse actionResponse) throws UnsupportedEncodingException { String congChucId = ParamUtil.getString(actionRequest, "congChucId"); String tab = ParamUtil.getString(actionRequest, "tab", "CC"); String coQuanQuanLyId = ParamUtil.getString(actionRequest, "coQuanQuanLyId", ""); String maOrTenOrEmail = URLDecoder.decode(ParamUtil.getString(actionRequest, "maOrTenOrEmail", ""), StringPool.UTF8); try { CongChuc congChuc = CongChucLocalServiceUtil.fetchCongChuc(Long.valueOf(congChucId)); if (congChuc != null) { TaiKhoanNguoiDung taiKhoan = TaiKhoanNguoiDungLocalServiceUtil .fetchTaiKhoanNguoiDung(congChuc.getTaiKhoanNguoiDungId()); if (taiKhoan != null) { User user = UserLocalServiceUtil.fetchUser(taiKhoan.getTaiKhoanNguoiDungId()); if (user != null) { CongChucLocalServiceUtil.deleteCongChuc(congChuc); List<NguoiDung2VaiTro> listNguoiDung2VaiTro = NguoiDung2VaiTroLocalServiceUtil .findByTaiKhoanNguoiDungID(taiKhoan.getId(), 0); for (int i = 0; i < listNguoiDung2VaiTro.size(); i++) { NguoiDung2VaiTroLocalServiceUtil.deleteNguoiDung2VaiTro(listNguoiDung2VaiTro.get(i)); } TaiKhoanNguoiDungLocalServiceUtil.deleteTaiKhoanNguoiDung(taiKhoan); UserLocalServiceUtil.deleteUser(user); SessionMessages.add(actionRequest, "delete.success"); } else { SessionErrors.add(actionRequest, "delete.error"); } } else { SessionErrors.add(actionRequest, "delete.error"); } } else { SessionErrors.add(actionRequest, "delete.error"); } } catch (Exception e) { actionResponse.setRenderParameter("jspPage", PageError); return; } actionRequest.setAttribute("coQuanQuanLyId", String.valueOf(coQuanQuanLyId)); actionRequest.setAttribute("maOrTenOrEmail", maOrTenOrEmail); actionRequest.setAttribute("tab", tab); }
From source file:org.oep.cmon.portlet.admin.congchuc.action.CongChucPortlet.java
License:Apache License
/** * This is function get data ChucVu/*w w w . j av a2 s .c o m*/ * Version: 1.0 * * History: * DATE AUTHOR DESCRIPTION * ------------------------------------------------- * 3-March-2013 Nam Dinh Create new * @param actionRequest * @param actionResponse * @throws IOException * @throws PortletException * @throws NumberFormatException * @throws SystemException */ public void getDataChucVu(ActionRequest actionRequest, ActionResponse actionResponse) throws IOException, PortletException, NumberFormatException, SystemException { String coQuanQuanLyId = ParamUtil.getString(actionRequest, "coQuanQuanLyId"); JSONArray rows = JSONFactoryUtil.getJSONFactory().createJSONArray(); List<ChucVu> listChucVu = new ArrayList<ChucVu>(); if (!Helpers.isEmpty(coQuanQuanLyId)) { listChucVu = ChucVuLocalServiceUtil.findByCoQuanQuanLy(Long.valueOf(coQuanQuanLyId), 0); } for (ChucVu item : listChucVu) { JSONObject obj = JSONFactoryUtil.getJSONFactory().createJSONObject(); obj.put("id", item.getId()); obj.put("name", item.getTen()); rows.put(obj); } HttpServletResponse resourceResponse = PortalUtil.getHttpServletResponse(actionResponse); resourceResponse.setContentType(ContentTypes.APPLICATION_JSON); resourceResponse.setCharacterEncoding(StringPool.UTF8); resourceResponse.getWriter().write(rows.toString()); resourceResponse.getWriter().close(); }