use of org.apache.commons.lang3.ArrayUtils.addAll in project fess by codelibs.
the class LdapUser method getPermissions.
@Override
public String[] getPermissions() {
if (permissions == null) {
final FessConfig fessConfig = ComponentUtil.getFessConfig();
final String baseDn = fessConfig.getLdapBaseDn();
final String accountFilter = fessConfig.getLdapAccountFilter();
final String groupFilter = fessConfig.getLdapGroupFilter();
if (StringUtil.isNotBlank(baseDn) && StringUtil.isNotBlank(accountFilter)) {
final LdapManager ldapManager = ComponentUtil.getLdapManager();
permissions = distinct(ArrayUtils.addAll(ldapManager.getRoles(this, baseDn, accountFilter, groupFilter, roles -> {
permissions = distinct(roles);
ComponentUtil.getActivityHelper().permissionChanged(OptionalThing.of(new FessUserBean(this)));
}), fessConfig.getRoleSearchUserPrefix() + ldapManager.normalizePermissionName(getName())));
} else {
permissions = StringUtil.EMPTY_STRINGS;
}
}
return permissions;
}
use of org.apache.commons.lang3.ArrayUtils.addAll in project hbase by apache.
the class AssignmentManagerUtil method createAssignProcedures.
/**
* Create assign procedures for the give regions, according to the {@code regionReplication}.
* <p/>
* For rolling back, we will submit procedures directly to the {@code ProcedureExecutor}, so it is
* possible that we persist the newly scheduled procedures, and then crash before persisting the
* rollback state, so when we arrive here the second time, it is possible that some regions have
* already been associated with a TRSP.
* @param ignoreIfInTransition if true, will skip creating TRSP for the given region if it is
* already in transition, otherwise we will add an assert that it should not in
* transition.
*/
private static TransitRegionStateProcedure[] createAssignProcedures(MasterProcedureEnv env, List<RegionInfo> regions, int regionReplication, ServerName targetServer, boolean ignoreIfInTransition) {
// create the assign procs only for the primary region using the targetServer
TransitRegionStateProcedure[] primaryRegionProcs = regions.stream().map(env.getAssignmentManager().getRegionStates()::getOrCreateRegionStateNode).map(regionNode -> {
TransitRegionStateProcedure proc = TransitRegionStateProcedure.assign(env, regionNode.getRegionInfo(), targetServer);
regionNode.lock();
try {
if (ignoreIfInTransition) {
if (regionNode.isInTransition()) {
return null;
}
} else {
// not process it either.
assert !regionNode.isInTransition();
}
regionNode.setProcedure(proc);
} finally {
regionNode.unlock();
}
return proc;
}).filter(p -> p != null).toArray(TransitRegionStateProcedure[]::new);
if (regionReplication == DEFAULT_REGION_REPLICA) {
// this is the default case
return primaryRegionProcs;
}
// collect the replica region infos
List<RegionInfo> replicaRegionInfos = new ArrayList<RegionInfo>(regions.size() * (regionReplication - 1));
for (RegionInfo hri : regions) {
// start the index from 1
for (int i = 1; i < regionReplication; i++) {
replicaRegionInfos.add(RegionReplicaUtil.getRegionInfoForReplica(hri, i));
}
}
// create round robin procs. Note that we exclude the primary region's target server
TransitRegionStateProcedure[] replicaRegionAssignProcs = env.getAssignmentManager().createRoundRobinAssignProcedures(replicaRegionInfos, Collections.singletonList(targetServer));
// combine both the procs and return the result
return ArrayUtils.addAll(primaryRegionProcs, replicaRegionAssignProcs);
}
Aggregations