List of usage examples for org.apache.commons.lang StringUtils isNumeric
public static boolean isNumeric(String str)
Checks if the String contains only unicode digits.
From source file:fr.paris.lutece.plugins.stock.modules.billetterie.web.StockBilletterieApp.java
/** * Page for the show/*from w w w .jav a 2 s . co m*/ * * @param page xpage * @param request http request * @param locale locale * @return xpage */ public XPage getShowPage(XPage page, HttpServletRequest request, Locale locale) { String sIdShow = request.getParameter(PARAMETER_PRODUCT_ID); Integer idShow = -1; if (StringUtils.isNotEmpty(sIdShow) && StringUtils.isNumeric(sIdShow)) { idShow = Integer.valueOf(sIdShow); } String sSeanceDate = request.getParameter(PARAMETER_DATE_SEANCE); String strSubscribe = request.getParameter(PARAMETER_SUBSCRIBE); String strPurchaseId = request.getParameter(PARAMETER_PURCHASE_ID); request.getSession().setAttribute(PARAMETER_PURCHASE_ID, strPurchaseId); Integer idPurchase = -1; String strNdPlaceBook = null; Map<String, Object> model = new HashMap<String, Object>(); if (StringUtils.isNotEmpty(strPurchaseId) && StringUtils.isNumeric(strPurchaseId)) { idPurchase = Integer.valueOf(strPurchaseId); ReservationDTO booking = _purchaseService.findById(idPurchase); if (booking != null) { final DateFormat sdfComboSeance = new SimpleDateFormat(TicketsConstants.FORMAT_COMBO_DATE_SEANCE, locale); Date today = new Date(); SeanceDTO seance = booking.getOffer(); String sDateHour = sdfComboSeance.format(seance.getDateHour()); if (seance.getStatut().equals(TicketsConstants.OFFER_STATUT_OPEN) && seance.getDateHour().after(today)) { if (seance.getQuantity() == 0) { sSeanceDate = sDateHour + " - COMPLET"; } else { sSeanceDate = sDateHour; } } } strNdPlaceBook = "" + booking.getQuantity(); request.getSession().setAttribute(PARAMETER_PURCHASE_ID, strPurchaseId); model.put(MARK_IS_MODIFY, idPurchase); } // Get the show ShowDTO show = _showService.getProduct(idShow); // Generates template FunctionnalException fe = getErrorOnce(request); if (fe != null) { model.put(TicketsConstants.PARAMETER_ERROR, getHtmlError(fe, request)); } model.put(MARK_SHOW, show); PartnerDTO partner = _providerService.findByIdWithProducts(show.getIdProvider()); if ((partner != null) && (partner.getDistrict() != null)) { District district = _districtService.findById(partner.getDistrict()); model.put(MARK_DISTRICT, district); } model.put(MARK_PARTNER, partner); model.put(MARK_URL_POSTER, AppPropertiesService.getProperty(PROPERTY_POSTER_PATH)); // Calculate if show is open to book model.put(MARK_BOOKING_OPENED, caculateBookingOpened(show)); // Get seance list SeanceFilter filter = new SeanceFilter(); filter.setOrderAsc(false); List<String> orderList = new ArrayList<String>(); orderList.add(ORDER_FILTER_DATE); filter.setOrders(orderList); model.put(MARK_SEANCE_DATE_LIST, _offerService.findSeanceByShow(show.getId(), filter, locale)); //Get the user LuteceUser currentUser = getUser(request); //check if the user is not ban, don't check for unregistred user if (currentUser != null) { String strEmailHome = currentUser.getUserInfo(LuteceUser.HOME_INFO_ONLINE_EMAIL); String strEmailBusiness = currentUser.getUserInfo(LuteceUser.BUSINESS_INFO_ONLINE_EMAIL); String strEmail = !strEmailHome.equals("") ? strEmailHome : strEmailBusiness; User userBan = _serviceUser.findByPrimaryKey(strEmail); if (userBan != null) { String banMessage = I18nService.getLocalizedString(MESSAGE_MESSAGE_USER_BAN, new String[] { userBan.getMotif() }, locale); model.put(MARK_MESSAGE_USER_BAN, banMessage); } } // If user authenticated, display booking bloc model.put(MARK_USER, currentUser); model.put(MARK_BLOC_RESERVATION, getBookingBloc(show, sSeanceDate, locale, strNdPlaceBook)); model.put(MARK_S_SEANCE_DATE, sSeanceDate); //if the user wants to subscribe to the show (get an email if a new representation is added) if (currentUser != null) { String strEmailHome = currentUser.getUserInfo(LuteceUser.HOME_INFO_ONLINE_EMAIL); String strEmailBusiness = currentUser.getUserInfo(LuteceUser.BUSINESS_INFO_ONLINE_EMAIL); String strEmail = !strEmailHome.equals("") ? strEmailHome : strEmailBusiness; SubscriptionProductJspBean jspBean = new SubscriptionProductJspBean(); boolean isSubscribe = false; //if user want to subscribe or unsubscribe to the product if (strSubscribe != null) { if (strSubscribe.equals(STRING_TRUE)) { jspBean.doSubscribeToProduct(request, currentUser); isSubscribe = true; model.put(MARK_USER_EMAIL, strEmail); } else { jspBean.doUnsubscribeToProduct(request, currentUser); } } else { isSubscribe = jspBean.isSubscribeToProduct(request, currentUser); } if (!isSubscribe) { model.put(MARK_SUBSCRIBE, STRING_TRUE); } else { model.put(MARK_USER_EMAIL, strEmail); } } HtmlTemplate template = AppTemplateService.getTemplate(TEMPLATE_DIR + TEMPLATE_SHOW_PAGE, locale, model); page.setContent(template.getHtml()); page.setPathLabel(show.getName()); page.setTitle(show.getName()); return page; }
From source file:fr.paris.lutece.plugins.contextinclude.web.ContextJspBean.java
/** * Get confirm remove context/*from ww w. j a v a 2 s .c o m*/ * @param request the HTTP request * @return the HTML code */ public String getConfirmRemoveContext(HttpServletRequest request) { String strIdContext = request.getParameter(PARAMETER_ID_CONTEXT); if (StringUtils.isBlank(strIdContext) || !StringUtils.isNumeric(strIdContext)) { return AdminMessageService.getMessageUrl(request, Messages.MANDATORY_FIELDS, AdminMessage.TYPE_STOP); } UrlItem url = new UrlItem(JSP_URL_DO_REMOVE_CONTEXT); url.addParameter(PARAMETER_ID_CONTEXT, strIdContext); return AdminMessageService.getMessageUrl(request, MESSAGE_CONFIRM_REMOVE_CONTEXT, url.getUrl(), AdminMessage.TYPE_CONFIRMATION); }
From source file:gtu._work.ui.DownloadMoveUI.java
private void executeBtnAction() { try {/*from w w w . ja v a2s.c o m*/ logArea.setText(""); Validate.notBlank(downloadDirText.getText(), ""); Validate.notBlank(unCompleteFileSubNameText.getText(), "???"); Validate.notBlank(fileSizeText.getText(), "?"); Validate.isTrue(StringUtils.isNumeric(fileSizeText.getText()), "?"); Validate.notBlank(subFileNameText.getText(), "?????"); File downloadDir = new File(downloadDirText.getText()); Validate.isTrue(downloadDir.exists() && downloadDir.isDirectory(), "?"); BTMovieMove move = new BTMovieMove(); String unCompleteFileSubName = unCompleteFileSubNameText.getText(); if (!unCompleteFileSubName.startsWith(".")) { unCompleteFileSubName = "." + unCompleteFileSubName; } Set<String> set = new HashSet<String>(); for (String subName : subFileNameText.getText().split(",")) { if (!subName.startsWith(".")) { subName = "." + subName; } set.add(subName); } move.setBtUnCompleteFileEnd(unCompleteFileSubName); move.setBigFileSize(Integer.parseInt(fileSizeText.getText()) * 1000);// 5mb move.setMovieDir(downloadDir); move.setDeleteNonWorkingDir(isDeleteBox.isSelected()); move.setMovieSubSet(set); System.out.println(move.getMovieSubSet()); move.execute(); List<String> notContainSubNameList = new ArrayList<String>(); for (String subName : move.getCurrentSubFileNameSet()) { if (!set.contains(subName)) { notContainSubNameList.add(subName); } } move.getLogSb().append("??:" + notContainSubNameList); logArea.setText(move.getLogSb().toString()); } catch (Exception ex) { JCommonUtil.handleException(ex); } }
From source file:fr.paris.lutece.plugins.crm.web.demand.DemandTypeJspBean.java
/** * Manages the removal form of a demand type whose identifier is in the http request * @param request The Http request//from w w w. ja v a 2 s.c o m * @return the html code to confirm */ public String getConfirmRemoveDemandType(HttpServletRequest request) { String strUrl = StringUtils.EMPTY; String strIdDemandType = request.getParameter(CRMConstants.PARAMETER_ID_DEMAND_TYPE); if (StringUtils.isNotBlank(strIdDemandType) && StringUtils.isNumeric(strIdDemandType)) { int nIdDemandType = Integer.parseInt(strIdDemandType); UrlItem url = new UrlItem(JSP_DO_REMOVE_DEMAND_TYPE); url.addParameter(CRMConstants.PARAMETER_ID_DEMAND_TYPE, nIdDemandType); strUrl = AdminMessageService.getMessageUrl(request, CRMConstants.MESSAGE_CONFIRM_REMOVE_DEMAND_TYPE, url.getUrl(), AdminMessage.TYPE_CONFIRMATION); } else { strUrl = AdminMessageService.getMessageUrl(request, CRMConstants.MESSAGE_ERROR, AdminMessage.TYPE_STOP); } return strUrl; }
From source file:de.ma.it.common.excel.ExcelFileManager.java
/** * /*ww w.java 2 s. c o m*/ * @param row * @param cellIdx * @return * @throws IllegalArgumentException */ public Integer readCellAsInt(HSSFRow row, int cellIdx) throws IllegalArgumentException { HSSFCell cell = getCell(row, cellIdx); if (cell == null) { return null; } int cellType = cell.getCellType(); // First evaluate formula if present if (cellType == HSSFCell.CELL_TYPE_FORMULA) { cellType = evaluator.evaluateFormulaCell(cell); } Integer result; switch (cellType) { case HSSFCell.CELL_TYPE_NUMERIC: double numericCellValue = cell.getNumericCellValue(); if (numericCellValue > Integer.MAX_VALUE) { throw new IllegalArgumentException("Value " + numericCellValue + " to big for integer!"); } result = Double.valueOf(numericCellValue).intValue(); break; case HSSFCell.CELL_TYPE_STRING: String stringCellValue = cell.getStringCellValue(); if (!StringUtils.isNumeric(stringCellValue)) { throw new IllegalArgumentException("Value " + stringCellValue + " is not numeric!"); } result = Double.valueOf(stringCellValue).intValue(); break; default: result = Integer.MIN_VALUE; break; } return result; }
From source file:fr.paris.lutece.portal.web.admin.AdminPagePortletJspBean.java
/** * Displays the portlet status modification page * * @param request The http request//from ww w . jav a 2 s . com * @return The confirm page * @throws AccessDeniedException if the user is not authorized to manage the portlet */ public String getModifyPortletStatus(HttpServletRequest request) throws AccessDeniedException { String strPortletId = request.getParameter(Parameters.PORTLET_ID); String strStatus = request.getParameter(PORTLET_STATUS); if (!StringUtils.isNumeric(strPortletId) || !StringUtils.isNumeric(strStatus)) { return AdminMessageService.getMessageUrl(request, Messages.MANDATORY_FIELDS, AdminMessage.TYPE_ERROR); } int nPortletId = Integer.parseInt(strPortletId); Portlet portlet = null; try { portlet = PortletHome.findByPrimaryKey(nPortletId); } catch (NullPointerException e) { AppLogService.error("Error looking for portlet with id " + nPortletId, e); } if (portlet == null || portlet.getId() != nPortletId) { return AdminMessageService.getMessageUrl(request, Messages.MESSAGE_INVALID_ENTRY, new Object[] { nPortletId }, AdminMessage.TYPE_ERROR); } int nStatus = Integer.parseInt(strStatus); if (nStatus != Portlet.STATUS_PUBLISHED && nStatus != Portlet.STATUS_UNPUBLISHED) { return AdminMessageService.getMessageUrl(request, Messages.MESSAGE_INVALID_ENTRY, new Object[] { nStatus }, AdminMessage.TYPE_ERROR); } AdminUser user = AdminUserService.getAdminUser(request); if (!RBACService.isAuthorized(PortletType.RESOURCE_TYPE, portlet.getPortletTypeId(), PortletResourceIdService.PERMISSION_MANAGE, user)) { throw new AccessDeniedException("User " + user + " is not authorized to permission " + PortletResourceIdService.PERMISSION_MANAGE + " on portlet " + nPortletId); } String strUrl = JSP_DO_MODIFY_STATUS + "?portlet_id=" + strPortletId + "&status=" + strStatus; String strTarget = "_top"; return AdminMessageService.getMessageUrl(request, PROPERTY_MESSAGE_CONFIRM_MODIFY_STATUS, strUrl, strTarget, AdminMessage.TYPE_CONFIRMATION); }
From source file:com.impetus.kundera.loader.GenericClientFactory.java
protected void onValidation(final String host, final String port) { if (host == null || !StringUtils.isNumeric(port) || port.isEmpty()) { logger.error("Host or port should not be null / port should be numeric"); throw new IllegalArgumentException("Host or port should not be null / port should be numeric"); }/* w ww .j av a 2 s . co m*/ }
From source file:fr.paris.lutece.plugins.genericalert.web.NotifyReminderTaskComponent.java
/** * {@inheritDoc}// www . j av a 2s .c o m */ @Override public String doSaveConfig(HttpServletRequest request, Locale locale, ITask task) { String strIdForm = request.getParameter(PARAMETER_ID_FORM); String strNbAlerts = request.getParameter(PARAMETER_NB_ALERT); String strApplyNbAlerts = request.getParameter(PARAMETER_APPLY_NB_ALERTS); String strForm = request.getParameter(PARAMETER_APPLY_ID_FORM); List<ReminderAppointment> listAppointment = new ArrayList<ReminderAppointment>(); Boolean bCreate = false; int nIdForm = Integer.parseInt(strIdForm); UrlItem url = new UrlItem(AppPathService.getBaseUrl(request) + JSP_MODIFY_TASK); url.addParameter(PARAMETER_ID_TASK, task.getId()); url.addParameter(PARAMETER_ID_FORM, nIdForm); int nbAlerts = 0; if (strNbAlerts != null) { if (StringUtils.isNotEmpty(strNbAlerts) && StringUtils.isNumeric(strNbAlerts)) { nbAlerts = Integer.parseInt(strNbAlerts); } else { return AdminMessageService.getMessageUrl(request, MESSAGE_ERROR_NB_ALERT_NO_VALID, AdminMessage.TYPE_STOP); } } TaskNotifyReminderConfig config = TaskNotifyReminderConfigHome.findByIdForm(task.getId(), nIdForm); if (config == null) { config = new TaskNotifyReminderConfig(); config.setIdTask(task.getId()); config.setIdForm(nIdForm); config.setListReminderAppointment(new ArrayList<ReminderAppointment>()); bCreate = true; } else { List<ReminderAppointment> listReminder = config.getListReminderAppointment(); if (nbAlerts == 0 && strForm == null) { TaskNotifyReminderConfigHome.removeAppointmentReminder(config.getIdTask(), nIdForm, nbAlerts, true); listReminder.clear(); config.setListReminderAppointment(listReminder); } if (nbAlerts < listReminder.size() && nbAlerts != 0 && strForm == null) { for (int i = nbAlerts + 1; i <= listReminder.size(); i++) { TaskNotifyReminderConfigHome.removeAppointmentReminder(config.getIdTask(), nIdForm, i, false); listReminder.remove(i - 1); } config.setListReminderAppointment(listReminder); } if (nbAlerts != 0 && strApplyNbAlerts == null && strForm == null) { for (int i = 1; i <= nbAlerts; i++) { ReminderAppointment reminderAppointment = new ReminderAppointment(); String strTimeToAlert = request.getParameter(MARK_TIME_ALERT + i); String strEmailNotify = request.getParameter(MARK_EMAIL_NOTIFY + i) == null ? MARK_FALSE : request.getParameter(MARK_EMAIL_NOTIFY + i); String strSmsNotify = request.getParameter(MARK_SMS_NOTIFY + i) == null ? MARK_FALSE : request.getParameter(MARK_SMS_NOTIFY + i); String strEmailAlertMessage = request.getParameter(MARK_EMAIL_ALERT_MESSAGE + i) == null ? StringUtils.EMPTY : request.getParameter(MARK_EMAIL_ALERT_MESSAGE + i); String strSmsAlertMessage = request.getParameter(MARK_SMS_ALERT_MESSAGE + i) == null ? StringUtils.EMPTY : request.getParameter(MARK_SMS_ALERT_MESSAGE + i); String strAlertSubject = request.getParameter(MARK_ALERT_SUBJECT + i) == null ? StringUtils.EMPTY : request.getParameter(MARK_ALERT_SUBJECT + i); String strPhoneNumber = request.getParameter(MARK_NUMBER_PHONE + i) == null ? StringUtils.EMPTY : request.getParameter(MARK_NUMBER_PHONE + i); String strEmailCc = request.getParameter(MARK_EMAIL_CC + i) == null ? StringUtils.EMPTY : request.getParameter(MARK_EMAIL_CC + i); String strIdSateAfter = request.getParameter(MARK_STATUS_WORKFLOW + i) == null ? StringUtils.EMPTY : request.getParameter(MARK_STATUS_WORKFLOW + i); if (StringUtils.isEmpty(strTimeToAlert) || !StringUtils.isNumeric(strTimeToAlert)) { if (strApplyNbAlerts == null && strForm == null) { return AdminMessageService.getMessageUrl(request, MESSAGE_ERROR_ALERT_TIME_NO_VALID, AdminMessage.TYPE_STOP); } } if (strSmsNotify.equals(MARK_FALSE) && strEmailNotify.equals(MARK_FALSE)) { if (strApplyNbAlerts == null && strForm == null) { return AdminMessageService.getMessageUrl(request, MESSAGE_ERROR_NOTIFY_TYPE_EMPTY, AdminMessage.TYPE_STOP); } } if (!strSmsNotify.equals(MARK_FALSE) && StringUtils.isEmpty(strPhoneNumber)) { if (strApplyNbAlerts == null && strForm == null) { return AdminMessageService.getMessageUrl(request, MESSAGE_ERROR_NUMBER_PHONE_EMPTY, AdminMessage.TYPE_STOP); } } if (StringUtils.isEmpty(strIdSateAfter)) { if (strApplyNbAlerts == null && strForm == null) { return AdminMessageService.getMessageUrl(request, MESSAGE_ERROR_STATUS_EMPTY, AdminMessage.TYPE_STOP); } } if (StringUtils.isEmpty(strAlertSubject)) { if (strApplyNbAlerts == null && strForm == null) { return AdminMessageService.getMessageUrl(request, MESSAGE_ERROR_SUBJECT_EMPTY, AdminMessage.TYPE_STOP); } } if (StringUtils.isEmpty(strEmailAlertMessage) && Boolean.parseBoolean(strEmailNotify)) { if (strApplyNbAlerts == null && strForm == null) { return AdminMessageService.getMessageUrl(request, MESSAGE_ERROR_EMAIL_TEXT_EMPTY, AdminMessage.TYPE_STOP); } } if (StringUtils.isEmpty(strSmsAlertMessage) && Boolean.parseBoolean(strSmsNotify)) { if (strApplyNbAlerts == null && strForm == null) { return AdminMessageService.getMessageUrl(request, MESSAGE_ERROR_SMS_TEXT_EMPTY, AdminMessage.TYPE_STOP); } } else { reminderAppointment.setIdTask(config.getIdTask()); reminderAppointment.setIdForm(nIdForm); reminderAppointment.setRank(i); reminderAppointment.setTimeToAlert(Integer.parseInt(strTimeToAlert)); reminderAppointment.setEmailNotify(Boolean.parseBoolean(strEmailNotify)); reminderAppointment.setSmsNotify(Boolean.parseBoolean(strSmsNotify)); reminderAppointment.setEmailAlertMessage(strEmailAlertMessage); reminderAppointment.setSmsAlertMessage(strSmsAlertMessage); reminderAppointment.setAlertSubject(strAlertSubject); reminderAppointment.setNumberPhone(strPhoneNumber); reminderAppointment.setEmailCc(strEmailCc); reminderAppointment.setIdStateAfter(Integer.parseInt(strIdSateAfter)); listAppointment.add(reminderAppointment); } } } config.setIdForm(nIdForm); } if (strForm == null) { if (listAppointment.size() > 0) { config.setListReminderAppointment(listAppointment); } config.setNbAlerts(nbAlerts); if (bCreate) { _taskNotifyReminderConfigService.create(config); } else { _taskNotifyReminderConfigService.update(config); } } if (strApplyNbAlerts != null || strForm != null) { return AppPathService.getBaseUrl(request) + JSP_MODIFY_TASK + "?" + PARAMETER_ID_TASK + "=" + task.getId() + "&" + PARAMETER_ID_FORM + "=" + nIdForm; } return null; }
From source file:com.greenline.guahao.web.module.home.controllers.vip.taikang.TaiKangController.java
/** * //from w w w . j av a 2s .c om * * @param users * @return UserFastLoginDO */ private UserFastLoginDO setLoginDO(String[] users) { UserFastLoginDO userFastLoginDO = new UserFastLoginDO(); String id = users[0].split("=")[1]; String name = users[1].split("=")[1]; if (id.length() > 64) { userFastLoginDO.setUserId(id.substring(0, 64)); } else { userFastLoginDO.setUserId(id); } if (name.length() > 50) { userFastLoginDO.setRealName(name.substring(0, 50)); } else { userFastLoginDO.setRealName(name); } if (null != users[2].split("=") && users[2].split("=").length == 2) { // ? String idcard = users[2].split("=")[1]; userFastLoginDO.setCertType(CertTypEnum.IDCARD.getValue()); userFastLoginDO.setCertNo(idcard); } if (null != users[3].split("=") && users[3].split("=").length == 2) { // String email = users[3].split("=")[1]; userFastLoginDO.setEmail(email); } if (null != users[4].split("=") && users[4].split("=").length == 2) { // String mobile = users[4].split("=")[1]; userFastLoginDO.setMobile(mobile); } if (null != users[5].split("=") && users[5].split("=").length == 2) { // String sex = users[5].split("=")[1]; if (StringUtils.isNumeric(sex)) { userFastLoginDO.setSex(Integer.valueOf(sex)); } } return userFastLoginDO; }
From source file:ips1ap101.lib.core.db.util.Exporter.java
static ExporterMessage export(String report, String number, String userid, String target, String format, String select, Object[] args, boolean logging) { Bitacora.trace(Exporter.class, "export", report, number, target, format); String informe = StringUtils.trimToEmpty(report); Long rastro = trimToNullNumber(number); Long usuario = StringUtils.isNotBlank(userid) && StringUtils.isNumeric(userid) ? Long.valueOf(userid) : null;//from ww w .j a v a 2s.c om String destino = trimToNullTarget(target); EnumFormatoArchivo tipo = getExportType(format); String decode = Utils.decodeSelect(trimToNullSelect(select)); return export(informe, rastro, usuario, destino, tipo, decode, false, args, logging); }