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.crm.web.category.CategoryJspBean.java
/** * Handles the removal form of a category * @param request The Http request/*w w w . j a v a2s. c om*/ * @return the jsp URL to display the form to manage categorys */ public String doRemoveCategory(HttpServletRequest request) { String strUrl = StringUtils.EMPTY; String strCategoryId = request.getParameter(CRMConstants.PARAMETER_CATEGORY_ID_CATEGORY); if (StringUtils.isNotBlank(strCategoryId) && StringUtils.isNumeric(strCategoryId)) { int nId = Integer.parseInt(strCategoryId); String strError = _categoryService.removeCategory(nId, getLocale()); if (StringUtils.isBlank(strError)) { strUrl = JSP_REDIRECT_TO_MANAGE_CATEGORIES; } else { Object[] args = { strError }; strUrl = AdminMessageService.getMessageUrl(request, CRMConstants.MESSAGE_CANNOT_REMOVE_CATEGORY, args, AdminMessage.TYPE_STOP); } } else { strUrl = AdminMessageService.getMessageUrl(request, CRMConstants.MESSAGE_ERROR, AdminMessage.TYPE_STOP); } return strUrl; }
From source file:fr.paris.lutece.plugins.extend.modules.comment.web.CommentJspBean.java
/** * Do remove comment.//from w ww . jav a2s. co m * * @param request the request * @return the string */ public String doRemoveComment(HttpServletRequest request) { String strIdComment = request.getParameter(CommentConstants.PARAMETER_ID_COMMENT); if (StringUtils.isNotBlank(strIdComment) && StringUtils.isNumeric(strIdComment)) { int nIdComment = Integer.parseInt(strIdComment); Comment comment = _commentService.findByPrimaryKey(nIdComment); if (comment != null) { try { _commentService.remove(nIdComment); } catch (Exception ex) { // Something wrong happened... a database check might be needed AppLogService.error(ex.getMessage() + " when updating a comment", ex); return AdminMessageService.getMessageUrl(request, CommentConstants.MESSAGE_ERROR_GENERIC_MESSAGE, AdminMessage.TYPE_ERROR); } String strPostBackUrl = (String) request.getSession().getAttribute( CommentPlugin.PLUGIN_NAME + CommentConstants.SESSION_COMMENT_ADMIN_POST_BACK_URL); request.getSession().setAttribute( CommentPlugin.PLUGIN_NAME + CommentConstants.SESSION_COMMENT_ADMIN_POST_BACK_URL, null); if (StringUtils.isEmpty(strPostBackUrl)) { strPostBackUrl = JSP_VIEW_EXTENDER_INFO; } UrlItem url = new UrlItem(strPostBackUrl); url.addParameter(CommentConstants.PARAMETER_EXTENDER_TYPE, CommentResourceExtender.EXTENDER_TYPE_COMMENT); url.addParameter(CommentConstants.PARAMETER_ID_EXTENDABLE_RESOURCE, comment.getIdExtendableResource()); url.addParameter(CommentConstants.PARAMETER_EXTENDABLE_RESOURCE_TYPE, comment.getExtendableResourceType()); if (comment.getIdParentComment() > 0) { url.addParameter(CommentConstants.PARAMETER_ID_COMMENT, comment.getIdParentComment()); } url.addParameter(CommentConstants.PARAMETER_FROM_URL, StringUtils.replace(request.getParameter(CommentConstants.PARAMETER_FROM_URL), CommentConstants.CONSTANT_AND, CommentConstants.CONSTANT_AND_HTML)); return url.getUrl(); } } return AdminMessageService.getMessageUrl(request, Messages.MANDATORY_FIELDS, AdminMessage.TYPE_STOP); }
From source file:fr.paris.lutece.plugins.directory.modules.rest.service.DirectoryRestService.java
/** * {@inheritDoc}// w w w.j a v a 2 s. co m */ @Override public List<Integer> getIdsEntry(int nIdDirectory, HttpServletRequest request) { List<Integer> listIdsEntry = new ArrayList<Integer>(); String[] strIdsEntry = request.getParameterValues(DirectoryRestConstants.PARAMETER_ID_ENTRY_FILTER); if (strIdsEntry != null) { Plugin pluginDirectory = PluginService.getPlugin(DirectoryPlugin.PLUGIN_NAME); for (String strIdEntry : strIdsEntry) { if (StringUtils.isNotBlank(strIdEntry) && StringUtils.isNumeric(strIdEntry)) { // Check if the entry in the parameter is indeed from the directory int nIdEntry = Integer.parseInt(strIdEntry); IEntry entry = EntryHome.findByPrimaryKey(nIdEntry, pluginDirectory); if ((entry != null) && (entry.getDirectory() != null) && (entry.getDirectory().getIdDirectory() == nIdDirectory)) { listIdsEntry.add(nIdEntry); } } } } else { listIdsEntry = getIdsEntry(nIdDirectory); } return listIdsEntry; }
From source file:com.evolveum.midpoint.web.page.admin.roles.component.MultiplicityPolicyDialog.java
private IValidator<String> prepareMultiplicityValidator() { return new IValidator<String>() { @Override/*from ww w .ja v a2s . c o m*/ public void validate(IValidatable<String> toValidate) { String multiplicity = toValidate.getValue(); if (!StringUtils.isNumeric(multiplicity) && !multiplicity.equals(MULTIPLICITY_UNBOUNDED)) { error(getString("MultiplicityPolicyDialog.message.invalidMultiplicity")); } } }; }
From source file:com.cloud.network.bigswitch.BigSwitchBcfUtils.java
public TopologyData getTopology(long physicalNetworkId) { List<NetworkVO> networks; List<NicVO> nics;// ww w . j av a 2s . c o m networks = _networkDao.listByPhysicalNetworkTrafficType(physicalNetworkId, TrafficType.Guest); TopologyData topo = new TopologyData(); // networks: // - all user created networks (VPC or non-VPC) // - one external network // routers: // - per VPC (handle in network loop) // - per stand-alone network (handle in network loop) // - one external router // handle external network first, only if NAT service is enabled if (networks != null) { if (!(networks.isEmpty()) && isNatEnabled()) { // get public net info - needed to set up source nat gateway NetworkVO pubNet = getPublicNetwork(physicalNetworkId); // locate subnet info SearchCriteria<VlanVO> sc = _vlanDao.createSearchCriteria(); sc.setParameters("network_id", pubNet.getId()); VlanVO vlanVO = _vlanDao.findOneBy(sc); // add tenant external network external TopologyData.Network network = topo.new Network(); network.setId("external"); network.setName("external"); network.setTenantId("external"); network.setTenantName("external"); String pubVlan = null; try { pubVlan = BroadcastDomainType.getValue(vlanVO.getVlanTag()); if (StringUtils.isNumeric(pubVlan)) { network.setVlan(Integer.valueOf(pubVlan)); } else { // untagged pubVlan = "0"; } } catch (URISyntaxException e) { e.printStackTrace(); } topo.addNetwork(network); } } // routerMap used internally for multiple updates to same tenant's router // add back to topo.routers after loop HashMap<String, RouterData> routerMap = new HashMap<String, RouterData>(); for (NetworkVO netVO : networks) { TopologyData.Network network = topo.new Network(); network.setId(netVO.getUuid()); network.setName(netVO.getName()); Integer vlan = null; if (netVO.getBroadcastUri() != null) { String vlanStr = BroadcastDomainType.getValue(netVO.getBroadcastUri()); if (StringUtils.isNumeric(vlanStr)) { vlan = Integer.valueOf(vlanStr); } else { // untagged vlan = 0; } } network.setVlan(vlan); network.setState(netVO.getState().name()); nics = _nicDao.listByNetworkId(netVO.getId()); List<Port> ports = new ArrayList<Port>(); String tenantId = null; String tenantName = null; // if VPC network, assign BCF tenant id with vpc uuid Vpc vpc = null; if (netVO.getVpcId() != null) { vpc = _vpcDao.acquireInLockTable(netVO.getVpcId()); } if (vpc != null) { tenantId = vpc.getUuid(); tenantName = vpc.getName(); } else { tenantId = netVO.getUuid(); tenantName = netVO.getName(); } for (NicVO nic : nics) { NetworkData netData = new NetworkData(); TopologyData.Port p = topo.new Port(); p.setAttachmentInfo(netData.new AttachmentInfo(nic.getUuid(), nic.getMacAddress())); VMInstanceVO vm = _vmDao.findById(nic.getInstanceId()); HostVO host = _hostDao.findById(vm.getHostId()); // if host not found, ignore this nic if (host == null) { continue; } String hostname = host.getName(); long zoneId = netVO.getDataCenterId(); String vmwareVswitchLabel = _networkModel.getDefaultGuestTrafficLabel(zoneId, HypervisorType.VMware); String[] labelArray = null; String vswitchName = null; if (vmwareVswitchLabel != null) { labelArray = vmwareVswitchLabel.split(","); vswitchName = labelArray[0]; } // hypervisor type: // kvm: ivs port name // vmware: specific portgroup naming convention String pgName = ""; if (host.getHypervisorType() == HypervisorType.KVM) { pgName = hostname; } else if (host.getHypervisorType() == HypervisorType.VMware) { pgName = hostname + "-" + vswitchName; } p.setHostId(pgName); p.setSegmentInfo(netData.new SegmentInfo(BroadcastDomainType.Vlan.name(), vlan)); p.setOwner(BigSwitchBcfApi.getCloudstackInstanceId()); List<AttachmentData.Attachment.IpAddress> ipList = new ArrayList<AttachmentData.Attachment.IpAddress>(); ipList.add(new AttachmentData().getAttachment().new IpAddress(nic.getIPv4Address())); p.setIpAddresses(ipList); p.setId(nic.getUuid()); p.setMac(nic.getMacAddress()); netData.getNetwork().setId(network.getId()); netData.getNetwork().setName(network.getName()); netData.getNetwork().setTenantId(tenantId); netData.getNetwork().setTenantName(tenantName); netData.getNetwork().setState(netVO.getState().name()); p.setNetwork(netData.getNetwork()); ports.add(p); } network.setTenantId(tenantId); network.setTenantName(tenantName); network.setPorts(ports); topo.addNetwork(network); // add router for network RouterData routerData; if (tenantId != null) { if (!routerMap.containsKey(tenantId)) { routerData = new RouterData(tenantId); routerMap.put(tenantId, routerData); } else { routerData = routerMap.get(tenantId); } routerData.getRouter().getAcls().addAll(listACLbyNetwork(netVO)); if (vpc != null) { routerData.getRouter().addExternalGateway(getPublicIpByVpc(vpc)); } else { routerData.getRouter().addExternalGateway(getPublicIpByNetwork(netVO)); } RouterInterfaceData intf = new RouterInterfaceData(tenantId, netVO.getGateway(), netVO.getCidr(), netVO.getUuid(), netVO.getName()); routerData.getRouter().addInterface(intf); } } for (RouterData rd : routerMap.values()) { topo.addRouter(rd.getRouter()); } return topo; }
From source file:com.hangum.tadpole.rdb.core.dialog.export.sqlresult.composite.ExportSQLComposite.java
@Override public boolean isValidate() { if (super.isValidate()) { if (StringUtils.isEmpty(this.textTargetName.getText())) { MessageDialog.openWarning(getShell(), Messages.get().Warning, Messages.get().ExportSQLComposite_PleaseTargetInput); this.textTargetName.setFocus(); return false; }//from w w w. j a va 2 s. com List<String> listWhereColumnName = new ArrayList<>(); for (int i = 0; i < btnWhereColumn.length; i++) { Button button = btnWhereColumn[i]; if (button.getSelection()) listWhereColumnName.add(button.getText()); } if (this.btnMerge.getSelection() && listWhereColumnName.size() <= 0) { MessageDialog.openWarning(getShell(), Messages.get().Warning, Messages.get().ExportSQLComposite_PleaseMergeMath); return false; } if (!StringUtils.isNumeric(this.textCommit.getText())) { MessageDialog.openWarning(getShell(), Messages.get().Warning, Messages.get().ExportSQLComposite_PleaseCommitCount); textCommit.setText("0"); this.textCommit.setFocus(); return false; } } return true; }
From source file:com.flexive.war.servlet.ThumbnailServlet.java
/** * {@inheritDoc}/*w w w . j a v a 2s .c o m*/ */ @Override public void service(ServletRequest servletRequest, ServletResponse servletResponse) throws ServletException, IOException { final HttpServletRequest request = (HttpServletRequest) servletRequest; final HttpServletResponse response = (HttpServletResponse) servletResponse; final String uri = request.getRequestURI(); FxThumbnailURIConfigurator conf = new FxThumbnailURIConfigurator(URLDecoder.decode(uri, "UTF-8")); if (conf.getPK() == null && !conf.isUseType()) { if (LOG.isDebugEnabled()) { LOG.debug("Empty request for thumbnail servlet: " + uri); } response.sendError(HttpServletResponse.SC_NOT_FOUND); return; } long binaryId; try { if (conf.isUseType()) { if (conf.getXPath().indexOf('/') == -1) { //probably a property FxProperty prop = CacheAdmin.getFilteredEnvironment().getProperty(conf.getXPath()); binaryId = getStructureBinaryId(conf, prop.getDefaultValue()); } else { FxAssignment as = CacheAdmin.getFilteredEnvironment().getAssignment(conf.getXPath()); if (as instanceof FxPropertyAssignment) { FxPropertyAssignment pa = (FxPropertyAssignment) as; binaryId = getStructureBinaryId(conf, pa.getDefaultValue()); } else binaryId = BinaryDescriptor.SYS_UNKNOWN; } } else { final String hintBinaryParam = request.getParameter("hintBinaryId"); final long hintBinaryId = StringUtils.isNumeric(hintBinaryParam) ? Long.parseLong(hintBinaryParam) : -1; if (hintBinaryId != -1) { // load the content to check if the binary belongs to that content (version) final FxContent content = EJBLookup.getContentEngine().load(conf.getPK()); final BinaryDescriptor binaryDescriptor = DownloadServlet.findBinaryDescriptor(content, hintBinaryId); if (binaryDescriptor == null) { LOG.warn("Invalid hintBinaryId for thumbnail of " + conf.getPK() + ": " + hintBinaryId); response.sendError(HttpServletResponse.SC_NOT_FOUND); } binaryId = hintBinaryId; } else { //authorization check and binary lookup binaryId = EJBLookup.getContentEngine().getBinaryId(conf.getPK(), XPathElement.stripType(conf.getXPath()), conf.getLanguage(), conf.useLangFallback()); } } } catch (FxNoAccessException na) { binaryId = BinaryDescriptor.SYS_NOACCESS; } catch (FxApplicationException e) { binaryId = BinaryDescriptor.SYS_UNKNOWN; } try { response.setDateHeader("Expires", System.currentTimeMillis() + 24L * 3600 * 1000); response.setDateHeader("Last-Modified", System.currentTimeMillis()); response.setHeader("Cache-Control", "private"); response.setHeader("Pragma", "cache"); FxStreamUtils.downloadBinary(new ThumbnailBinaryCallback(response), CacheAdmin.getStreamServers(), response.getOutputStream(), binaryId, conf); } catch (FxStreamException e) { LOG.error(e); throw new ServletException(e); } }
From source file:com.greenline.guahao.web.module.home.controllers.mobile.MobileHealthTopicController.java
/** * ?/* w w w . j a v a2 s .com*/ * * @return */ @MethodRemark(value = "remark=?,method=get") @RequestMapping(value = "/mobile/jkdjt/{id}", method = RequestMethod.GET) public String jkdjtDetail(ModelMap map, @PathVariable("id") String id) { if (!StringUtils.isNumeric(id)) { map.put("message", "????"); return MobileConstants.M_ERROR; } HealthTopicsDO healthTopicsDO = healthTopicsManager.getHealthTopicsByIdNew(Integer.valueOf(id)); if (null == healthTopicsDO) { map.put("message", "????"); return MobileConstants.M_ERROR; } String[] threepart = HtmlUtils.getContentWithoutHtml(healthTopicsDO.getContent(), 0, CONTENT_COUNT_LIMIT); //0 1 2 healthTopicsDO.setPreContent(threepart[0]); healthTopicsDO.setLastContent(threepart[2]); healthTopicsDO.setContent(healthTopicsDO.getContent()); map.put("topic", healthTopicsDO); map.put("description", HtmlUtils.deleteHtml(healthTopicsDO.getContent())); return "mobile/jkx/jkdjt_detail"; }
From source file:fr.paris.lutece.plugins.directory.business.AbstractEntryTypeUpload.java
/** * Check the entry data//w ww .j a va 2 s .c om * @param request the HTTP request * @param locale the locale * @return the error message url if there is an error, an empty string * otherwise */ protected String checkEntryData(HttpServletRequest request, Locale locale) { String strTitle = request.getParameter(PARAMETER_TITLE); String strMaxFiles = request.getParameter(PARAMETER_MAX_FILES); String strFileMaxSize = request.getParameter(PARAMETER_FILE_MAX_SIZE); String strFieldError = DirectoryUtils.EMPTY_STRING; if (StringUtils.isBlank(strTitle)) { strFieldError = FIELD_TITLE; } else if (StringUtils.isBlank(strMaxFiles)) { strFieldError = FIELD_MAX_FILES; } else if (StringUtils.isBlank(strFileMaxSize)) { strFieldError = FIELD_FILE_MAX_SIZE; } if (!strFieldError.equals(DirectoryUtils.EMPTY_STRING)) { Object[] tabRequiredFields = { I18nService.getLocalizedString(strFieldError, locale) }; return AdminMessageService.getMessageUrl(request, MESSAGE_MANDATORY_FIELD, tabRequiredFields, AdminMessage.TYPE_STOP); } if (!StringUtils.isNumeric(strMaxFiles)) { strFieldError = FIELD_MAX_FILES; } else if (!StringUtils.isNumeric(strFileMaxSize)) { strFieldError = FIELD_FILE_MAX_SIZE; } if (!strFieldError.equals(DirectoryUtils.EMPTY_STRING)) { Object[] tabRequiredFields = { I18nService.getLocalizedString(strFieldError, locale) }; return AdminMessageService.getMessageUrl(request, MESSAGE_NUMERIC_FIELD, tabRequiredFields, AdminMessage.TYPE_STOP); } return StringUtils.EMPTY; }
From source file:edu.ku.brc.af.core.db.AutoNumberGeneric.java
/** * Returns the integer from a portion of the string. If the string is not long enough than it return null. * @param pos the pos to extract// w w w . j a va 2 s. co m * @param value the string value to be extracted from * @return the new integer value or null */ protected BigInteger extractIntegerValue(final Pair<Integer, Integer> pos, final String value) { if (StringUtils.isNotEmpty(value)) { if (pos != null && value.length() >= pos.second) { String str = value.substring(pos.first, pos.second); if (StringUtils.isNumeric(str)) { try { return new BigInteger(str); } catch (Exception ex) { errorMsg = ex.toString(); edu.ku.brc.af.core.UsageTracker.incrHandledUsageCount(); edu.ku.brc.exceptions.ExceptionTracker.getInstance().capture(AutoNumberGeneric.class, ex); //ex.printStackTrace(); } } } } return null; }