Java Code Examples for org.apache.commons.collections.CollectionUtils.isEmpty()

The following are Jave code examples for showing how to use isEmpty() of the org.apache.commons.collections.CollectionUtils class. You can vote up the examples you like. Your votes will be used in our system to get more good examples.
+ Save this method
Example 1
Project: xproject   File: AdminController.java   View Source Code Vote up 7 votes
/**
 * 获取当前登录者所能看见的菜单集合
 * @param request
 * @param response
 * @return
 */
@ResponseBody
@RequestMapping(value="/login/user/menus", method=GET, produces=APPLICATION_JSON)
public Object getLoginUserMenuList(HttpServletRequest request, HttpServletResponse response) {
	List<Map<String,Object>> dataList = new ArrayList<Map<String,Object>>();
	try {
		List<AdminResource> userMenuResources = new ArrayList<AdminResource>();
		AdminUserRealm realm = ShiroUtils.getRealm(AdminUserRealm.class);
		AuthorizationInfo authInfo = realm.getAuthorizationInfo(SecurityUtils.getSubject().getPrincipals());
		if(authInfo instanceof CustomAuthorizationInfo){
			CustomAuthorizationInfo<AdminResource> authorizationInfo = (CustomAuthorizationInfo<AdminResource>) authInfo;
			Set<AdminResource> userResources = authorizationInfo.getResources();
			if(!CollectionUtils.isEmpty(userResources)){
				for(AdminResource resource : userResources){
					if(AdminResourceActionTypeEnum.ADMIN_RESOURCE_ACTION_TYPE_MENU.getTypeCode().equals(resource.getActionType())){
						userMenuResources.add(resource);
					}
				}
				dataList = resourceTreeBuilder.buildObjectTree(GlobalConstants.DEFAULT_ADMIN_ROOT_RESOURCE_ID, userMenuResources, resourceNavMenuNodeConverter);
			}
		}
	} catch (Exception e) {
		logger.error(e.getMessage(), e);
	}
	return dataList;
}
 
Example 2
Project: happylifeplat-transaction   File: ZookeeperRecoverTransactionServiceImpl.java   View Source Code Vote up 7 votes
/**
 * 批量删除补偿事务信息
 *
 * @param ids             ids 事务id集合
 * @param applicationName 应用名称
 * @return true 成功
 */
@Override
public Boolean batchRemove(List<String> ids, String applicationName) {
    if (CollectionUtils.isEmpty(ids) || StringUtils.isBlank(applicationName)) {
        return Boolean.FALSE;
    }

    final String rootPath = RepositoryPathUtils.buildZookeeperPath(applicationName);
    ids.stream().map(id -> {
        try {
            final String path = buildRootPath(rootPath, id);
            byte[] content = zooKeeper.getData(path,
                    false, new Stat());
            final TransactionRecoverAdapter adapter = objectSerializer.deSerialize(content, TransactionRecoverAdapter.class);
            zooKeeper.delete(path, adapter.getVersion());
            return 1;
        } catch (Exception e) {
            e.printStackTrace();
            return -1;
        }

    }).count();

    return Boolean.TRUE;
}
 
Example 3
Project: configx   File: ConfigContext.java   View Source Code Vote up 7 votes
/**
 * 调用所有的{@link ConfigItemPostProcessor}进行配置项预处理
 *
 * @param versionPropertySource
 */
private void invokeConfigItemPostProcessors(VersionPropertySource<ConfigItemList> versionPropertySource) {
    if (versionPropertySource == null) {
        return;
    }
    List<ConfigItemPostProcessor> configItemPostProcessors = this.configItemPostProcessors;
    if (CollectionUtils.isEmpty(configItemPostProcessors)) {
        return;
    }

    long version = versionPropertySource.getVersion();
    EnumerablePropertySource<?> propertySource = versionPropertySource.getSource();
    if (propertySource == null) {
        return;
    }
    if (!(propertySource instanceof ConfigPropertySource)) {
        return;
    }

    ConfigPropertySource configPropertySource = (ConfigPropertySource) propertySource;

    for (ConfigItemPostProcessor postProcessor : configItemPostProcessors) {
        postProcessor.postProcessConfigItems(version, configPropertySource);
    }
}
 
