Search in sources :

Example 1 with AzureSdkAllowListEntity

use of com.microsoft.azure.toolkit.intellij.azuresdk.model.AzureSdkAllowListEntity in project azure-tools-for-java by Microsoft.

the class AzureSdkLibraryService method loadAzureSDKWhitelist.

@Cacheable("sdk/packages/whitelist")
@AzureOperation(name = "sdk.load_meta_data.whitelist", type = AzureOperation.Type.TASK)
private static Set<String> loadAzureSDKWhitelist() {
    try {
        final URL destination = AzureSdkLibraryService.class.getResource(SDK_ALLOW_LIST_CSV);
        final ObjectReader reader = CSV_MAPPER.readerFor(AzureSdkAllowListEntity.class).with(CsvSchema.emptySchema().withHeader());
        final MappingIterator<AzureSdkAllowListEntity> data = reader.readValues(destination);
        return data.readAll().stream().filter(e -> StringUtils.isNoneBlank(e.getArtifactId(), e.getGroupId())).map(AzureSdkAllowListEntity::getPackageName).collect(Collectors.toSet());
    } catch (final IOException e) {
        log.warn(String.format("failed to load Azure SDK allow list from \"%s\"", SDK_ALLOW_LIST_CSV), e);
    }
    return Collections.emptySet();
}
Also used : ObjectReader(com.fasterxml.jackson.databind.ObjectReader) IOException(java.io.IOException) AzureSdkAllowListEntity(com.microsoft.azure.toolkit.intellij.azuresdk.model.AzureSdkAllowListEntity) URL(java.net.URL) Cacheable(com.microsoft.azure.toolkit.lib.common.cache.Cacheable) AzureOperation(com.microsoft.azure.toolkit.lib.common.operation.AzureOperation)

Aggregations

ObjectReader (com.fasterxml.jackson.databind.ObjectReader)1 AzureSdkAllowListEntity (com.microsoft.azure.toolkit.intellij.azuresdk.model.AzureSdkAllowListEntity)1 Cacheable (com.microsoft.azure.toolkit.lib.common.cache.Cacheable)1 AzureOperation (com.microsoft.azure.toolkit.lib.common.operation.AzureOperation)1 IOException (java.io.IOException)1 URL (java.net.URL)1