Convert roles yml string to map.

@param yml string
@return roles map
439321
public Map<String, Role> ymlToRoles(String yml) {
        try {
            Map<String, Role> map = mapper
                .readValue(yml, new TypeReference<TreeMap<String, Role>>() {
                });
            map.forEach((roleKey, role) -> role.setKey(roleKey));
            return map;
        } catch (Exception e) {
            log.error("Failed to create roles collection from YML file, error: {}", e.getMessage(), e);
        }
        return Collections.emptyMap();
    }
818532
protected Map<String, String> getElementAttributes() {
        // Preserve order of attributes
        Map<String, String> attrs = new HashMap<>();

        if (this.getRole() != null) {
            attrs.put("role", this.getRole());
        }

        return attrs;
    }
26757
@SuppressWarnings("static-method")
	protected String generateYaml(Map<String, Object> map) throws JsonProcessingException {
		final YAMLFactory yamlFactory = new YAMLFactory();
		yamlFactory.configure(Feature.WRITE_DOC_START_MARKER, false);
		final ObjectMapper mapper = new ObjectMapper(yamlFactory);
		return mapper.writerWithDefaultPrettyPrinter().writeValueAsString(map);
	}
1114749
protected String serializeFromMap(@Nullable String user, long start, long duration, @Nullable List<String> roles, Map<String, Object> nameAndValMap) {
		return serializeFromMap(user, start, duration, toArr(roles), nameAndValMap);
	}
44332
public Map<String, String> toStringMap() {
    Map<String, String> map = new HashMap<>();
    for (Map.Entry<String, Object> entry : entrySet()) {
      map.put(entry.getKey(), String.valueOf(entry.getValue()));
    }
    return map;
  }
151279
public void map(final Group group, final Role role)
    {
        this.getRoleMappings().add(new RoleMapping(group, role));
    }
1278650
public void map(final Group group, final Role role)
    {
        try
        {
            this.addRoleMapping(new RoleMapping(group, role));
        }
        catch(final RepositoryException e)
        {
            throw new RuntimeException("Found unexpected exception while adding role mapping", e);
        }
    }
1208928
public static Map<String, Object> getYamlObjectValue(Map<String, Object> yamlObject,
            String key, boolean allowsEmpty) throws YamlConvertException {
        Object obj = getObjectValue(yamlObject, key, allowsEmpty);
        @SuppressWarnings("unchecked")
        Map<String, Object> result = (Map<String, Object>) obj;
        return result;
    }
1078139
public function role_mappings($rolemappings, $roles) {
        $roles[0] = get_string('none');
        $output  = html_writer::start_tag('div', array('class' => 'restore-rolemappings'));
        $output .= $this->output->heading(get_string('restorerolemappings', 'backup'), 2);
        foreach ($rolemappings as $id => $mapping) {
            $label = $mapping->name;
            $name = 'mapping'.$id;
            $selected = $mapping->targetroleid;
            $output .= $this->backup_detail_select($label, $name, $roles, $mapping->targetroleid, false, array(), $mapping->description);
        }
        $output .= html_writer::end_tag('div');
        return $output;
    }
1368582
def roles_dict(path, repo_prefix="", repo_sub_dir=""):
    
    exit_if_path_not_found(path)

    aggregated_roles = {}

    roles = os.walk(path).next()[1]

    # First scan all directories
    for role in roles:
        for sub_role in roles_dict(path + "/" + role, repo_prefix="",
                                   repo_sub_dir=role + "/"):
            aggregated_roles[role + "/" + sub_role] = role + "/" + sub_role

    # Then format them
    for role in roles:
        if is_role(os.path.join(path, role)):
            if isinstance(role, basestring):
                role_repo = "{0}{1}".format(repo_prefix, role_name(role))

                aggregated_roles[role] = role_repo

    return aggregated_roles
8868
@GetMapping(value = "/swagger.yml", produces = "text/yaml")
  public String swagger(Model model, HttpServletResponse response) {
    response.setContentType("text/yaml");
    response.setCharacterEncoding("UTF-8");
    final UriComponents uriComponents =
        ServletUriComponentsBuilder.fromCurrentContextPath().build();
    model.addAttribute("scheme", uriComponents.getScheme());
    String host = uriComponents.getHost();
    if (uriComponents.getPort() >= 0) {
      host += ":" + uriComponents.getPort();
    }
    model.addAttribute("host", host);
    model.addAttribute(
        "entityTypes",
        metaDataService
            .getEntityTypes()
            .filter(e -> !e.isAbstract())
            .map(EntityType::getId)
            .sorted()
            .collect(toList()));
    model.addAttribute("attributeTypes", AttributeType.getOptionsLowercase());
    model.addAttribute("languageCodes", getLanguageCodes().collect(toList()));
    return "view-swagger";
  }
756428
public function loadYmlData($yml)
    {
        $searchEngines = \Spyc::YAMLLoadString($yml);

        $this->definitionList = $this->transformData($searchEngines);

        return $this->definitionList;
    }
1198678
public static ComputationGraphSpace fromYaml(String yaml) {
        try {
            return YamlMapper.getMapper().readValue(yaml, ComputationGraphSpace.class);
        } catch (IOException e) {
            throw new RuntimeException(e);
        }
    }
411620
public Stream<Casting> castingsRelation(Role... roles) {
        Set<Role> roleSet = new HashSet<>(Arrays.asList(roles));
        if (roleSet.isEmpty()) {
            return vertex().getEdgesOfType(Direction.OUT, Schema.EdgeLabel.ROLE_PLAYER).
                    map(edge -> Casting.withRelation(edge, owner));
        }

        //Traversal is used so we can potentially optimise on the index
        Set<Integer> roleTypesIds = roleSet.stream().map(r -> r.labelId().getValue()).collect(Collectors.toSet());
        return vertex().tx().getTinkerTraversal().V().
                hasId(elementId()).
                outE(Schema.EdgeLabel.ROLE_PLAYER.getLabel()).
                has(Schema.EdgeProperty.RELATION_TYPE_LABEL_ID.name(), type().labelId().getValue()).
                has(Schema.EdgeProperty.ROLE_LABEL_ID.name(), P.within(roleTypesIds)).
                toStream().
                map(edge -> vertex().tx().factory().buildEdgeElement(edge)).
                map(edge -> Casting.withRelation(edge, owner));
    }
744040
private static Map<String, Object> convert(
        final Map<CharSequence, Object> params) {
        final Map<String, Object> map = new HashMap<>(params.size());
        for (final Map.Entry<CharSequence, Object> ent : params.entrySet()) {
            map.put(ent.getKey().toString(), ent.getValue());
        }
        return map;
    }
46795
protected Map<String, Role> parseDefinedRoles(Config config) {
        // Parse the defined Roles
        Map<String, Role> roleMap = new HashMap<>();
        if (!config.hasPath("roles")) {
            log.trace("'{}' has no roles", config);
        } else if (config.hasPath("roles")) {
            log.trace("Parsing Role definitions");
            Config roleConfig = config.getConfig("roles");
            for (Map.Entry<String, ConfigValue> entry : roleConfig.entrySet()) {
                String name = entry.getKey();
                List<String> permissions = roleConfig.getStringList(name);
                Role role = new Role(name, permissions.toArray(new String[permissions.size()]));
                roleMap.put(role.getName(), role);
            }
        }

        return Collections.unmodifiableMap(roleMap);
    }
777129
protected Apikey createFromMap(@Nullable String user, long start, long duration, @Nullable List<String> roles, Map<String, Object> nameAndValMap) {
		return createFromMap(user, start, duration, toArr(roles), nameAndValMap);
	}