Takes some amount of range resources (e.g. ports).

@param amount the number of values to take from the available range(s).
@param roles the roles to accept
559253
public List<Protos.Resource> takeRanges(String resourceName, int amount, Set<String> roles) {
		if (LOG.isDebugEnabled()) {
			LOG.debug("Allocating {} {}", amount, resourceName);
		}

		List<Protos.Resource> result = new ArrayList<>(1);
		for (ListIterator<Protos.Resource> i = resources.listIterator(); i.hasNext();) {
			if (amount <= 0) {
				break;
			}

			// take from next available range resource that is unreserved or reserved for an applicable role
			Protos.Resource available = i.next();
			if (!resourceName.equals(available.getName()) || !available.hasRanges()) {
				continue;
			}
			if (!UNRESERVED_ROLE.equals(available.getRole()) && !roles.contains(available.getRole())) {
				continue;
			}

			List<Protos.Value.Range> takenRanges = new ArrayList<>();
			List<Protos.Value.Range> remainingRanges = new ArrayList<>(available.getRanges().getRangeList());
			for (ListIterator<Protos.Value.Range> j = remainingRanges.listIterator(); j.hasNext();) {
				if (amount <= 0) {
					break;
				}

				// take from next available range (note: ranges are inclusive)
				Protos.Value.Range availableRange = j.next();
				long amountToTake = Math.min(availableRange.getEnd() - availableRange.getBegin() + 1, amount);
				Protos.Value.Range takenRange = availableRange.toBuilder().setEnd(availableRange.getBegin() + amountToTake - 1).build();
				amount -= amountToTake;
				takenRanges.add(takenRange);

				// keep remaining range (if any)
				long remaining = availableRange.getEnd() - takenRange.getEnd();
				if (remaining > 0) {
					j.set(availableRange.toBuilder().setBegin(takenRange.getEnd() + 1).build());
				}
				else {
					j.remove();
				}
			}
			Protos.Resource taken = available.toBuilder().setRanges(Protos.Value.Ranges.newBuilder().addAllRange(takenRanges)).build();
			if (LOG.isDebugEnabled()) {
				LOG.debug("Taking {} from {}", Utils.toString(taken.getRanges()), Utils.toString(available));
			}
			result.add(taken);

			// keep remaining ranges (if any)
			if (remainingRanges.size() > 0) {
				i.set(available.toBuilder().setRanges(Protos.Value.Ranges.newBuilder().addAllRange(remainingRanges)).build());
			}
			else {
				i.remove();
			}
		}

		if (LOG.isDebugEnabled()) {
			LOG.debug("Allocated: {}, unsatisfied: {}", Utils.toString(result), amount);
		}
		return result;
	}
1192329
public void setLimits(java.util.Collection<Limit> limits) {
        if (limits == null) {
            this.limits = null;
            return;
        }

        this.limits = new com.amazonaws.internal.SdkInternalList<Limit>(limits);
    }
338696
public function initializePermissions(array $nodes, array $roles)
    {
        $this->om->startFlushSuite();

        foreach ($nodes as $node) {
            foreach ($roles as $role) {
                $type = $node->getResourceType();
                $this->editPerms(
                    $type->getDefaultMask(),
                    $role,
                    $node,
                    false
                );
            }
        }

        $this->om->endFlushSuite();
    }
951215
public void setPolicyRoles(java.util.Collection<PolicyRole> policyRoles) {
        if (policyRoles == null) {
            this.policyRoles = null;
            return;
        }

        this.policyRoles = new com.amazonaws.internal.SdkInternalList<PolicyRole>(policyRoles);
    }
302349
public void setItems(java.util.Collection<UsagePlanKey> items) {
        if (items == null) {
            this.items = null;
            return;
        }

        this.items = new java.util.ArrayList<UsagePlanKey>(items);
    }
