org.springframework.util.CollectionUtils Java Examples

The following examples show how to use org.springframework.util.CollectionUtils. 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: OneNetClient.java    From one-net with Apache License 2.0 6 votes vote down vote up
@Autowired
public OneNetClient(OneNetServerSessionManager oneNetServerSessionManager, OneNetClientConfig oneNetClientConfig) throws Exception {
    bootstrap = new Bootstrap();
    final EventLoopGroup workerGroup = new NioEventLoopGroup();
    bootstrap.group(workerGroup).channel(NioSocketChannel.class).option(ChannelOption.SO_KEEPALIVE, true);
    oneNetServerSessionManager.setClientName(oneNetClientConfig.getServerName());
    oneNetServerSessionManager.setReconnectAfterNSeconds(oneNetClientConfig.getReconnectSeconds());
    if (!CollectionUtils.isEmpty(oneNetClientConfig.getServerConfigs())) {
        clientName = oneNetClientConfig.getServerName();
        oneNetClientConfig.getServerConfigs().stream().forEach(
                (onenetClientServerConfig) ->
                        oneNetServerSessionManager.getOneNetServerSessions()
                                .putIfAbsent(oneNetClientConfig.getServerName(),
                                        new ServerSession(onenetClientServerConfig))
        );
    }
}
 
Example #2
Source File: PmsProductServiceImpl.java    From macrozheng with Apache License 2.0 6 votes vote down vote up
private void handleSkuStockCode(List<PmsSkuStock> skuStockList, Long productId) {
    if(CollectionUtils.isEmpty(skuStockList))return;
    for(int i=0;i<skuStockList.size();i++){
        PmsSkuStock skuStock = skuStockList.get(i);
        if(StringUtils.isEmpty(skuStock.getSkuCode())){
            SimpleDateFormat sdf = new SimpleDateFormat("yyyyMMdd");
            StringBuilder sb = new StringBuilder();
            //日期
            sb.append(sdf.format(new Date()));
            //四位商品id
            sb.append(String.format("%04d", productId));
            //三位索引id
            sb.append(String.format("%03d", i+1));
            skuStock.setSkuCode(sb.toString());
        }
    }
}
 
Example #3
Source File: SpringMvcEndpointGeneratorMojo.java    From springmvc-raml-plugin with Apache License 2.0 6 votes vote down vote up
@SuppressWarnings("unchecked")
private Rule<JCodeModel, JDefinedClass, ApiResourceMetadata> loadRule() {
	Rule<JCodeModel, JDefinedClass, ApiResourceMetadata> ruleInstance = new Spring4ControllerStubRule();
	try {
		ruleInstance = (Rule<JCodeModel, JDefinedClass, ApiResourceMetadata>) getClassRealm().loadClass(rule).newInstance();
		this.getLog().debug(StringUtils.collectionToCommaDelimitedString(ruleConfiguration.keySet()));
		this.getLog().debug(StringUtils.collectionToCommaDelimitedString(ruleConfiguration.values()));

		if (ruleInstance instanceof ConfigurableRule<?, ?, ?> && !CollectionUtils.isEmpty(ruleConfiguration)) {
			this.getLog().debug("SETTING CONFIG");
			((ConfigurableRule<?, ?, ?>) ruleInstance).applyConfiguration(ruleConfiguration);
		}
	} catch (Exception e) {
		getLog().error("Could not instantiate Rule " + this.rule + ". The default Rule will be used for code generation.", e);
	}
	return ruleInstance;
}
 
Example #4
Source File: SysRoleServiceImpl.java    From RuoYi with Apache License 2.0 6 votes vote down vote up
/**
 * 新增角色部门信息(数据权限)
 *
 * @param role 角色对象
 */