Example 4
Project: circus-train   File: CommonBeans.java   View Source Code Vote up 7 votes
private HiveConf newHiveConf(TunnelMetastoreCatalog hiveCatalog, Configuration baseConf) {
  List<String> siteXml = hiveCatalog.getSiteXml();
  if (CollectionUtils.isEmpty(siteXml)) {
    LOG.info("No Hadoop site XML is defined for catalog {}.", hiveCatalog.getName());
  }
  Map<String, String> properties = new HashMap<>();
  for (Entry<String, String> entry : baseConf) {
    properties.put(entry.getKey(), entry.getValue());
  }
  if (hiveCatalog.getHiveMetastoreUris() != null) {
    properties.put(ConfVars.METASTOREURIS.varname, hiveCatalog.getHiveMetastoreUris());
  }
  configureMetastoreTunnel(hiveCatalog.getMetastoreTunnel(), properties);
  putConfigurationProperties(hiveCatalog.getConfigurationProperties(), properties);
  HiveConf hiveConf = new HiveConfFactory(siteXml, properties).newInstance();
  return hiveConf;
}
 
Example 5
Project: xm-gate   File: GatewayResource.java   View Source Code Vote up 7 votes
private Map<String, String> receiveServiceStatus(List<ServiceInstance> instances) {
    if (CollectionUtils.isEmpty(instances)) {
        return Collections.emptyMap();
    }
    Map<String, String> instancesStatus = new HashMap<>();

    instances.stream()
        .filter(serviceInstance -> serviceInstance.getUri() != null)
        .forEach(instance -> {
            String uri = instance.getUri().toString();
            String status;
            try {
                Map body = restTemplate.exchange(
                    String.format("%s/management/health", uri),
                    HttpMethod.GET, null, Map.class).getBody();
                status = (String) body.get(STATUS);
            } catch (RestClientException e) {
                log.error("Error occurred while getting status of the microservice by URI {}",
                    uri, e);
                status = "DOWN";
            }
            instancesStatus.put(uri, status);
        });
    return instancesStatus;
}
 
Example 6
Project: happylifeplat-tcc   File: MongoCompensationServiceImpl.java   View Source Code Vote up 7 votes
/**
 * 批量删除补偿事务信息
 *
 * @param ids             ids 事务id集合
 * @param applicationName 应用名称
 * @return true 成功
 */
@Override
public Boolean batchRemove(List<String> ids, String applicationName) {
    if (CollectionUtils.isEmpty(ids) || StringUtils.isBlank(applicationName)) {
        return Boolean.FALSE;
    }
    final String mongoTableName = RepositoryPathUtils.buildMongoTableName(applicationName);

    ids.forEach(id -> {
        Query query = new Query();
        query.addCriteria(new Criteria("transId").is(id));
        mongoTemplate.remove(query, mongoTableName);
    });

    return Boolean.TRUE;
}
 
Example 7
Project: happylifeplat-tcc   File: RedisCompensationServiceImpl.java   View Source Code Vote up 6 votes
/**
 * 批量删除补偿事务信息
 *
 * @param ids             ids 事务id集合
 * @param applicationName 应用名称
 * @return true 成功
 */
@Override
public Boolean batchRemove(List<String> ids, String applicationName) {
    if (CollectionUtils.isEmpty(ids) || StringUtils.isBlank(applicationName)) {
        return Boolean.FALSE;
    }
    String keyPrefix = RepositoryPathUtils.buildRedisKeyPrefix(applicationName);
    final String[] keys = ids.stream()
            .map(id -> RepositoryPathUtils.buildRedisKey(keyPrefix,id)).toArray(String[]::new);

    jedisClient.del(keys);
    return Boolean.TRUE;
}
 
Example 8
Project: visitormanagement   File: OriginConverter.java   View Source Code Vote up 6 votes
@Override
public Collection<VisitorOriginDTO> convertToDTO(Collection<Origin> origins) {
	if (CollectionUtils.isEmpty(origins)) {
		return null;
	}
	return origins.stream().filter(Objects::nonNull).map(origin -> convertToDTO(origin))
			.collect(Collectors.toList());
}
 