808701
private List<String> getUsersFor(Collection<String> roles){
		List<String> users = new HashList<>();
		for(String role: roles){
			if(roleMembershipRU.containsKey(role))
				users.addAll(roleMembershipRU.get(role));
		}
		return users;
	}
929813
public void setResourceRequirements(java.util.Collection<ResourceRequirement> resourceRequirements) {
        if (resourceRequirements == null) {
            this.resourceRequirements = null;
            return;
        }

        this.resourceRequirements = new com.amazonaws.internal.SdkInternalList<ResourceRequirement>(resourceRequirements);
    }
698504
public void assignRole(XEvent event, String role) {
		if (role != null && role.trim().length() > 0) {
			XAttributeLiteral attr = (XAttributeLiteral) ATTR_ROLE.clone();
			attr.setValue(role.trim());
			event.getAttributes().put(KEY_ROLE, attr);
		}
	}
905584
public void addRole(Role role) {
        apiRoles.add(role);
        roles.add(role.getName());
        for (org.seedstack.seed.security.Permission permission : role.getPermissions()) {
            if (!role.getScopes().isEmpty()) {
                for (Scope scope : role.getScopes()) {
                    ScopePermission sp = new ScopePermission(permission.getPermission(), scope);
                    scopePermissions.add(sp);
                }
            } else {
                stringPermissions.add(permission.getPermission());
            }
        }
    }
858722
@POST
  @Path("/db/{authorizerName}/roles/{roleName}/permissions")
  @Produces(MediaType.APPLICATION_JSON)
  @Consumes(MediaType.APPLICATION_JSON)
  @ResourceFilters(BasicSecurityResourceFilter.class)
  public Response setRolePermissions(
      @Context HttpServletRequest req,
      @PathParam("authorizerName") final String authorizerName,
      @PathParam("roleName") String roleName,
      List<ResourceAction> permissions
  )
  {
    return resourceHandler.setRolePermissions(authorizerName, roleName, permissions);
  }
974648
public void setPartitions(java.util.Collection<Partition> partitions) {
        if (partitions == null) {
            this.partitions = null;
            return;
        }

        this.partitions = new java.util.ArrayList<Partition>(partitions);
    }
1139957
public Authorizations setRoles(Set<Role> roles) {
        this.roles.clear();
        this.aggregatePermissions = null;
        addRoles(roles);

        return this;
    }
391650
protected void ensureAvailableBytes(int amount) throws IOException {
		if (!this.seekEnabled && amount > this.buffer.remaining()) {
			this.bufferPosition += this.buffer.position();
			this.buffer.compact();
			int limit = this.buffer.position();
			final int read = this.stream.read(this.buffer);
			if (read < 0) {
				if (limit == 0) {
					throw new EOFException();
				}
			} else {
				limit += read;
			}
			this.buffer.rewind();
			this.buffer.limit(limit);

		}
		if (amount > this.buffer.remaining()) {
			throw new EOFException();
		}
	}
346128
public void setPorts(java.util.Collection<InstancePortInfo> ports) {
        if (ports == null) {
            this.ports = null;
            return;
        }

        this.ports = new java.util.ArrayList<InstancePortInfo>(ports);
    }
348406
public void setAccountLimits(java.util.Collection<AccountLimit> accountLimits) {
        if (accountLimits == null) {
            this.accountLimits = null;
            return;
        }

        this.accountLimits = new com.amazonaws.internal.SdkInternalList<AccountLimit>(accountLimits);
    }
1173599
public void setJobs(java.util.Collection<ThirdPartyJob> jobs) {
        if (jobs == null) {
            this.jobs = null;
            return;
        }

        this.jobs = new java.util.ArrayList<ThirdPartyJob>(jobs);
    }
254155
public void setItems(java.util.Collection<UsagePlan> items) {
        if (items == null) {
            this.items = null;
            return;
        }

        this.items = new java.util.ArrayList<UsagePlan>(items);
    }