use of com.viaversion.viaversion.protocols.protocol1_9to1_8.storage in project airavata-mft by apache.
the class FileBasedResourceBackend method getS3Storage.
@Override
public Optional<S3Storage> getS3Storage(S3StorageGetRequest request) throws Exception {
JSONParser jsonParser = new JSONParser();
InputStream inputStream = FileBasedResourceBackend.class.getClassLoader().getResourceAsStream(storageFile);
try (InputStreamReader reader = new InputStreamReader(inputStream)) {
Object obj = jsonParser.parse(reader);
JSONArray storagesList = (JSONArray) obj;
List<S3Storage> s3Storages = (List<S3Storage>) storagesList.stream().filter(storage -> "S3".equals(((JSONObject) storage).get("type").toString())).map(storage -> {
JSONObject s = (JSONObject) storage;
S3Storage st = S3Storage.newBuilder().setStorageId(s.get("storageId").toString()).setRegion(s.get("region").toString()).setRegion(s.get("bucketName").toString()).build();
return st;
}).collect(Collectors.toList());
return s3Storages.stream().filter(s -> request.getStorageId().equals(s.getStorageId())).findFirst();
}
}
use of com.viaversion.viaversion.protocols.protocol1_9to1_8.storage in project airavata-mft by apache.
the class FileBasedResourceBackend method getAzureStorage.
@Override
public Optional<AzureStorage> getAzureStorage(AzureStorageGetRequest request) throws Exception {
JSONParser jsonParser = new JSONParser();
InputStream inputStream = FileBasedResourceBackend.class.getClassLoader().getResourceAsStream(storageFile);
try (InputStreamReader reader = new InputStreamReader(inputStream)) {
Object obj = jsonParser.parse(reader);
JSONArray storageList = (JSONArray) obj;
List<AzureStorage> azureStorages = (List<AzureStorage>) storageList.stream().filter(storage -> "AZURE".equals(((JSONObject) storage).get("type").toString())).map(storage -> {
JSONObject s = (JSONObject) storage;
AzureStorage st = AzureStorage.newBuilder().setStorageId(s.get("storageId").toString()).setContainer(s.get("container").toString()).build();
return st;
}).collect(Collectors.toList());
return azureStorages.stream().filter(s -> request.getStorageId().equals(s.getStorageId())).findFirst();
}
}
Aggregations