Java Code Examples for org.apache.commons.lang.math.NumberUtils#isDigits()
The following examples show how to use
org.apache.commons.lang.math.NumberUtils#isDigits() .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: Rift.java From aion-germany with GNU General Public License v3.0 | 6 votes |
protected void handleRift(Player player, String... params) { if (params.length < 2 || !NumberUtils.isDigits(params[1])) { showHelp(player); return; } int id = NumberUtils.toInt(params[1]); boolean result; if (!isValidId(player, id)) { showHelp(player); return; } if (COMMAND_OPEN.equalsIgnoreCase(params[0])) { boolean guards = Boolean.parseBoolean(params[2]); result = RiftService.getInstance().openRifts(id, guards); PacketSendUtility.sendMessage(player, result ? "Rifts is opened!" : "Rifts was already opened"); } else if (COMMAND_CLOSE.equalsIgnoreCase(params[0])) { result = RiftService.getInstance().closeRifts(id); PacketSendUtility.sendMessage(player, result ? "Rifts is closed!" : "Rifts was already closed"); } }
Example 2
Source File: ApexCli.java From attic-apex-core with Apache License 2.0 | 6 votes |
@Override public void execute(String[] args, ConsoleReader reader) throws Exception { if (currentApp == null) { throw new CliException("No application selected"); } if (!NumberUtils.isDigits(args[1])) { throw new CliException("Operator ID must be a number"); } StramAgent.StramUriSpec uriSpec = new StramAgent.StramUriSpec(); uriSpec = uriSpec.path(StramWebServices.PATH_PHYSICAL_PLAN_OPERATORS).path(args[1]).path("properties"); final JSONObject request = new JSONObject(); request.put(args[2], args[3]); JSONObject response = getResource(uriSpec, currentApp, new WebServicesClient.WebServicesHandler<JSONObject>() { @Override public JSONObject process(WebResource.Builder webResource, Class<JSONObject> clazz) { return webResource.accept(MediaType.APPLICATION_JSON).post(JSONObject.class, request); } }); printJson(response); }
Example 3
Source File: CasLoginAct.java From Lottery with GNU General Public License v2.0 | 5 votes |
private Integer getCookieErrorRemaining(HttpServletRequest request, HttpServletResponse response) { Cookie cookie = CookieUtils.getCookie(request, COOKIE_ERROR_REMAINING); if (cookie != null) { String value = cookie.getValue(); if (NumberUtils.isDigits(value)) { return Integer.parseInt(value); } } return null; }
Example 4
Source File: ApexCli.java From Bats with Apache License 2.0 | 5 votes |
@Override public void execute(String[] args, ConsoleReader reader) throws Exception { if (currentApp == null) { throw new CliException("No application selected"); } if (!NumberUtils.isDigits(args[1])) { throw new CliException("Operator ID must be a number"); } String[] newArgs = new String[args.length - 1]; System.arraycopy(args, 1, newArgs, 0, args.length - 1); PosixParser parser = new PosixParser(); CommandLine line = parser.parse(GET_PHYSICAL_PROPERTY_OPTIONS.options, newArgs); String waitTime = line.getOptionValue(GET_PHYSICAL_PROPERTY_OPTIONS.waitTime.getOpt()); String propertyName = line.getOptionValue(GET_PHYSICAL_PROPERTY_OPTIONS.propertyName.getOpt()); StramAgent.StramUriSpec uriSpec = new StramAgent.StramUriSpec(); uriSpec = uriSpec.path(StramWebServices.PATH_PHYSICAL_PLAN_OPERATORS).path(args[1]).path("properties"); if (propertyName != null) { uriSpec = uriSpec.queryParam("propertyName", propertyName); } if (waitTime != null) { uriSpec = uriSpec.queryParam("waitTime", waitTime); } try { JSONObject response = getResource(uriSpec, currentApp); printJson(response); } catch (Exception e) { throw new CliException("Failed web service request for appid " + currentApp.getApplicationId().toString(), e); } }
Example 5
Source File: SiegeCommand.java From aion-germany with GNU General Public License v3.0 | 5 votes |
protected void handleStartStopSiege(Player player, String... params) { if (params.length != 2 || !NumberUtils.isDigits(params[1])) { showHelp(player); return; } int siegeLocId = NumberUtils.toInt(params[1]); if (!isValidSiegeLocationId(player, siegeLocId)) { showHelp(player); return; } if (COMMAND_START.equalsIgnoreCase(params[0])) { if (SiegeService.getInstance().isSiegeInProgress(siegeLocId)) { PacketSendUtility.sendMessage(player, "Siege Location " + siegeLocId + " is already under siege"); } else { PacketSendUtility.sendMessage(player, "Siege Location " + siegeLocId + " - starting siege!"); SiegeService.getInstance().startSiege(siegeLocId); } } else if (COMMAND_STOP.equalsIgnoreCase(params[0])) { if (!SiegeService.getInstance().isSiegeInProgress(siegeLocId)) { PacketSendUtility.sendMessage(player, "Siege Location " + siegeLocId + " is not under siege"); } else { PacketSendUtility.sendMessage(player, "Siege Location " + siegeLocId + " - stopping siege!"); SiegeService.getInstance().stopSiege(siegeLocId); } } }
Example 6
Source File: TravelActionBase.java From kfs with GNU Affero General Public License v3.0 | 5 votes |
/** * This method adds a new related document into the travel request document * * @param mapping * @param form * @param request * @param response * @return * @throws Exception */ public ActionForward addRelatedDocumentLine(ActionMapping mapping, ActionForm form, HttpServletRequest request, HttpServletResponse response) throws Exception { TravelFormBase travelReqForm = (TravelFormBase) form; AccountingDocumentRelationship adr = travelReqForm.getNewAccountingDocumentRelationship(); if (adr.getRelDocumentNumber() == null || !NumberUtils.isDigits(adr.getRelDocumentNumber())) { GlobalVariables.getMessageMap().putError( String.format("%s.%s", TemKeyConstants.TRVL_RELATED_DOCUMENT, TemPropertyConstants.TRVL_RELATED_DOCUMENT_NUM), TemKeyConstants.ERROR_TRVL_RELATED_DOCUMENT_REQUIRED); } else { if (getDocumentService().documentExists(adr.getRelDocumentNumber())) { adr.setDocumentNumber(travelReqForm.getDocument().getDocumentNumber()); adr.setPrincipalId(GlobalVariables.getUserSession().getPerson().getPrincipalId()); getAccountingDocumentRelationshipService().save(adr); travelReqForm.setNewAccountingDocumentRelationship(new AccountingDocumentRelationship()); } else { GlobalVariables.getMessageMap().putError( String.format("%s.%s", TemKeyConstants.TRVL_RELATED_DOCUMENT, TemPropertyConstants.TRVL_RELATED_DOCUMENT_NUM), TemKeyConstants.ERROR_TRVL_RELATED_DOCUMENT_NOT_FOUND, new String[] { adr.getRelDocumentNumber() }); } } return mapping.findForward(KFSConstants.MAPPING_BASIC); }
Example 7
Source File: Invasion.java From aion-germany with GNU General Public License v3.0 | 5 votes |
protected void handleStartStopInvasion(Player player, String... params) { if (params.length != 2 || !NumberUtils.isDigits(params[1])) { showHelp(player); return; } int vortexId = NumberUtils.toInt(params[1]); String locationName = vortexId == 0 ? "Theobomos" : "Brusthonin"; if (!isValidVortexLocationId(player, vortexId)) { showHelp(player); return; } if (COMMAND_START.equalsIgnoreCase(params[0])) { if (VortexService.getInstance().isInvasionInProgress(vortexId)) { PacketSendUtility.sendMessage(player, locationName + " is already under siege"); } else { PacketSendUtility.sendMessage(player, locationName + " invasion started!"); VortexService.getInstance().startInvasion(vortexId); } } else if (COMMAND_STOP.equalsIgnoreCase(params[0])) { if (!VortexService.getInstance().isInvasionInProgress(vortexId)) { PacketSendUtility.sendMessage(player, locationName + " is not under siege"); } else { PacketSendUtility.sendMessage(player, locationName + " invasion stopped!"); VortexService.getInstance().stopInvasion(vortexId); } } }
Example 8
Source File: RipUtils.java From ripme with MIT License | 5 votes |
private static String urlFromImagefapDirectoryName(String dir) { if (!dir.startsWith("imagefap")) { return null; } String url = null; dir = dir.substring("imagefap_".length()); if (NumberUtils.isDigits(dir)) { url = "http://www.imagefap.com/gallery.php?gid=" + dir; } else { url = "http://www.imagefap.com/gallery.php?pgid=" + dir; } return url; }
Example 9
Source File: RedisConfigTemplateController.java From cachecloud with Apache License 2.0 | 5 votes |
/** * 修改配置 */ @RequestMapping(value = "/update") public ModelAndView update(HttpServletRequest request, HttpServletResponse response, Model model) { AppUser appUser = getUserInfo(request); String id = request.getParameter("id"); String configKey = request.getParameter("configKey"); String configValue = request.getParameter("configValue"); String info = request.getParameter("info"); int status = NumberUtils.toInt(request.getParameter("status"), -1); if (StringUtils.isBlank(id) || !NumberUtils.isDigits(id) || StringUtils.isBlank(configKey) || status > 1 || status < 0) { model.addAttribute("status", SuccessEnum.FAIL.value()); model.addAttribute("message", ErrorMessageEnum.PARAM_ERROR_MSG.getMessage() + "id=" + id + ",configKey=" + configKey + ",configValue=" + configValue + ",status=" + status); return new ModelAndView(""); } //开始修改 logger.warn("user {} want to change id={}'s configKey={}, configValue={}, info={}, status={}", appUser.getName(), id, configKey, configValue, info, status); SuccessEnum successEnum; InstanceConfig instanceConfig = redisConfigTemplateService.getById(NumberUtils.toLong(id)); try { instanceConfig.setConfigValue(configValue); instanceConfig.setInfo(info); instanceConfig.setStatus(status); redisConfigTemplateService.saveOrUpdate(instanceConfig); successEnum = SuccessEnum.SUCCESS; } catch (Exception e) { successEnum = SuccessEnum.FAIL; model.addAttribute("message", ErrorMessageEnum.INNER_ERROR_MSG.getMessage()); logger.error(e.getMessage(), e); } logger.warn("user {} want to change id={}'s configKey={}, configValue={}, info={}, status={}, result is {}", appUser.getName(), id, configKey, configValue, info, status, successEnum.value()); //发送邮件通知 appEmailUtil.sendRedisConfigTemplateChangeEmail(appUser, instanceConfig, successEnum, RedisConfigTemplateChangeEnum.UPDATE); model.addAttribute("status", successEnum.value()); return new ModelAndView(""); }
Example 10
Source File: Config.java From Lottery with GNU General Public License v2.0 | 5 votes |
public Integer getErrorInterval() { String interval = getAttr().get(LOGIN_ERROR_INTERVAL); if (NumberUtils.isDigits(interval)) { return Integer.parseInt(interval); } else { // 默认间隔30分钟 return 30; } }
Example 11
Source File: Config.java From Lottery with GNU General Public License v2.0 | 5 votes |
public Integer getErrorTimes() { String times = getAttr().get(LOGIN_ERROR_TIMES); if (NumberUtils.isDigits(times)) { return Integer.parseInt(times); } else { // 默认3次 return 3; } }
Example 12
Source File: AbstractMediaFileNameStrategyImpl.java From yes-cart with Apache License 2.0 | 5 votes |
/** * {@inheritDoc} */ @Override public String createRollingFileName(final String fullFileName, final String code, final String suffix, final String locale) { final String systemPart = (Constants.NO_IMAGE.equals(code) ? "" : "_" + code) + "_" + (char)(NumberUtils.toInt(suffix) + 'a') + (StringUtils.isNotEmpty(locale) ? "_" + locale : ""); final int posExt = fullFileName.lastIndexOf('.'); final String fileName; final String fileExt; if (posExt == -1) { fileName = fullFileName; fileExt = ""; } else { fileName = fullFileName.substring(0, posExt); fileExt = fullFileName.substring(posExt); // including '.' } final String mainPart; if (fileName.endsWith(systemPart)) { mainPart = fileName.substring(0, fileName.length() - systemPart.length()); } else { mainPart = fileName; } final int posRollingNumber = mainPart.lastIndexOf('-'); if (posRollingNumber == -1 || (mainPart.length() < posRollingNumber + 1) || !NumberUtils.isDigits(mainPart.substring(posRollingNumber + 1))) { return mainPart + "-1" + systemPart + fileExt; } return mainPart.substring(0, posRollingNumber) + "-" + (NumberUtils.toInt(mainPart.substring(posRollingNumber + 1)) + 1) + systemPart + fileExt; }
Example 13
Source File: CmsLoginAct.java From Lottery with GNU General Public License v2.0 | 5 votes |
private Integer getCookieErrorRemaining(HttpServletRequest request, HttpServletResponse response) { Cookie cookie = CookieUtils.getCookie(request, COOKIE_ERROR_REMAINING); if (cookie != null) { String value = cookie.getValue(); if (NumberUtils.isDigits(value)) { return Integer.parseInt(value); } } return null; }
Example 14
Source File: StringUtil.java From smart-framework with Apache License 2.0 | 4 votes |
/** * 是否为十进制数(整数) */ public static boolean isDigits(String str) { return NumberUtils.isDigits(str); }
Example 15
Source File: StringUtil.java From springdream with Apache License 2.0 | 4 votes |
/** * 是否为十进制数(整数) */ public static boolean isDigits(String str) { return NumberUtils.isDigits(str); }
Example 16
Source File: StringUtil.java From smart-framework with Apache License 2.0 | 4 votes |
/** * 是否为十进制数(整数) */ public static boolean isDigits(String str) { return NumberUtils.isDigits(str); }
Example 17
Source File: ImportAppCenterImpl.java From cachecloud with Apache License 2.0 | 4 votes |
@Override public ImportAppResult check(AppDesc appDesc, String appInstanceInfo) { // 1.检查是否应用信息为空 if (appDesc == null) { return ImportAppResult.fail("应用信息为空"); } // 2.检查应用名是否重复 String appName = appDesc.getName(); AppDesc existAppDesc = appService.getAppByName(appName); if (existAppDesc != null) { return ImportAppResult.fail(appName + ", 应用名重复"); } // 3.实例信息是否为空 if (StringUtils.isBlank(appInstanceInfo)) { return ImportAppResult.fail("实例详情为空"); } String[] appInstanceDetails = appInstanceInfo.split("\n"); // 4.检查实例信息格式是否正确 for (String appInstance : appInstanceDetails) { if (StringUtils.isBlank(appInstance)) { return ImportAppResult.fail("应用实例信息有空行"); } String[] instanceItems = appInstance.split(":"); if (instanceItems.length != 3) { return ImportAppResult.fail("应用实例信息" + appInstance + "格式错误,必须有2个冒号"); } String ip = instanceItems[0]; // 4.1.检查ip对应的机器是否存在 try { MachineInfo machineInfo = machineCenter.getMachineInfoByIp(ip); if (machineInfo == null) { return ImportAppResult.fail(appInstance + "中的ip不存在"); } else if (machineInfo.isOffline()) { return ImportAppResult.fail(appInstance + "中的ip已经被删除"); } } catch (Exception e) { return ImportAppResult.fail(appInstance + "中的ip不存在"); } // 4.2.检查端口是否为整数 String portStr = instanceItems[1]; boolean portIsDigit = NumberUtils.isDigits(portStr); if (!portIsDigit) { return ImportAppResult.fail(appInstance + "中的port不是整数"); } int port = NumberUtils.toInt(portStr); // 4.3.检查ip:port是否已经在instance_info表和instance_statistics中 int count = instanceDao.getCountByIpAndPort(ip, port); if (count > 0) { return ImportAppResult.fail(appInstance + "中ip:port已经在instance_info存在"); } InstanceStats instanceStats = instanceStatsDao.getInstanceStatsByHost(ip, port); if (instanceStats != null) { return ImportAppResult.fail(appInstance + "中ip:port已经在instance_statistics存在"); } // 4.4.检查Redis实例是否存活 String memoryOrMasterName = instanceItems[2]; int memoryOrMasterNameInt = NumberUtils.toInt(memoryOrMasterName); boolean isRun; if (memoryOrMasterNameInt > 0) { isRun = redisCenter.isRun(ip, port, appDesc.getPassword()); } else { isRun = redisCenter.isRun(ip, port); } if (!isRun) { return ImportAppResult.fail(appInstance + "中的节点不是存活的"); } // 4.5.检查内存是否为整数 boolean isSentinelNode = memoryOrMasterNameInt <= 0; if (isSentinelNode) { // 4.5.1 sentinel节点masterName判断 if (StringUtils.isEmpty(memoryOrMasterName)) { return ImportAppResult.fail(appInstance + "中的sentinel节点master为空"); } // 判断masterName String masterName = getSentinelMasterName(ip, port); if (StringUtils.isEmpty(masterName) || !memoryOrMasterName.equals(masterName)) { return ImportAppResult.fail(ip + ":" + port + ", masterName:" + masterName + "与所填" + memoryOrMasterName + "不一致"); } } else { // 4.5.2 内存必须是整数 boolean maxMemoryIsDigit = NumberUtils.isDigits(memoryOrMasterName); if (!maxMemoryIsDigit) { return ImportAppResult.fail(appInstance + "中的maxmemory不是整数"); } } } // 5. 节点之间关系是否正确,这个比较麻烦,还是依赖于用户填写的正确性。 return ImportAppResult.success(); }
Example 18
Source File: AppDeployCenterImpl.java From cachecloud with Apache License 2.0 | 4 votes |
@Override public DataFormatCheckResult checkAppDeployDetail(Long appAuditId, String appDeployText) { if (appAuditId == null) { logger.error("appAuditId is null"); return DataFormatCheckResult.fail("审核id不能为空!"); } if (StringUtils.isBlank(appDeployText)) { logger.error("appDeployText is null"); return DataFormatCheckResult.fail("部署节点列表不能为空!"); } String[] nodeInfoList = appDeployText.split(ConstUtils.NEXT_LINE); if (nodeInfoList == null || nodeInfoList.length == 0) { logger.error("nodeInfoList is null"); return DataFormatCheckResult.fail("部署节点列表不能为空!"); } AppAudit appAudit = appAuditDao.getAppAudit(appAuditId); if (appAudit == null) { logger.error("appAudit:id={} is not exist", appAuditId); return DataFormatCheckResult.fail(String.format("审核id=%s不存在", appAuditId)); } long appId = appAudit.getAppId(); AppDesc appDesc = appService.getByAppId(appId); if (appDesc == null) { logger.error("appDesc:id={} is not exist"); return DataFormatCheckResult.fail(String.format("appId=%s不存在", appId)); } int type = appDesc.getType(); //检查每一行 for (String nodeInfo : nodeInfoList) { nodeInfo = StringUtils.trim(nodeInfo); if (StringUtils.isBlank(nodeInfo)) { return DataFormatCheckResult.fail(String.format("部署列表%s中存在空行", appDeployText)); } String[] array = nodeInfo.split(ConstUtils.COLON); if (array == null || array.length == 0) { return DataFormatCheckResult.fail(String.format("部署列表%s中存在空行", appDeployText)); } String masterHost = null; String memSize = null; String slaveHost = null; if (TypeUtil.isRedisCluster(type)) { if (array.length == 2) { masterHost = array[0]; memSize = array[1]; } else if (array.length == 3) { masterHost = array[0]; memSize = array[1]; slaveHost = array[2]; } else { return DataFormatCheckResult.fail(String.format("部署列表中%s, 格式错误!", nodeInfo)); } } else if (TypeUtil.isRedisSentinel(type)) { if (array.length == 3) { masterHost = array[0]; memSize = array[1]; slaveHost = array[2]; } else if (array.length == 1) { masterHost = array[0]; } else { return DataFormatCheckResult.fail(String.format("部署列表中%s, 格式错误!", nodeInfo)); } } else if (TypeUtil.isRedisStandalone(type)) { if (array.length == 2) { masterHost = array[0]; memSize = array[1]; } else { return DataFormatCheckResult.fail(String.format("部署列表中%s, 格式错误!", nodeInfo)); } } if (!checkHostExist(masterHost)) { return DataFormatCheckResult.fail(String.format("%s中的ip=%s不存在,请在机器管理中添加!", nodeInfo, masterHost)); } if (StringUtils.isNotBlank(memSize) && !NumberUtils.isDigits(memSize)) { return DataFormatCheckResult.fail(String.format("%s中的中的memSize=%s不是整数!", nodeInfo, memSize)); } if (StringUtils.isNotBlank(slaveHost) && !checkHostExist(slaveHost)) { return DataFormatCheckResult.fail(String.format("%s中的ip=%s不存在,请在机器管理中添加!", nodeInfo, slaveHost)); } } //检查sentinel类型:数据节点一行,sentinel节点多行 if (TypeUtil.isRedisSentinel(type)) { return checkSentinelAppDeploy(nodeInfoList); //检查单点类型:只能有一行数据节点 } else if (TypeUtil.isRedisStandalone(type)) { return checkStandaloneAppDeploy(nodeInfoList); } return DataFormatCheckResult.success("应用部署格式正确,可以开始部署了!"); }
Example 19
Source File: AppDataMigrateCenterImpl.java From cachecloud with Apache License 2.0 | 4 votes |
/** * 检测配置 * * @param migrateMachineIp * @param redisMigrateEnum * @param servers * @param redisSourcePass 源密码 * @return */ private AppDataMigrateResult checkMigrateConfig(String migrateMachineIp, AppDataMigrateEnum redisMigrateEnum, String servers, String redisPassword, boolean isSource) { //target如果是rdb是没有路径的,不需要检测 if (isSource || !AppDataMigrateEnum.isFileType(redisMigrateEnum)) { if (StringUtils.isBlank(servers)) { return AppDataMigrateResult.fail("服务器信息不能为空!"); } } List<String> serverList = Arrays.asList(servers.split(ConstUtils.NEXT_LINE)); if (CollectionUtils.isEmpty(serverList)) { return AppDataMigrateResult.fail("服务器信息格式有问题!"); } for (String server : serverList) { if (AppDataMigrateEnum.isFileType(redisMigrateEnum)) { if (!isSource) { continue; } // 检查文件是否存在 String filePath = server; String cmd = "head " + filePath; try { String headResult = SSHUtil.execute(migrateMachineIp, cmd); if (StringUtils.isBlank(headResult)) { return AppDataMigrateResult.fail(migrateMachineIp + "上的rdb:" + filePath + "不存在或者为空!"); } } catch (Exception e) { logger.error(e.getMessage()); return AppDataMigrateResult.fail(migrateMachineIp + "上的rdb:" + filePath + "读取异常!"); } } else { // 1. 检查是否为ip:port格式(简单检查一下,无需正则表达式) // 2. 检查Redis节点是否存在 String[] instanceItems = server.split(":"); if (instanceItems.length != 2) { return AppDataMigrateResult.fail("实例信息" + server + "格式错误,必须为ip:port格式"); } String ip = instanceItems[0]; String portStr = instanceItems[1]; boolean portIsDigit = NumberUtils.isDigits(portStr); if (!portIsDigit) { return AppDataMigrateResult.fail(server + "中的port不是整数"); } int port = NumberUtils.toInt(portStr); boolean isRun = redisCenter.isRun(ip, port, redisPassword); if (!isRun) { return AppDataMigrateResult.fail(server + "不是存活的或者密码错误!"); } } } return AppDataMigrateResult.success(); }
Example 20
Source File: CommitQuery.java From onedev with MIT License | 4 votes |
public static CommitQuery parse(Project project, @Nullable String queryString) { List<CommitCriteria> criterias = new ArrayList<>(); if (queryString != null) { CharStream is = CharStreams.fromString(queryString); CommitQueryLexer lexer = new CommitQueryLexer(is); lexer.removeErrorListeners(); lexer.addErrorListener(new BaseErrorListener() { @Override public void syntaxError(Recognizer<?, ?> recognizer, Object offendingSymbol, int line, int charPositionInLine, String msg, RecognitionException e) { throw new RuntimeException("Malformed commit query", e); } }); CommonTokenStream tokens = new CommonTokenStream(lexer); CommitQueryParser parser = new CommitQueryParser(tokens); parser.removeErrorListeners(); parser.setErrorHandler(new BailErrorStrategy()); List<String> authorValues = new ArrayList<>(); List<String> committerValues = new ArrayList<>(); List<String> beforeValues = new ArrayList<>(); List<String> afterValues = new ArrayList<>(); List<String> pathValues = new ArrayList<>(); List<String> messageValues = new ArrayList<>(); List<Revision> revisions = new ArrayList<>(); for (CriteriaContext criteria: parser.query().criteria()) { if (criteria.authorCriteria() != null) { if (criteria.authorCriteria().AuthoredByMe() != null) authorValues.add(null); else authorValues.add(getValue(criteria.authorCriteria().Value())); } else if (criteria.committerCriteria() != null) { if (criteria.committerCriteria().CommittedByMe() != null) committerValues.add(null); else committerValues.add(getValue(criteria.committerCriteria().Value())); } else if (criteria.messageCriteria() != null) { messageValues.add(getValue(criteria.messageCriteria().Value())); } else if (criteria.pathCriteria() != null) { pathValues.add(getValue(criteria.pathCriteria().Value())); } else if (criteria.beforeCriteria() != null) { beforeValues.add(getValue(criteria.beforeCriteria().Value())); } else if (criteria.afterCriteria() != null) { afterValues.add(getValue(criteria.afterCriteria().Value())); } else if (criteria.revisionCriteria() != null) { String value; Revision.Scope scope; if (criteria.revisionCriteria().DefaultBranch() != null) value = project.getDefaultBranch(); else value = getValue(criteria.revisionCriteria().Value()); if (criteria.revisionCriteria().BUILD() != null) { String numberStr = value; if (numberStr.startsWith("#")) numberStr = numberStr.substring(1); if (NumberUtils.isDigits(numberStr)) { Build build = OneDev.getInstance(BuildManager.class).find(project, Long.parseLong(numberStr)); if (build == null) throw new OneException("Unable to find build: " + value); else value = build.getCommitHash(); } else { throw new OneException("Invalid build number: " + numberStr); } } if (criteria.revisionCriteria().SINCE() != null) scope = Revision.Scope.SINCE; else if (criteria.revisionCriteria().UNTIL() != null) scope = Revision.Scope.UNTIL; else scope = null; revisions.add(new Revision(value, scope, criteria.revisionCriteria().getText())); } } if (!authorValues.isEmpty()) criterias.add(new AuthorCriteria(authorValues)); if (!committerValues.isEmpty()) criterias.add(new CommitterCriteria(committerValues)); if (!pathValues.isEmpty()) criterias.add(new PathCriteria(pathValues)); if (!messageValues.isEmpty()) criterias.add(new MessageCriteria(messageValues)); if (!beforeValues.isEmpty()) criterias.add(new BeforeCriteria(beforeValues)); if (!afterValues.isEmpty()) criterias.add(new AfterCriteria(afterValues)); if (!revisions.isEmpty()) criterias.add(new RevisionCriteria(revisions)); } return new CommitQuery(criterias); }