Example 9
Project: visitormanagement   File: EmployeeConverter.java   View Source Code Vote up 6 votes
@Override
public Collection<EmployeeDTO> convertToDTO(Collection<Employee> employees) {
	if (CollectionUtils.isEmpty(employees)) {
		return null;
	}
	return employees.stream().
			filter(Objects::nonNull).map(employee -> convertToDTO(employee))
			.collect(Collectors.toList());
}
 
Example 10
Project: xm-commons   File: TenantListRepository.java   View Source Code Vote up 6 votes
private void assertExistTenants(Set<TenantState> tenantKeys) {
    if (CollectionUtils.isEmpty(tenantKeys)) {
        final String error = "Tenant list for " + applicationName + " empty. Check tenants-list.json.";
        log.error(error);
        throw new IllegalStateException(error);
    }
}
 
Example 11
Project: EasyPackage   File: TaskBiz.java   View Source Code Vote up 6 votes
private boolean recordMailReceiver(int taskGroupId,
        List<Integer> mailReceiverIdList) {
    if (CollectionUtils.isEmpty(mailReceiverIdList)) {
        return false;
    }
    return true;
}
 
Example 12
Project: keti   File: PrivilegeManagementServiceImpl.java   View Source Code Vote up 6 votes
@Override
@Transactional(readOnly = true)
public List<BaseResource> getResources() {
    ZoneEntity zone = this.zoneResolver.getZoneEntityOrFail();

    List<BaseResource> resources = new ArrayList<>();
    List<ResourceEntity> resourceEntities = this.resourceRepository.findByZone(zone);

    if (!CollectionUtils.isEmpty(resourceEntities)) {
        for (ResourceEntity resourceEntity : resourceEntities) {
            resources.add(this.privilegeConverter.toResource(resourceEntity));
        }
    }
    return resources;
}
 
Example 13
Project: Dragonfly   File: CacheDetectorImpl.java   View Source Code Vote up 6 votes
private List<String> getFullPieceMd5s(Task task, FileMetaData metaData) {
    List<String> pieceMd5s = taskService.getFullPieceMd5sByTask(task);
    if (CollectionUtils.isEmpty(pieceMd5s)) {
        pieceMd5s = fileMetaDataService.readPieceMd5(task.getTaskId(), metaData.getRealMd5());
    }
    return pieceMd5s;
}
 
Example 14
Project: xxpay-master   File: ObjectValidUtil.java   View Source Code Vote up 6 votes
public static boolean isValid(Object... objs) {
    if (objs == null || objs.length < 1) {
        return false;
    }

    for (Object obj : objs) {
        if (obj instanceof Short) {
            if (isNull(obj)) {
                return false;
            }
        } else if (obj instanceof Integer) {
            if (isInvalidInteger((Integer) obj)) {
                return false;
            }
        } else if (obj instanceof Long) {
            if (isInvalidLong((Long) obj)) {
                return false;
            }
        } else if (obj instanceof String) {
            if (isInvalidString(obj.toString())) {
                return false;
            }
        } else if (obj instanceof List) {
            if (CollectionUtils.isEmpty((List) obj)) {
                return false;
            }
        } else if (obj instanceof Map) {
            if (isNull(obj) || ((Map) obj).isEmpty()) {
                return false;
            }
        } else {
            if (isNull(obj)) {
                return false;
            }
        }
    }
    return true;
}
 
Example 15
Project: mtgo-best-bot   File: RawLinesProcessor.java   View Source Code Vote up 6 votes
public ProcessingLifecycleStatus determineLifecycleStatus(RawLines rawLines) {
    ProcessingLifecycleStatus status = ProcessingLifecycleStatus.UNKNOWN;
    List<List<RawWord>> lines = rawLines.getRawLines();

    if(CollectionUtils.isEmpty(lines)) {
        return status;
    }

    for(List<RawWord> line : lines) {
        if(status != ProcessingLifecycleStatus.UNKNOWN) {
            break;
        }

        for(RawWord word : line) {
            if(word.getWord().contains("Forgot") || word.getWord().contains("Password")) {
                status = ProcessingLifecycleStatus.LOGIN_READY;
                break;
            } else if(word.getWord().contains("Welcome")) {
                status = ProcessingLifecycleStatus.APPLICATION_READY;
                break;
            } else if(word.getWord().contains("Trade")) {
                status = ProcessingLifecycleStatus.TRADE_PARTNER;
            } else if(word.getWord().contains("SOFTWARE")) {
                status = ProcessingLifecycleStatus.ACCEPT_TOS_EULA_READY;
            }
        }
    }

    return status;
}
 