private int insertRoleDept(SysRole role) {
    int rows = 1;
    // 新增角色与部门(数据权限)管理
    List<SysRoleDept> list = new ArrayList<>();
    for (Long deptId : role.getDeptIds()) {
        SysRoleDept rd = new SysRoleDept();
        rd.setRoleId(role.getRoleId());
        rd.setDeptId(deptId);
        list.add(rd);
    }
    if (!CollectionUtils.isEmpty(list)) {
        rows = roleDeptMapper.batchRoleDept(list);
    }
    return rows;
}
 
Example #5
Source File: TradeOrderRepository.java    From tcc-transaction with Apache License 2.0 6 votes vote down vote up
public TradeOrder findByMerchantOrderNo(String merchantOrderNo) {
    List<TradeOrder> list = jdbcTemplate.query("select id,self_user_id,opposite_user_id,merchant_order_no,amount,status from red_trade_order where merchant_order_no = ?", new RowMapper<TradeOrder>() {
        @Override
        public TradeOrder mapRow(ResultSet rs, int i) throws SQLException {
            TradeOrder tradeOrder = new TradeOrder();
            tradeOrder.setId(rs.getLong("id"));
            tradeOrder.setSelfUserId(rs.getLong("self_user_id"));
            tradeOrder.setOppositeUserId(rs.getLong("opposite_user_id"));
            tradeOrder.setMerchantOrderNo(rs.getString("merchant_order_no"));
            tradeOrder.setAmount(rs.getBigDecimal("amount"));
            tradeOrder.setStatus(rs.getString("status"));
            return tradeOrder;
        }
    }, merchantOrderNo);
    if (!CollectionUtils.isEmpty(list)) {
        return list.get(0);
    } else {
        return null;
    }
}
 
Example #6
Source File: ActsCacheData.java    From sofa-acts with Apache License 2.0 6 votes vote down vote up
@SuppressWarnings("unchecked")
public static void loadDataSet() {

    collectDbTableName();

    File folder = FileUtil.getTestResourceFile(ActsPathConstants.OBJECT_DATA_PATH);
    if (folder.isDirectory()) {
        String[] files = folder.list();
        for (String fileName : files) {
            objectDataSet.add(fileName);
        }
    }

    File msgFile = FileUtil.getTestResourceFile(ActsPathConstants.MSGCONFIG_PATH);
    LinkedHashMap<?, ?> msgConfigData = FileUtil.readYaml(msgFile);
    if (CollectionUtils.isEmpty(msgConfigData)) {
        return;
    }

}
 
Example #7
Source File: BaseCanalClientTest.java    From canal-1.1.3 with Apache License 2.0 6 votes vote down vote up
protected void printSummary(Message message, long batchId, int size) {
    long memsize = 0;
    for (Entry entry : message.getEntries()) {
        memsize += entry.getHeader().getEventLength();
    }

    String startPosition = null;
    String endPosition = null;
    if (!CollectionUtils.isEmpty(message.getEntries())) {
        startPosition = buildPositionForDump(message.getEntries().get(0));
        endPosition = buildPositionForDump(message.getEntries().get(message.getEntries().size() - 1));
    }

    SimpleDateFormat format = new SimpleDateFormat(DATE_FORMAT);
    logger.info(context_format, new Object[] { batchId, size, memsize, format.format(new Date()), startPosition,
            endPosition });
}
 
Example #8
Source File: ValuedPropertyDocument.java    From hesperides with GNU General Public License v3.0 6 votes vote down vote up
@Override
protected List<AbstractValuedPropertyDocument> completeWithMustacheContent(List<AbstractPropertyDocument> abstractModelProperties) {
    List<PropertyDocument> matchingProperties = AbstractPropertyDocument.getFlatProperties(abstractModelProperties)
            .filter(abstractModuleProperty -> name.equals(abstractModuleProperty.getName()))
            .collect(Collectors.toList());

    if (CollectionUtils.isEmpty(matchingProperties)) {
        // Si on ne la retrouve pas dans le module (propriété définie puis
        // valorisée puis supprimée du template) on la conserve telle quelle
        return Collections.singletonList(this);
    }
    // Il arrive qu'une propriété soit déclarée plusieurs fois avec le même nom
    // et un commentaire distinct. Dans ce cas on crée autant de propriétés valorisées
    // qu'il n'y a de propriétés déclarées
    return matchingProperties.stream()
            .map(propertyDocument -> new ValuedPropertyDocument(name, value))
            .collect(Collectors.toList());
}
 
