Java Code Examples for org.springframework.util.StringUtils#isEmpty()
The following examples show how to use
org.springframework.util.StringUtils#isEmpty() .
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: BashUtils.java From hdfs-shell with Apache License 2.0 | 6 votes |
public static String[] parseArguments(final String input) { if (StringUtils.isEmpty(input)) { return new String[0]; } return ArgumentTokenizer.tokenize(input).toArray(new String[0]); // final Matcher m = ARG_PATTERN.matcher(input); // final List<String> list = new ArrayList<>(); // while (m.find()) { // final String group3 = m.group(3); // if (group3 == null) { // list.add(m.group(1)); // } else { // list.add(group3); // } // } // return list.toArray(new String[list.size()]); }
Example 2
Source File: CaptchaController.java From CAS with Apache License 2.0 | 6 votes |
/** * 用于前端ajax校验 */ @RequestMapping(value = "/chkCode", method = RequestMethod.POST) public void checkCode(String code, HttpServletRequest req, HttpServletResponse resp) { //获取session中的验证码 String storeCode = (String) req.getSession().getAttribute("captcha_code"); code = code.trim(); //返回值 Map<String, Object> map = new HashMap<String, Object>(); //验证是否对,不管大小写 if (!StringUtils.isEmpty(storeCode) && code.equalsIgnoreCase(storeCode)) { map.put("error", false); map.put("msg", "验证成功"); } else if (StringUtils.isEmpty(code)) { map.put("error", true); map.put("msg", "验证码不能为空"); } else { map.put("error", true); map.put("msg", "验证码错误"); } this.writeJSON(resp, map); }
Example 3
Source File: LoginBiz.java From roncoo-adminlte-springmvc with Apache License 2.0 | 6 votes |
/** * 授权登录 * * @param code */ public Result<String> oauth(String code) { Result<String> result = new Result<String>(); if (StringUtils.isEmpty(code)) { return result; } Map<String, Object> param = new HashMap<String, Object>(); param.put("clientId", ConfUtil.getProperty("clientId")); param.put("clientSecret", ConfUtil.getProperty("clientSecret")); param.put("code", code); param.put("grantType", "authorization_code"); String url = ConfUtil.getProperty("baseUrl") + ConfUtil.getProperty("apiAccessTokenUrl"); JsonNode json = RestTemplateUtil.postForObject(url, param); int status = json.get("errCode").asInt(); if (0 == status) { String roncooNo = json.get("resultData").get("roncooNo").asText(); result.setStatus(true); result.setErrCode(0); result.setResultData(roncooNo); } return result; }
Example 4
Source File: WireMockJsonSnippet.java From restdocs-wiremock with Apache License 2.0 | 6 votes |
/** * If ATTRIBUTE_NAME_URL_TEMPLATE is present use it to build a urlPattern instead of a urlPath. * * This allows for more flexible request matching when the path contains variable elements. * * ATTRIBUTE_NAME_URL_TEMPLATE is present if the urlTemplate factore methods of RestDocumentationRequestBuilders are used. * * @param operation * @param requestBuilder */ private void urlPathOrUrlPattern(Operation operation, Maps.Builder<Object, Object> requestBuilder) { String urlTemplate = (String) operation.getAttributes().get(ATTRIBUTE_NAME_URL_TEMPLATE); if (StringUtils.isEmpty(urlTemplate)) { requestBuilder.put("urlPath", operation.getRequest().getUri().getRawPath()); } else { UriTemplate uriTemplate = new UriTemplate(urlTemplate); UriComponentsBuilder uriTemplateBuilder = UriComponentsBuilder.fromUriString(urlTemplate); Maps.Builder<String, String> uriVariables = Maps.builder(); for (String variableName : uriTemplate.getVariableNames()) { uriVariables.put(variableName, "[^/]+"); } String uriPathRegex = uriTemplateBuilder.buildAndExpand(uriVariables.build()).getPath(); requestBuilder.put("urlPathPattern", uriPathRegex); } }
Example 5
Source File: TeamController.java From staffjoy with MIT License | 6 votes |
@GetMapping(path = "/get_worker_team_info") @Authorize(value = { AuthConstant.AUTHORIZATION_AUTHENTICATED_USER, AuthConstant.AUTHORIZATION_SUPPORT_USER, AuthConstant.AUTHORIZATION_ICAL_SERVICE }) public GenericWorkerResponse getWorkerTeamInfo(@RequestParam(required = false) String companyId, @RequestParam String userId) { GenericWorkerResponse response = new GenericWorkerResponse(); if (AuthConstant.AUTHORIZATION_AUTHENTICATED_USER.equals(AuthContext.getAuthz())) { if (!userId.equals(AuthContext.getUserId())) { // user can access their own entry if (StringUtils.isEmpty(companyId)) { response.setCode(ResultCode.PARAM_MISS); response.setMessage("missing companyId"); return response; } permissionService.checkPermissionCompanyAdmin(companyId); } } WorkerDto workerDto = this.teamService.getWorkerTeamInfo(userId); response.setWorker(workerDto); return response; }
Example 6
Source File: WebUtils.java From spring-backend-boilerplate with Apache License 2.0 | 6 votes |
public static String getUri(String fullUrl) { if (StringUtils.isEmpty(fullUrl)) { return ""; } int startIndex = fullUrl.indexOf("://"); if (startIndex < 0) { return ""; } startIndex = fullUrl.indexOf("/", startIndex + 3); if (startIndex < 0) { return ""; } return fullUrl.substring(startIndex); }
Example 7
Source File: ClusterController.java From AthenaServing with Apache License 2.0 | 5 votes |
/** * 查询集群详情 * * @param id * @return */ @RequestMapping(value = "/detail", method = RequestMethod.GET) public Response<ClusterDetailResponseBody> find(@RequestParam("id") String id) { if (StringUtils.isEmpty(id)) { return new Response<>(SystemErrCode.ERRCODE_INVALID_PARAMETER, SystemErrCode.ERRMSG_ID_NOT_NULL); } return this.clusterServiceImpl.find(id); }
Example 8
Source File: LitemallGoodsService.java From litemall with MIT License | 5 votes |
public List<Integer> getCatIds(Integer brandId, String keywords, Boolean isHot, Boolean isNew) { LitemallGoodsExample example = new LitemallGoodsExample(); LitemallGoodsExample.Criteria criteria1 = example.or(); LitemallGoodsExample.Criteria criteria2 = example.or(); if (!StringUtils.isEmpty(brandId)) { criteria1.andBrandIdEqualTo(brandId); criteria2.andBrandIdEqualTo(brandId); } if (!StringUtils.isEmpty(isNew)) { criteria1.andIsNewEqualTo(isNew); criteria2.andIsNewEqualTo(isNew); } if (!StringUtils.isEmpty(isHot)) { criteria1.andIsHotEqualTo(isHot); criteria2.andIsHotEqualTo(isHot); } if (!StringUtils.isEmpty(keywords)) { criteria1.andKeywordsLike("%" + keywords + "%"); criteria2.andNameLike("%" + keywords + "%"); } criteria1.andIsOnSaleEqualTo(true); criteria2.andIsOnSaleEqualTo(true); criteria1.andDeletedEqualTo(false); criteria2.andDeletedEqualTo(false); List<LitemallGoods> goodsList = goodsMapper.selectByExampleSelective(example, Column.categoryId); List<Integer> cats = new ArrayList<Integer>(); for (LitemallGoods goods : goodsList) { cats.add(goods.getCategoryId()); } return cats; }
Example 9
Source File: RequestTestController.java From spring-boot-projects with Apache License 2.0 | 5 votes |
@RequestMapping(value = "/test1", method = RequestMethod.GET) public String test1(String info) { if (StringUtils.isEmpty(info) || StringUtils.isEmpty(info)) { return "请输入info的值!"; } return "你输入的内容是:" + info; }
Example 10
Source File: ActuatorController.java From boot-actuator with MIT License | 5 votes |
/** * 添加应用 * @param name * @param url * @return */ @ResponseBody @RequestMapping("/saveActuator") public Res saveActuator(String name,String url){ if(actuatorTtype.equals("1")){ return Res.error("演示环境不能操作"); } if(StringUtils.isEmpty(name)||StringUtils.isEmpty(url)){ return Res.error("名称和应用域名不能为空"); } try { SysActuatorEntity query=new SysActuatorEntity(); query.setUrl(url); query.setUrl(name); int count=sysActuatorMapper.selectCount(new QueryWrapper(query)); if(count>0){ return Res.error("该应用数据中已存在"); } SysActuatorEntity s=new SysActuatorEntity(); s.setName(name); s.setUrl(url); s.setDate(new Date()); sysActuatorMapper.insert(s); return Res.ok(); } catch (Exception e) { logger.debug("添加监控应用异常:{},{}",name,e); return Res.error(); } }
Example 11
Source File: MailServiceImpl.java From SpringBoot-Home with Apache License 2.0 | 5 votes |
/** * 检测邮件信息类 * @param mail */ private void checkMail(Mail mail) { if (StringUtils.isEmpty(mail.getReceiver())) { throw new RuntimeException("邮件收信人不能为空"); } if (StringUtils.isEmpty(mail.getSubject())) { throw new RuntimeException("邮件主题不能为空"); } if (StringUtils.isEmpty(mail.getText()) && null == mail.getEmailTemplateContext()) { throw new RuntimeException("邮件内容不能为空"); } }
Example 12
Source File: NacosServiceRegistry.java From spring-cloud-alibaba with Apache License 2.0 | 5 votes |
@Override public void register(Registration registration) { if (StringUtils.isEmpty(registration.getServiceId())) { log.warn("No service to register for nacos client..."); return; } NamingService namingService = namingService(); String serviceId = registration.getServiceId(); String group = nacosDiscoveryProperties.getGroup(); Instance instance = getNacosInstanceFromRegistration(registration); try { namingService.registerInstance(serviceId, group, instance); log.info("nacos registry, {} {} {}:{} register finished", group, serviceId, instance.getIp(), instance.getPort()); } catch (Exception e) { log.error("nacos registry, {} register failed...{},", serviceId, registration.toString(), e); // rethrow a RuntimeException if the registration is failed. // issue : https://github.com/alibaba/spring-cloud-alibaba/issues/1132 rethrowRuntimeException(e); } }
Example 13
Source File: QualifiedNameUtils.java From egeria with Apache License 2.0 | 5 votes |
public static String buildQualifiedNameForDataViewColumn(String hostAddress, String informationViewId, String columnName){ String endpointQualifiedName = ""; if(!StringUtils.isEmpty(hostAddress)){ endpointQualifiedName = QualifiedNameUtils.buildQualifiedName("", Constants.SOFTWARE_SERVER, hostAddress); } String informationViewQualifiedName = QualifiedNameUtils.buildQualifiedName(endpointQualifiedName, Constants.INFORMATION_VIEW, informationViewId); return QualifiedNameUtils.buildQualifiedName(informationViewQualifiedName, Constants.DERIVED_SCHEMA_ATTRIBUTE, columnName); }
Example 14
Source File: TagController.java From My-Blog with Apache License 2.0 | 5 votes |
@PostMapping("/tags/save") @ResponseBody public Result save(@RequestParam("tagName") String tagName) { if (StringUtils.isEmpty(tagName)) { return ResultGenerator.genFailResult("参数异常!"); } if (tagService.saveTag(tagName)) { return ResultGenerator.genSuccessResult(); } else { return ResultGenerator.genFailResult("标签名称重复"); } }
Example 15
Source File: WxMenu.java From FastBootWeixin with Apache License 2.0 | 4 votes |
public Builder setPagePath(String pagePath) { this.pagePath = StringUtils.isEmpty(pagePath) ? null : pagePath; return this; }
Example 16
Source File: MemberTransactionController.java From ZTuoExchange_framework with MIT License | 4 votes |
@RequiresPermissions(value = {"finance:member-transaction:page-query", "finance:member-transaction:page-query:recharge", "finance:member-transaction:page-query:check", "finance:member-transaction:page-query:fee"}, logical = Logical.OR) @PostMapping("page-query_es") @AccessLog(module = AdminModule.FINANCE, operation = "分页查找交易记录MemberTransaction") public MessageResult getPageQueryByES( MemberTransaction2ESVO transactionVO) { log.info(">>>>>>查询交易明细开始>>>>>>>>>"); try { String query="{\"from\":"+(transactionVO.getPageNo()-1)*transactionVO.getPageSize()+",\"size\":"+ transactionVO.getPageSize()+",\"sort\":[{\"create_time\":{\"order\":\"desc\"}}]," + "\"query\":{\"bool\":{\"must\":["; boolean deleteFlag =false; if(!StringUtils.isEmpty(transactionVO.getStartTime())&&!StringUtils.isEmpty(transactionVO.getEndTime())){ query+="{\"range\":{\"create_time\":{\"gte\":\""+transactionVO.getStartTime()+"\",\"lte\":\""+transactionVO.getEndTime()+"\"}}},"; deleteFlag =true; } if(!StringUtils.isEmpty(transactionVO.getType())){ query+="{\"match\":{\"type\":\""+transactionVO.getType()+"\"}},"; deleteFlag =true; } if(!StringUtils.isEmpty(transactionVO.getMemberId())){ query+="{\"match\":{\"member_id\":\""+transactionVO.getMemberId()+"\"}},"; deleteFlag =true; } if(!StringUtils.isEmpty(transactionVO.getMinMoney())){ query+="{\"range\":{\"amount\":{\"gte\":\""+transactionVO.getMinMoney()+"\"}}},"; deleteFlag =true; } if(!StringUtils.isEmpty(transactionVO.getMaxMoney())){ query+="{\"range\":{\"amount\":{\"lte\":\""+transactionVO.getMaxMoney()+"\"}}},"; deleteFlag =true; } if(!StringUtils.isEmpty(transactionVO.getMinFee())){ query+="{\"range\":{\"fee\":{\"gte\":\""+transactionVO.getMinFee()+"\"}}},"; } if(!StringUtils.isEmpty(transactionVO.getMaxFee())){ query+="{\"range\":{\"fee\":{\"lte\":\""+transactionVO.getMaxFee()+"\"}}},"; deleteFlag =true; } if(deleteFlag){ //去除最后一个符号 query.substring(0,query.length()-1); } query+="]}}}"; return success(esUtils.queryForAnyOne(JSONObject.parseObject(query),"member_transaction","mem_transaction")); }catch (Exception e){ log.info(">>>>>>查询异常>>>"+e); return error("查询异常"); } }
Example 17
Source File: EmailFilter.java From fake-smtp-server with Apache License 2.0 | 4 votes |
public boolean ignore(String sender, String recipient){ if(StringUtils.isEmpty(this.fakeSmtpConfigurationProperties.getFilteredEmailRegexList())){ return false; } return ignoreParticipant(sender) || ignoreParticipant(recipient); }
Example 18
Source File: HeartSyncRunnable.java From spring-boot-starter-micro-job with Apache License 2.0 | 4 votes |
/** * 检查相关参数 * * @param job 任务对象 */ private void checkParam(Job job, String jobKey) { if (job.autoStart() && StringUtils.isEmpty(job.cron())) { throw new JobException("Job:" + jobKey + " , Automatic startup requires configuration of cron parameters."); } }
Example 19
Source File: AuthApiLecturerProfitBiz.java From roncoo-education with MIT License | 4 votes |
/** * 讲师申请提现接口 * * @param authLecturerProfitSaveBO * @author wuyun */ @Transactional public Result<Integer> save(AuthLecturerProfitSaveBO authLecturerProfitSaveBO) { // 查询用户信息 UserExt userExt = userExtDao.getByUserNo(authLecturerProfitSaveBO.getLecturerUserNo()); if (ObjectUtil.isNull(userExt) || StatusIdEnum.NO.getCode().equals(userExt.getStatusId())) { return Result.error("该用户不存在"); } // 查询讲师信息 Lecturer lecturer = lecturerDao.getByLecturerUserNo(authLecturerProfitSaveBO.getLecturerUserNo()); if (ObjectUtil.isNull(lecturer) || StatusIdEnum.NO.getCode().equals(lecturer.getStatusId())) { return Result.error("该讲师不存在"); } // 查询用户账户信息 LecturerExt lecturerExt = lecturerExtDao.getByLecturerUserNo(authLecturerProfitSaveBO.getLecturerUserNo()); if (ObjectUtil.isNull(lecturerExt) || StatusIdEnum.NO.getCode().equals(lecturerExt.getStatusId())) { return Result.error("该账户不存在"); } if (lecturerExt.getEnableBalances().compareTo(authLecturerProfitSaveBO.getExtractMoney()) < 0) { return Result.error("账户余额不足"); } if (StringUtils.isEmpty(lecturerExt.getBankCardNo())) { return Result.error("银行卡未绑定"); } if (!StringUtils.hasText(authLecturerProfitSaveBO.getSmsCode())) { return Result.error("输入的验证码不能为空!"); } String redisSmsCode = redisTemplate.opsForValue().get(authLecturerProfitSaveBO.getClientId() + userExt.getMobile()); if (StringUtils.isEmpty(redisSmsCode)) { return Result.error("验证码已失效!"); } String sign = SignUtil.getByLecturer(lecturerExt.getTotalIncome(), lecturerExt.getHistoryMoney(), lecturerExt.getEnableBalances(), lecturerExt.getFreezeBalances()); if (sign.equals(lecturerExt.getSign())) { // 先存日志,再操作 LecturerProfit lecturerProfitInfo = BeanUtil.copyProperties(lecturerExt, LecturerProfit.class); lecturerProfitInfo.setGmtCreate(null); lecturerProfitInfo.setProfitStatus(ProfitStatusEnum.CONFIRMING.getCode()); // 讲师收入 BigDecimal lecturerProfit = authLecturerProfitSaveBO.getExtractMoney().multiply(lecturer.getLecturerProportion()); // 平台收入 BigDecimal platformProfit = authLecturerProfitSaveBO.getExtractMoney().subtract(lecturerProfit); lecturerProfitInfo.setLecturerProfit(lecturerProfit);// 讲师收入 = 提现金额 * 讲师分润比例 lecturerProfitInfo.setPlatformProfit(platformProfit);// 平台收入 = 提现金额 - 讲师收入 lecturerProfitDao.save(lecturerProfitInfo); // 减少账户可提现金额,增加账号冻结金额,生成新的签名防篡改 lecturerExt.setEnableBalances(lecturerExt.getEnableBalances().subtract(authLecturerProfitSaveBO.getExtractMoney()));// 账户可提现金额减去申请的金额 lecturerExt.setFreezeBalances(lecturerExt.getFreezeBalances().add(authLecturerProfitSaveBO.getExtractMoney()));// 账号冻结金额加上申请的金额 lecturerExt.setSign(SignUtil.getByLecturer(lecturerExt.getTotalIncome(), lecturerExt.getHistoryMoney(), lecturerExt.getEnableBalances(), lecturerExt.getFreezeBalances())); return Result.success(lecturerExtDao.updateById(lecturerExt)); } else { logger.error("签名为:{},{}", sign, lecturerExt.getSign()); return Result.error("账户异常,请联系客服"); } }
Example 20
Source File: SofaBootRpcProperties.java From sofa-rpc-boot-projects with Apache License 2.0 | 4 votes |
public String getEnableMesh() { return StringUtils.isEmpty(enableMesh) ? getDotString(new Object() { }.getClass().getEnclosingMethod().getName()) : enableMesh; }