Example 16
Project: -artemis-disruptor-miaosha   File: RequestDtoEventDbOutputer.java   View Source Code Vote up 5 votes
@Override
public void onEvent(RequestDtoEvent event, long sequence, boolean endOfBatch) throws Exception {

  if (event.hasErrorOrException()) {
    return;
  }

  List<Command> commandList = event.getCommandCollector().getCommandList();
  if (CollectionUtils.isEmpty(commandList)) {
    return;
  }

  for (Command command : commandList) {
    commandDispatcher.dispatch(command);
  }

}
 
Example 17
Project: redirector   File: BatchChange.java   View Source Code Vote up 5 votes
public void addEntityToSave(Expressions entityToSave) {
    if (CollectionUtils.isEmpty(entitiesToSave)) {
        entitiesToSave = new ArrayList<Expressions>();
    }
    entitiesToSave.add(entityToSave);
}
 
Example 18
Project: aws-codecommit-trigger-plugin   File: RepoInfo.java   View Source Code Vote up 5 votes
public boolean isNoUrlFound() {
    return CollectionUtils.isEmpty(this.nonCodeCommitUrls) && CollectionUtils.isEmpty(this.codeCommitUrls);
}
 
Example 19
Project: rufus   File: FeedUtils.java   View Source Code Vote up 5 votes
public static void mergeAuthors(SyndEntry entry) {
    if (CollectionUtils.isEmpty(entry.getAuthors())) {
        entry.setAuthors(Collections.singletonList(entry.getAuthor()));
    }
}
 
Example 20
Project: PoiExcelExport   File: ExcelExportService.java   View Source Code Vote up 5 votes
@Override
void setCellValues(Class<?> loadCls) {
	if (loadCls == null || !Class.class.isAssignableFrom(loadCls)) {
		if (LOG.isDebugEnabled()) {
			LOG.debug("loadCls must not be Class type!");
		}
	}
	ExcelEntity entity = loadCls.getAnnotation(ExcelEntity.class);
	if (entity == null) {
		if (LOG.isDebugEnabled()) {
			LOG.debug("[" + loadCls.getName() + "] must not be Class type!");
		}
		throw new AnnotationNotFoundException(loadCls,
				" is not a excel entity!");
	}
	//tangle year,quarter,or month columns
	tangleHeader(entity);
	//load attributes type definition
	List<CellDefinition> contentDefinitionList=_getEntityFields(loadCls);
	if(CollectionUtils.isEmpty(contentDefinitionList)){
		throw new IllegalTempClassException(loadCls,
				" is not a legal entity!");
	}
	this.COLUMN_NUMBER=contentDefinitionList.size();
	/****************** vertical direction draw  ********************/
	/*for(int _row=0;_row<this.ROWS;_row++){
		for(int i=0;i<COLUMN_NUMBER;i++){
			CellDefinition def=contentDefinitionList.get(i);
			int col=def.getCol();
			int[] rows=def.getRow();
			CellStyle style=def.getCellStyle();
			FontStyle font=def.getFontStyle();
			CellValueUtil.setCell(this.getWb(),super.getSheet(),new int[]{rows[_row],col},style,font,this.getCount(this.dataType, this.data.get(_row*COLUMN_NUMBER+i)));
		}
	}*/
	/****************** vertical direction draw  ********************/
	
	/****************** horizon direction draw  ********************/
	for(int i=0;i<COLUMN_NUMBER;i++){
		//inner loop specify one type per time
		CellDefinition def=contentDefinitionList.get(i);
		int col=def.getCol();
		int[] rows=def.getRow();
		CellStyle style=def.getCellStyle();
		FontStyle font=def.getFontStyle();
		for(int _row=0;_row<this.ROWS;_row++){
			CellValueUtil.setCell(this.getWb(),super.getSheet(),new int[]{rows[_row],col},style,font,this.getCount(this.dataType, this.data.get(i*ROWS+_row)));
		}
	}
	/****************** horizon direction draw  ********************/
	
}