Example #9
Source File: AbstractMessageConverterMethodProcessor.java    From spring4-understanding with Apache License 2.0 6 votes vote down vote up
@SuppressWarnings("unchecked")
private boolean safeExtension(HttpServletRequest request, String extension) {
	if (!StringUtils.hasText(extension)) {
		return true;
	}
	extension = extension.toLowerCase(Locale.ENGLISH);
	if (this.safeExtensions.contains(extension)) {
		return true;
	}
	String pattern = (String) request.getAttribute(HandlerMapping.BEST_MATCHING_PATTERN_ATTRIBUTE);
	if (pattern != null && pattern.endsWith("." + extension)) {
		return true;
	}
	if (extension.equals("html")) {
		String name = HandlerMapping.PRODUCIBLE_MEDIA_TYPES_ATTRIBUTE;
		Set<MediaType> mediaTypes = (Set<MediaType>) request.getAttribute(name);
		if (!CollectionUtils.isEmpty(mediaTypes) && mediaTypes.contains(MediaType.TEXT_HTML)) {
			return true;
		}
	}
	return safeMediaTypesForExtension(extension);
}
 
Example #10
Source File: PatchPermissionModel_J10003.java    From ranger with Apache License 2.0 6 votes vote down vote up
private int assignPermissions(List<XXPortalUser> xXPortalUsers){
	int countUserPermissionUpdated = 0;
	if(!CollectionUtils.isEmpty(xXPortalUsers)){
		for (XXPortalUser xPortalUser : xXPortalUsers) {
			try{
				if(xPortalUser!=null){
					VXPortalUser vPortalUser = xPortalUserService.populateViewBean(xPortalUser);
					if(vPortalUser!=null){
						vPortalUser.setUserRoleList(daoManager.getXXPortalUserRole().findXPortalUserRolebyXPortalUserId(vPortalUser.getId()));
						xUserMgr.assignPermissionToUser(vPortalUser, false);
						countUserPermissionUpdated += 1;
						logger.info("Permissions assigned/updated on base of User's Role, UserId [" + xPortalUser.getId() + "]");
					}
				}
			}catch(Exception ex){
			}
		}
	}
	return countUserPermissionUpdated;
}
 
Example #11
Source File: AbstractRouterDistributor.java    From spring-cloud-huawei with Apache License 2.0 6 votes vote down vote up
@Override
public List<T> distribute(String targetServiceName, List<T> list, PolicyRuleItem invokeRule) {
  //初始化LatestVersion
  initLatestVersion(targetServiceName, list);

  invokeRule.check(
      RouterRuleCache.getServiceInfoCacheMap().get(targetServiceName).getLatestVersionTag());

  // 建立tag list
  Map<TagItem, List<T>> versionServerMap = getDistributList(targetServiceName, list, invokeRule);

  //如果没有匹配到合适的规则,直接返回最新版本的服务列表
  if (CollectionUtils.isEmpty(versionServerMap)) {
    LOGGER.debug("route management can not match any rule and route the latest version");
    return getLatestVersionList(list, targetServiceName);
  }

  // 分配流量,返回结果
  TagItem targetTag = getFiltedServerTagItem(invokeRule, targetServiceName);
  if (versionServerMap.containsKey(targetTag)) {
    return versionServerMap.get(targetTag);
  }
  return getLatestVersionList(list, targetServiceName);
}
 
