Java Code Examples for org.apache.commons.lang3.ObjectUtils#isEmpty()
The following examples show how to use
org.apache.commons.lang3.ObjectUtils#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: DispatcherActor.java From Nickle-Scheduler with Apache License 2.0 | 6 votes |
/** * 初始化master路由 */ private void initMasterRouter() { ArrayList<Routee> routeeList = Lists.newArrayList(); for (String masterStr : masterList) { /** * master ip和端口号 */ String[] ipAndPort = masterStr.split(":"); if (ObjectUtils.isEmpty(ipAndPort) || ipAndPort.length != 2) { log.error("ipAndPort 为空"); ClientUtils.exit(getContext()); return; } String path = String.format(AKKA_REMOTE_MODEL, SCHEDULER_SYSTEM_NAME, ipAndPort[0], ipAndPort[1], MASTER_MANAGER_ACTOR_NAME); routeeList.add(new ActorRefRoutee(getContext().actorFor(path))); } masterRouter = new Router(new RandomRoutingLogic(), routeeList); }
Example 2
Source File: DispatcherActor.java From Nickle-Scheduler with Apache License 2.0 | 6 votes |
/** * 执行注册 * * @param clientRegisterEvent */ private void execRegister(ClientRegisterEvent clientRegisterEvent) throws InterruptedException { Config config = getContext().getSystem().settings().config(); //一直注册直到服务器返回数据 if (!ObjectUtils.isEmpty(masterList)) { if (registerSuccess) { log.info("已注册成功"); return; } ConfigObject configObject = config.getObject("akka.remote.netty.tcp"); String hostname = configObject.get("hostname").unwrapped().toString(); String portStr = configObject.get("port").unwrapped().toString(); Integer port = Integer.valueOf(portStr); registerEvent = new RegisterEvent(hostname, port, clientRegisterEvent.getJobDataList(), clientRegisterEvent.getTriggerDataList()); masterRouter.route(registerEvent, getSelf()); //睡眠1s后注册,避免频繁注册 Thread.sleep(1000); this.getSelf().tell(clientRegisterEvent, getSelf()); } else { log.error("master地址为空,将不继续注册"); ClientUtils.exit(getContext()); } }
Example 3
Source File: SysUserController.java From hdw-dubbo with Apache License 2.0 | 6 votes |
/** * 保存用户 */ @ApiOperation(value = "保存用户", notes = "保存用户") @PostMapping("/save") @RequiresPermissions("sys/user/save") public CommonResult save(@RequestBody @Validated(CreateGroup.class) SysUser user) { try { SysUser sysUser = sysUserService.selectByLoginName(user.getLoginName()); if (!ObjectUtils.isEmpty(sysUser)) { return CommonResult.failed("登录名已存在"); } String salt = ShiroUtil.getRandomSalt(16); user.setSalt(salt); String pwd = ShiroUtil.md5(user.getPassword(), user.getLoginName() + salt); user.setPassword(pwd); user.setCreateTime(new Date()); user.setCreateUserId(ShiroUtil.getUser().getId()); sysUserService.saveByVo(user); return CommonResult.success("添加成功"); } catch (Exception e) { log.error(e.getMessage()); throw new GlobalException("运行异常,请联系管理员"); } }
Example 4
Source File: OperationInErrorStateHandler.java From multiapps-controller with Apache License 2.0 | 6 votes |
private Execution findCurrentExecution(FlowableEngineEvent flowableEngineEvent) { try { // This is needed because when there are parallel CallActivity, the query will return multiple results for just one Execution List<Execution> currentExecutionsForProcess = getProcessEngineConfiguration().getRuntimeService() .createExecutionQuery() .executionId(flowableEngineEvent.getExecutionId()) .processInstanceId(flowableEngineEvent.getProcessInstanceId()) .list(); // Based on the above comment, one of the executions will have null activityId(because it will be the monitoring one) and thus // should be excluded from the list of executions return ObjectUtils.isEmpty(currentExecutionsForProcess) ? null : findCurrentExecution(currentExecutionsForProcess); } catch (Exception e) { return null; } }
Example 5
Source File: YamlRepresenter.java From multiapps with Apache License 2.0 | 6 votes |
@Override protected NodeTuple representJavaBeanProperty(Object javaBean, Property property, Object propertyValue, Tag customTag) { if (ObjectUtils.isEmpty(propertyValue)) { return null; } Field field = getField(javaBean.getClass(), property.getName()); String nodeName = field.isAnnotationPresent(YamlElement.class) ? field.getAnnotation(YamlElement.class) .value() : property.getName(); if (field.isAnnotationPresent(YamlAdapter.class)) { return getAdaptedTuple(propertyValue, field, nodeName); } NodeTuple defaultNode = super.representJavaBeanProperty(javaBean, property, propertyValue, customTag); return new NodeTuple(representData(nodeName), defaultNode.getValueNode()); }
Example 6
Source File: SysUserServiceImpl.java From hdw-dubbo with Apache License 2.0 | 5 votes |
@Override public SysUser selectByLoginName(String loginName) { SysUser sysUser = this.baseMapper.selectByLoginName(loginName); if (ObjectUtils.isEmpty(sysUser)) { return null; } return sysUser; }
Example 7
Source File: SysUserServiceImpl.java From hdw-dubbo with Apache License 2.0 | 5 votes |
@Override public LoginUserVo selectLoginUserVoByLoginName(String loginName) { SysUser sysUser = this.baseMapper.selectByLoginName(loginName); if (ObjectUtils.isEmpty(sysUser)) { return null; } LoginUserVo loginUserVo = new LoginUserVo(); BeanUtils.copyProperties(sysUser, loginUserVo); List<String> enterpriseIds = sysUserEnterpriseService.selectEnterpriseIdByUserId(sysUser.getId()); loginUserVo.setEnterpriseIdList(enterpriseIds); return loginUserVo; }
Example 8
Source File: DetermineServiceCreateUpdateServiceActionsStep.java From multiapps-controller with Apache License 2.0 | 5 votes |
private String buildServiceType(CloudServiceInstance service) { if (service.isUserProvided()) { return ResourceType.USER_PROVIDED_SERVICE.toString(); } String label = ObjectUtils.isEmpty(service.getLabel()) ? "unknown label" : service.getLabel(); String plan = ObjectUtils.isEmpty(service.getPlan()) ? "unknown plan" : service.getPlan(); return label + "/" + plan; }
Example 9
Source File: ValidatorUtil.java From multiapps with Apache License 2.0 | 5 votes |
public static void validateModifiableElements(String elementType, String elementPrefix, String containerName, String key, Object value, Object parentValue) throws ContentException { if (!ObjectUtils.isEmpty(parentValue) && !parentValue.equals(value)) { throw new ContentException(Messages.CANNOT_MODIFY_ELEMENT, elementType, getPrefixedName(elementPrefix, key), containerName); } }
Example 10
Source File: SchedulerActor.java From Nickle-Scheduler with Apache License 2.0 | 4 votes |
private void cycleSchedule(String msg) { log.info("开始扫描待调度任务"); SqlSession sqlSession = sqlSessionFactory.openSession(); try { NickleSchedulerTriggerMapper schedulerTriggerMapper = sqlSession.getMapper(NickleSchedulerTriggerMapper.class); NickleSchedulerLockMapper schedulerLockMapper = sqlSession.getMapper(NickleSchedulerLockMapper.class); //获取锁防止多个schduler同时获取到相同的任务 schedulerLockMapper.lock(LOCK_NAME); //查询需要执行的任务 QueryWrapper<NickleSchedulerTrigger> queryWrapper = new QueryWrapper<>(); /** * 一次性获取到下一次待调度的trigger,按需要调度时间降序,获取条件(满足一条即可): * 1、触发器状态为STAND_BY且时间在当前时间+调度时间内 * 2、触发器状态为ACQUIRED但更新时间小于一次性获取的时间+容错时间(为了防止调度器修改完状态后down机) */ log.info("autocommit:{}", sqlSession.getConnection().getAutoCommit()); queryWrapper.lambda() .and(qw -> qw.le(NickleSchedulerTrigger::getTriggerNextTime, System.currentTimeMillis()) .eq(NickleSchedulerTrigger::getTriggerStatus, STAND_BY)) .or(qw1 -> qw1.and(qw2 -> qw2.eq(NickleSchedulerTrigger::getTriggerStatus, ACQUIRED) .le(NickleSchedulerTrigger::getTriggerUpdateTime, System.currentTimeMillis() - (SCHEDULE_TIME + MISTAKE_TIME)))) .orderByDesc(NickleSchedulerTrigger::getTriggerNextTime); //分页取 Page<NickleSchedulerTrigger> triggerPage = new Page<>(1, SCHEDULE_TRIGGER_NUM); List<NickleSchedulerTrigger> nickleSchedulerTriggers = schedulerTriggerMapper.selectPage(triggerPage, queryWrapper).getRecords(); log.info("需要调度的触发器:{}", nickleSchedulerTriggers); if (ObjectUtils.isEmpty(nickleSchedulerTriggers)) { log.info("结束扫描待调度任务,无调度触发器"); nextSchedule(); return; } //修改trigger状态后释放锁 modifyTriggerStatus(nickleSchedulerTriggers, sqlSession); //添加任务 addRunJob(nickleSchedulerTriggers); //触发器不为空继续调度 getSelf().tell(SCHEDULE, getSelf()); } catch (Exception e) { sqlSession.rollback(); e.printStackTrace(); log.error("调度发生错误:{}", e.getMessage()); } finally { sqlSession.close(); } log.info("结束扫描待调度任务"); nextSchedule(); }
Example 11
Source File: SysLoginController.java From hdw-dubbo with Apache License 2.0 | 4 votes |
/** * 登录 */ @ApiOperation(value = "登录", notes = "登录") @PostMapping("/sys/login") public CommonResult login(@RequestBody SysLoginDTO loginDTO) { log.info("POST请求登录"); String username = decrypt(loginDTO.getUsername()); String password = decrypt(loginDTO.getPassword()); String verCode=loginDTO.getCaptcha(); String verKey=loginDTO.getCheckKey(); if (StringUtils.isBlank(username)) { return CommonResult.failed("用户名不能为空"); } if (StringUtils.isBlank(password)) { return CommonResult.failed("密码不能为空"); } if (StringUtils.isBlank(verCode)) { return CommonResult.failed("验证码不能为空"); } //TODO: 获取redis中的验证码 String redisCode = (String) redisService.get(verKey); //TODO: 判断验证码 if (org.springframework.util.StringUtils.isEmpty(redisCode) || !redisCode.equals(verCode.trim().toLowerCase())) { return CommonResult.failed("验证码不正确"); } SysUser sysUser = userService.selectByLoginName(username); if (ObjectUtils.isEmpty(sysUser)) { return CommonResult.failed("账号不存在"); } if (!sysUser.getPassword().equals(ShiroUtil.md5(password, username + sysUser.getSalt()))) { return CommonResult.failed("密码不正确"); } if(sysUser.getStatus()==1){ return CommonResult.failed("账号被禁用"); } //TODO:当企业不存在或者企业被禁用不允许登录 if (sysUser.getUserType() == 1) { Enterprise sysEnterprise = enterpriseService.getById(sysUser.getEnterpriseId()); if (null != sysEnterprise && sysEnterprise.getStatus() == 1) { return CommonResult.failed("企业被禁用,该账户不允许登录"); } else if (null == sysEnterprise) { return CommonResult.failed("企业不存在,该账户不允许登录"); } } //TODO: 生成token LoginUserVo loginUserVo=new LoginUserVo(); BeanUtils.copyProperties(sysUser,loginUserVo); String token=jwtTokenUtil.generateToken(loginUserVo); ConcurrentMap<String,Object> concurrentMap=new ConcurrentHashMap<>(); concurrentMap.put("token",token); log.info(" 用户名: " + loginUserVo.getName() + ",登录成功! "); sysLogService.addLog(loginUserVo.getLoginName(), "用户名: " + loginUserVo.getName() + ",登录成功!", 1, null); return CommonResult.success(concurrentMap); }
Example 12
Source File: CustomUserDetailsService.java From lion with Apache License 2.0 | 4 votes |
@Override public UserDetails loadUserByUsername(String username) { // 获取用户信息 SysUser sysUser = upmsManager.getUserByUsername(username); if (ObjectUtils.isEmpty(sysUser)) { throw new LionException("用户'" + username + "'不存在"); } // 获取角色信息 List<SysRole> sysRoles = upmsManager.getRoleByUserId(sysUser.getId()); if (ObjectUtils.isEmpty(sysRoles)) { throw new LionException("用户'" + username + "'没有对应的角色信息,请配置"); } Set<GrantedAuthority> grantedAuthorities = new HashSet(); sysRoles.stream().forEach(sysRole -> { // 角色必须是 ROLE_ 开头,可以在数据库中设置(这里在程序中设置) grantedAuthorities.add(new SimpleGrantedAuthority(ROLE_PREFIX + sysRole.getCode().toUpperCase())); // 获取菜单列表 /* List<SysMenu> sysMenus = upmsManager.getMenuByRoleId(sysRole.getId()); if (ObjectUtils.isEmpty(sysMenus)) { throw new LionException("用户'" + username + "'所在角色没有菜单信息,请配置"); } else { sysMenus.stream().forEach(sysMenu -> grantedAuthorities.add(new SimpleGrantedAuthority(sysMenu.getCode()))); } */ }); return new org.springframework.security.core.userdetails.User( sysUser.getUsername(), sysUser.getPassword(), sysUser.getEnabled(), sysUser.getAccountNonExpired(), sysUser.getCredentialsNonExpired(), sysUser.getAccountNonLocked(), grantedAuthorities); }
Example 13
Source File: PublishConfigurationEntriesStep.java From multiapps-controller with Apache License 2.0 | 4 votes |
private void infoConfigurationPublishment(ConfigurationEntry entry) { if (!ObjectUtils.isEmpty(entry.getContent())) { getStepLogger().info(MessageFormat.format(Messages.PUBLISHING_PUBLIC_PROVIDED_DEPENDENCY, entry.getProviderId())); } }