use of org.wso2.carbon.apimgt.rest.api.publisher.v1.dto.APIScopeDTO in project carbon-apimgt by wso2.
the class APIMappingUtil method getAPIScopesFromScopeDTOs.
/**
* Convert ScopeDTO List to APIScopesDTO List adding the attribute 'isShared'.
*
* @param scopeDTOS ScopeDTO List
* @return APIScopeDTO List
* @throws APIManagementException if an error occurs while converting ScopeDTOs to APIScopeDTOs
*/
private static List<APIScopeDTO> getAPIScopesFromScopeDTOs(List<ScopeDTO> scopeDTOS) throws APIManagementException {
List<APIScopeDTO> apiScopeDTOS = new ArrayList<>();
APIProvider apiProvider = RestApiCommonUtil.getLoggedInUserProvider();
String tenantDomain = RestApiCommonUtil.getLoggedInUserTenantDomain();
Set<String> allSharedScopeKeys = apiProvider.getAllSharedScopeKeys(tenantDomain);
scopeDTOS.forEach(scopeDTO -> {
APIScopeDTO apiScopeDTO = new APIScopeDTO();
apiScopeDTO.setScope(scopeDTO);
apiScopeDTO.setShared(allSharedScopeKeys.contains(scopeDTO.getName()) ? Boolean.TRUE : Boolean.FALSE);
apiScopeDTOS.add(apiScopeDTO);
});
return apiScopeDTOS;
}
use of org.wso2.carbon.apimgt.rest.api.publisher.v1.dto.APIScopeDTO in project carbon-apimgt by wso2.
the class APIMappingUtil method getAPIScopesFromScopeDTOs.
/**
* Convert ScopeDTO List to APIScopesDTO List adding the attribute 'isShared'.
*
* @param scopeDTOS ScopeDTO List
* @return APIScopeDTO List
* @throws APIManagementException if an error occurs while converting ScopeDTOs to APIScopeDTOs
*/
private static List<APIScopeDTO> getAPIScopesFromScopeDTOs(List<ScopeDTO> scopeDTOS, APIProvider apiProvider) throws APIManagementException {
List<APIScopeDTO> apiScopeDTOS = new ArrayList<>();
String tenantDomain = RestApiCommonUtil.getLoggedInUserTenantDomain();
Set<String> allSharedScopeKeys = apiProvider.getAllSharedScopeKeys(tenantDomain);
scopeDTOS.forEach(scopeDTO -> {
APIScopeDTO apiScopeDTO = new APIScopeDTO();
apiScopeDTO.setScope(scopeDTO);
apiScopeDTO.setShared(allSharedScopeKeys.contains(scopeDTO.getName()) ? Boolean.TRUE : Boolean.FALSE);
apiScopeDTOS.add(apiScopeDTO);
});
return apiScopeDTOS;
}
use of org.wso2.carbon.apimgt.rest.api.publisher.v1.dto.APIScopeDTO in project carbon-apimgt by wso2.
the class APIMappingUtil method getScopes.
/**
* This method returns the oauth scopes according to the given list of scopes.
*
* @param apiDTO list of APIScopes
* @return scope set
*/
public static Set<Scope> getScopes(APIDTO apiDTO) {
Set<Scope> scopeSet = new LinkedHashSet<>();
for (APIScopeDTO apiScopeDTO : apiDTO.getScopes()) {
Scope scope = new Scope();
ScopeDTO scopeDTO = apiScopeDTO.getScope();
scope.setKey(scopeDTO.getName());
scope.setName(scopeDTO.getDisplayName());
scope.setDescription(scopeDTO.getDescription());
scope.setRoles(String.join(",", scopeDTO.getBindings()));
scopeSet.add(scope);
}
return scopeSet;
}
use of org.wso2.carbon.apimgt.rest.api.publisher.v1.dto.APIScopeDTO in project carbon-apimgt by wso2.
the class APIMappingUtil method getScopes.
/**
* This method returns the oauth scopes according to the given list of scopes.
*
* @param apiProductDTO list of scopes
* @return scope set
*/
private static Set<Scope> getScopes(APIProductDTO apiProductDTO) {
Set<Scope> scopeSet = new LinkedHashSet<>();
for (APIScopeDTO apiScopeDTO : apiProductDTO.getScopes()) {
Scope scope = new Scope();
ScopeDTO scopeDTO = apiScopeDTO.getScope();
scope.setKey(scopeDTO.getName());
scope.setName(scopeDTO.getDisplayName());
scope.setDescription(scopeDTO.getDescription());
scope.setRoles(String.join(",", scopeDTO.getBindings()));
scopeSet.add(scope);
}
return scopeSet;
}
Aggregations