Example #12
Source File: SpringProfileDocumentMatcher.java    From canal with Apache License 2.0 6 votes vote down vote up
@Override
public YamlProcessor.MatchStatus matches(Properties properties) {
    List<String> profiles = extractSpringProfiles(properties);
    ProfilesMatcher profilesMatcher = getProfilesMatcher();
    Set<String> negative = extractProfiles(profiles, ProfileType.NEGATIVE);
    Set<String> positive = extractProfiles(profiles, ProfileType.POSITIVE);
    if (!CollectionUtils.isEmpty(negative)) {
        if (profilesMatcher.matches(negative) == YamlProcessor.MatchStatus.FOUND) {
            return YamlProcessor.MatchStatus.NOT_FOUND;
        }
        if (CollectionUtils.isEmpty(positive)) {
            return YamlProcessor.MatchStatus.FOUND;
        }
    }
    return profilesMatcher.matches(positive);
}
 
Example #13
Source File: IoTService.java    From iot-dc with Apache License 2.0 6 votes vote down vote up
/**
 * 获取 IoT 映射信息
 */
private Map<String, IotInfo> getIoTSnIdMapper(String key) throws Exception {
    LOGGER.info("get IoT SnId Mapper... key is [{}]", key);
    Map<Object, Object> mapperMap = redisService.hGetAll(key);
    if (CollectionUtils.isEmpty(mapperMap)) {
        LOGGER.warn("the IoTSnIdMapper is empty!");
        return new HashMap<>(0);
    }

    Map<String, IotInfo> mapperStrMap = new HashMap<>(mapperMap.size());
    Set<Object> keySet = mapperMap.keySet();
    for (Object sn : keySet) {
        Object data = mapperMap.get(sn);
        IotInfo dataMap = JsonUtils.jsonStr2Obj(String.valueOf(data), IotInfo.class);
        mapperStrMap.put(String.valueOf(sn), dataMap);
    }
    return mapperStrMap;
}
 
Example #14
Source File: OpenAPIBuilder.java    From springdoc-openapi with Apache License 2.0 6 votes vote down vote up
/**
 * Instantiates a new Open api builder.
 *
 * @param openAPI the open api
 * @param context the context
 * @param securityParser the security parser
 * @param springDocConfigProperties the spring doc config properties
 * @param openApiBuilderCustomisers the open api builder customisers
 */
OpenAPIBuilder(Optional<OpenAPI> openAPI, ApplicationContext context, SecurityParser securityParser,
		SpringDocConfigProperties springDocConfigProperties,
		Optional<List<OpenApiBuilderCustomiser>> openApiBuilderCustomisers) {
	if (openAPI.isPresent()) {
		this.openAPI = openAPI.get();
		if (this.openAPI.getComponents() == null)
			this.openAPI.setComponents(new Components());
		if (this.openAPI.getPaths() == null)
			this.openAPI.setPaths(new Paths());
		if (!CollectionUtils.isEmpty(this.openAPI.getServers()))
			this.isServersPresent = true;
	}
	this.context = context;
	this.securityParser = securityParser;
	this.springDocConfigProperties = springDocConfigProperties;
	this.openApiBuilderCustomisers = openApiBuilderCustomisers;
}
 
Example #15
Source File: PmsProductServiceImpl.java    From xmall with MIT License 6 votes vote down vote up
private void handleSkuStockCode(List<PmsSkuStock> skuStockList, Long productId) {
    if(CollectionUtils.isEmpty(skuStockList))return;
    for(int i=0;i<skuStockList.size();i++){
        PmsSkuStock skuStock = skuStockList.get(i);
        if(StringUtils.isEmpty(skuStock.getSkuCode())){
            SimpleDateFormat sdf = new SimpleDateFormat("yyyyMMdd");
            StringBuilder sb = new StringBuilder();
            //日期
            sb.append(sdf.format(new Date()));
            //四位商品id
            sb.append(String.format("%04d", productId));
            //三位索引id
            sb.append(String.format("%03d", i+1));
            skuStock.setSkuCode(sb.toString());
        }
    }
}
 
