Search in sources :

Example 1 with RoleAliasDTO

use of org.wso2.carbon.apimgt.rest.api.admin.v1.dto.RoleAliasDTO in project carbon-apimgt by wso2.

the class SystemScopesMappingUtil method fromRoleAliasObjectToRoleAliasDTOList.

/**
 * Converts api scope-role mapping to RoleScopeDTO List.
 *
 * @param roleMapping Map of a Role Scope  Mapping
 * @return RoleScopeDTO list
 */
private static List<RoleAliasDTO> fromRoleAliasObjectToRoleAliasDTOList(Map<String, List<String>> roleMapping) {
    List<RoleAliasDTO> roleAliasDTOS = new ArrayList<>(roleMapping.size());
    for (Map.Entry<String, List<String>> mapping : roleMapping.entrySet()) {
        RoleAliasDTO roleAliasDTO = new RoleAliasDTO();
        roleAliasDTO.setRole(mapping.getKey());
        roleAliasDTO.setAliases(mapping.getValue());
        roleAliasDTOS.add(roleAliasDTO);
    }
    return roleAliasDTOS;
}
Also used : RoleAliasDTO(org.wso2.carbon.apimgt.rest.api.admin.v1.dto.RoleAliasDTO) ArrayList(java.util.ArrayList) ArrayList(java.util.ArrayList) List(java.util.List) HashMap(java.util.HashMap) Map(java.util.Map)

Example 2 with RoleAliasDTO

use of org.wso2.carbon.apimgt.rest.api.admin.v1.dto.RoleAliasDTO in project carbon-apimgt by wso2.

the class SystemScopesMappingUtil method createJsonObjectOfRoleMapping.

/**
 * Extract roles and aliases and create JSONObject
 *
 * @param body          RoleAliasListDTO as request body
 * @return JSONObject   role-alias data
 */
public static JSONObject createJsonObjectOfRoleMapping(RoleAliasListDTO body) {
    JSONObject roleJson = new JSONObject();
    for (RoleAliasDTO roleAlias : body.getList()) {
        String aliases = roleAlias.getAliases().toString().replaceAll("\\[", "").replaceAll("\\]", "");
        roleJson.put(roleAlias.getRole(), aliases);
    }
    return roleJson;
}
Also used : JSONObject(org.json.simple.JSONObject) RoleAliasDTO(org.wso2.carbon.apimgt.rest.api.admin.v1.dto.RoleAliasDTO)

Aggregations

RoleAliasDTO (org.wso2.carbon.apimgt.rest.api.admin.v1.dto.RoleAliasDTO)2 ArrayList (java.util.ArrayList)1 HashMap (java.util.HashMap)1 List (java.util.List)1 Map (java.util.Map)1 JSONObject (org.json.simple.JSONObject)1