Example #16
Source File: ReplicationRoutingDataSource.java    From spring-data-mybatis with Apache License 2.0 6 votes vote down vote up
public ReplicationRoutingDataSource(DataSource master, List<DataSource> slaves) {

		Assert.notNull(master, "master datasource can not be null.");

		Map<Object, Object> targetDataSources = new HashMap<>();
		targetDataSources.put(MASTER_KEY, new LazyConnectionDataSourceProxy(master));
		if (!CollectionUtils.isEmpty(slaves)) {
			slaveSize = slaves.size();
			for (int i = 0; i < slaveSize; i++) {
				targetDataSources.put(SLAVE_PREFIX + i,
						new LazyConnectionDataSourceProxy(slaves.get(i)));
			}
		}
		else {
			this.onlyMaster = true;
		}
		setTargetDataSources(targetDataSources);
		setDefaultTargetDataSource(targetDataSources.get(MASTER_KEY));
	}
 
Example #17
Source File: RequestMappingInfoHandlerMapping.java    From spring-analysis-note with MIT License 6 votes vote down vote up
/**
 * Return declared "params" conditions but only among those that also
 * match the "methods", "consumes", and "params" conditions.
 */
public List<String[]> getParamConditions() {
	List<String[]> result = new ArrayList<>();
	for (PartialMatch match : this.partialMatches) {
		if (match.hasProducesMatch()) {
			Set<NameValueExpression<String>> set = match.getInfo().getParamsCondition().getExpressions();
			if (!CollectionUtils.isEmpty(set)) {
				int i = 0;
				String[] array = new String[set.size()];
				for (NameValueExpression<String> expression : set) {
					array[i++] = expression.toString();
				}
				result.add(array);
			}
		}
	}
	return result;
}
 
Example #18
Source File: UiTopicService.java    From pmq with Apache License 2.0 6 votes vote down vote up
private void checkQueueMessageCount(List<QueueEntity> queueEntities) {
	if (!soaConfig.getMaxTableMessageSwitch()) {
		return;
	}
	if (CollectionUtils.isEmpty(queueEntities)) {
		return;
	}
	Long allMessageCount = 0L;

	for (QueueEntity queueEntity : queueEntities) {
		allMessageCount += getQueueMessage(queueEntity);
	}

	if (allMessageCount / queueEntities.size() > soaConfig.getMaxTableMessage()) {
		throw new CheckFailException("每队列消息量未达到最大值,不允许扩容,可联系管理员强制扩容");
	}
}
 
Example #19
Source File: DocServiceImpl.java    From super-cloudops with Apache License 2.0 6 votes vote down vote up
private void update(FileChanges fileChanges) {
	fileChanges.setId(null);
	fileChanges.preInsert();
	fileChanges.setIsLatest(1);
	fileChanges.setAction("edit");
	String path = writeContentIntoFile(fileChanges);
	fileChanges.setContent(path);
	fileChangesDao.updateIsLatest(fileChanges.getDocCode());
	fileChangesDao.insertSelective(fileChanges);
	// label
	List<Integer> labelIds = fileChanges.getLabelIds();
	if(!CollectionUtils.isEmpty(labelIds)){
		List<FileLabel> fileLabels = new ArrayList<>();
		for(Integer labelId : labelIds){
			FileLabel fileLabel = new FileLabel();
			fileLabel.preInsert();
			fileLabel.setFileId(fileChanges.getId());
			fileLabel.setLabelId(labelId);
			fileLabels.add(fileLabel);
		}
		fileLabelDao.insertBatch(fileLabels);
	}
}
 
Example #20
Source File: DataxJsonHelper.java    From datax-web with MIT License 6 votes vote down vote up
@Override
public Map<String, Object> buildHBaseReader() {
    DataxHbasePojo dataxHbasePojo = new DataxHbasePojo();
    dataxHbasePojo.setJdbcDatasource(readerDatasource);
    List<Map<String, Object>> columns = Lists.newArrayList();
    for (int i = 0; i < readerColumns.size(); i++) {
        Map<String, Object> column = Maps.newLinkedHashMap();
        column.put("name", readerColumns.get(i));
        column.put("type", "string");
        columns.add(column);
    }
    dataxHbasePojo.setColumns(columns);
    dataxHbasePojo.setReaderHbaseConfig(readerDatasource.getZkAdress());
    String readerTable=!CollectionUtils.isEmpty(readerTables)?readerTables.get(0):Constants.STRING_BLANK;
    dataxHbasePojo.setReaderTable(readerTable);
    dataxHbasePojo.setReaderMode(hbaseReaderDto.getReaderMode());
    dataxHbasePojo.setReaderRange(hbaseReaderDto.getReaderRange());
    return readerPlugin.buildHbase(dataxHbasePojo);
}
 
Example #21
Source File: CometInterceptor.java    From Milkomeda with MIT License 6 votes vote down vote up
private void printLog(HttpServletRequest request) {
    CometLoggerProperties logger = this.cometLoggerProperties;
    List<String> exclude = logger.getExclude();
    String requestURI = request.getRequestURI();
    if (!CollectionUtils.isEmpty(exclude)) {
        if (exclude.contains(requestURI)) {
            return;
        }
    }
    List<CometLoggerProperties.Strategy> strategyList = this.strategyList;
    if (CollectionUtils.isEmpty(strategyList)) {
        return;
    }
    String requestParams = CometAspect.resolveThreadLocal.get();
    for (CometLoggerProperties.Strategy strategy : strategyList) {
        if (CollectionUtils.isEmpty(strategy.getPaths()) ||
                !URLPathMatcher.match(strategy.getPaths(), requestURI)) {
            continue;
        }
        log.info(urlPlaceholderParser.parse(strategy.getTpl(), request, requestParams, strategy.getCacheKeys()));
        break;
    }
}
 
Example #22
Source File: RouterFunctionMapping.java    From spring-analysis-note with MIT License 5 votes vote down vote up
@Override
public void afterPropertiesSet() throws Exception {
	if (this.routerFunction == null) {
		initRouterFunction();
	}
	if (CollectionUtils.isEmpty(this.messageConverters)) {
		initMessageConverters();
	}
}
 
Example #23
Source File: SysRoleResourcesServiceImpl.java    From springboot-learn with MIT License 5 votes vote down vote up
/**
 * 批量插入,支持批量插入的数据库可以使用,例如MySQL,H2等,另外该接口限制实体包含id属性并且必须为自增列
 *
 * @param entities
 */
@Override
public void insertList(List<RoleResources> entities) {
    Assert.notNull(entities, "entities不可为空!");
    if (CollectionUtils.isEmpty(entities)) {
        return;
    }
    List<SysRoleResources> sysRoleResources = new ArrayList<>();
    for (RoleResources rr : entities) {
        rr.setUpdateTime(new Date());
        rr.setCreateTime(new Date());
        sysRoleResources.add(rr.getSysRoleResources());
    }
    resourceMapper.insertList(sysRoleResources);
}
 
Example #24
Source File: UserServiceImpl.java    From halo with GNU General Public License v3.0 5 votes vote down vote up
@Override
public Optional<User> getCurrentUser() {
    // Find all users
    List<User> users = listAll();

    if (CollectionUtils.isEmpty(users)) {
        // Return empty user
        return Optional.empty();
    }

    // Return the first user
    return Optional.of(users.get(0));
}
 
Example #25
Source File: InitSystemConfig.java    From plumemo with Apache License 2.0 5 votes vote down vote up
public void init() {

        List<Config> configList = configDao.selectList(null);
        configList.forEach(config -> {
            log.debug("config_key: {}, config_vlaue: {}", config.getConfigKey(), config.getConfigValue());
            ConfigCache.putConfig(config.getConfigKey(), config.getConfigValue());
        });

        List<AuthUser> authUsers = authUserDao.selectList(new LambdaQueryWrapper<AuthUser>().eq(AuthUser::getRoleId, RoleEnum.ADMIN.getRoleId()));
        if (!CollectionUtils.isEmpty(authUsers)) {
            SystemPropertyBean systemPropertyBean = BeanTool.getBean(SystemPropertyBean.class);
            systemPropertyBean.setAccessKey(authUsers.get(0).getAccessKey());
            systemPropertyBean.setSecretKey(authUsers.get(0).getSecretKey());
        }
    }
 
Example #26
Source File: MembershipVo.java    From sophia_scaffolding with Apache License 2.0 5 votes vote down vote up
/**
 * bo转vo
 * @param list
 * @return
 */
public List<MembershipVo> buildVoList(List<Membership> list){
    List<MembershipVo> voList = new ArrayList<>();
    if(CollectionUtils.isEmpty(list)){
        return voList;
    }
    list.forEach(item ->{
        MembershipVo vo = new MembershipVo();
        BeanUtils.copyProperties(item,vo);
        voList.add(vo);
    });
    return voList;
}
 
Example #27
Source File: ResourceHttpRequestHandler.java    From spring4-understanding with Apache License 2.0 5 votes vote down vote up
/**
 * Look for a {@link org.springframework.web.servlet.resource.PathResourceResolver}
 * among the {@link #getResourceResolvers() resource resolvers} and configure
 * its {@code "allowedLocations"} to match the value of the
 * {@link #setLocations(java.util.List) locations} property unless the "allowed
 * locations" of the {@code PathResourceResolver} is non-empty.
 */
protected void initAllowedLocations() {
	if (CollectionUtils.isEmpty(this.locations)) {
		return;
	}
	for (int i = getResourceResolvers().size()-1; i >= 0; i--) {
		if (getResourceResolvers().get(i) instanceof PathResourceResolver) {
			PathResourceResolver pathResolver = (PathResourceResolver) getResourceResolvers().get(i);
			if (ObjectUtils.isEmpty(pathResolver.getAllowedLocations())) {
				pathResolver.setAllowedLocations(getLocations().toArray(new Resource[getLocations().size()]));
			}
			break;
		}
	}
}
 
Example #28
Source File: HbaseSchemaMapper.java    From pinpoint with Apache License 2.0 5 votes vote down vote up
private Set<String> mapIncludeFiles(List<HbaseSchema.Include> schemaIncludes) {
    if (CollectionUtils.isEmpty(schemaIncludes)) {
        return Collections.emptySet();
    }
    Set<String> includeFiles = new LinkedHashSet<>();
    for (HbaseSchema.Include schemaInclude : schemaIncludes) {
        String includeFile = schemaInclude.getFile();
        if (includeFiles.contains(includeFile)) {
            throw new InvalidHbaseSchemaException("Duplicate include file : " + includeFile);
        }
        includeFiles.add(includeFile);
    }
    return includeFiles;
}
 
Example #29
Source File: DeleteAppPolicyExecutorTask.java    From cf-butler with Apache License 2.0 5 votes vote down vote up
private boolean isWhitelisted(ApplicationPolicy policy, String organization) {
   	Set<String> prunedSet = new HashSet<>(policy.getOrganizationWhiteList());
   	while (prunedSet.remove(""));
   	Set<String> whitelist =
   			CollectionUtils.isEmpty(prunedSet) ?
   					prunedSet: policy.getOrganizationWhiteList();
   	return
		whitelist.isEmpty() ? true: policy.getOrganizationWhiteList().contains(organization);
}
 
Example #30
Source File: StackV4RequestValidator.java    From cloudbreak with Apache License 2.0 5 votes vote down vote up
@Override
public ValidationResult validate(StackV4Request subject) {
    ValidationResultBuilder validationBuilder = ValidationResult.builder();
    if (CollectionUtils.isEmpty(subject.getInstanceGroups())) {
        validationBuilder.error("Stack request must contain instance groups.");
    }
    validateTemplates(subject, validationBuilder);
    validateEncryptionKey(subject, validationBuilder);
    return validationBuilder.build();
}