Search in sources :

Example 11 with com.viaversion.viaversion.protocols.protocol1_9to1_8.storage

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();
    }
}
Also used : ResourceBackend(org.apache.airavata.mft.resource.server.backend.ResourceBackend) Logger(org.slf4j.Logger) org.apache.airavata.mft.resource.stubs.azure.storage(org.apache.airavata.mft.resource.stubs.azure.storage) JSONParser(org.json.simple.parser.JSONParser) org.apache.airavata.mft.resource.stubs.common(org.apache.airavata.mft.resource.stubs.common) org.apache.airavata.mft.resource.stubs.box.storage(org.apache.airavata.mft.resource.stubs.box.storage) org.apache.airavata.mft.resource.stubs.scp.storage(org.apache.airavata.mft.resource.stubs.scp.storage) org.apache.airavata.mft.resource.stubs.ftp.storage(org.apache.airavata.mft.resource.stubs.ftp.storage) LoggerFactory(org.slf4j.LoggerFactory) IOException(java.io.IOException) org.apache.airavata.mft.resource.stubs.gcs.storage(org.apache.airavata.mft.resource.stubs.gcs.storage) JSONArray(org.json.simple.JSONArray) InputStreamReader(java.io.InputStreamReader) Collectors(java.util.stream.Collectors) List(java.util.List) org.apache.airavata.mft.storage.stubs.storagesecret(org.apache.airavata.mft.storage.stubs.storagesecret) JSONObject(org.json.simple.JSONObject) org.apache.airavata.mft.resource.stubs.s3.storage(org.apache.airavata.mft.resource.stubs.s3.storage) org.apache.airavata.mft.resource.stubs.dropbox.storage(org.apache.airavata.mft.resource.stubs.dropbox.storage) org.apache.airavata.mft.resource.stubs.local.storage(org.apache.airavata.mft.resource.stubs.local.storage) Optional(java.util.Optional) InputStream(java.io.InputStream) InputStreamReader(java.io.InputStreamReader) JSONObject(org.json.simple.JSONObject) InputStream(java.io.InputStream) JSONArray(org.json.simple.JSONArray) JSONParser(org.json.simple.parser.JSONParser) JSONObject(org.json.simple.JSONObject) List(java.util.List)

Example 12 with com.viaversion.viaversion.protocols.protocol1_9to1_8.storage

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();
    }
}
Also used : ResourceBackend(org.apache.airavata.mft.resource.server.backend.ResourceBackend) Logger(org.slf4j.Logger) org.apache.airavata.mft.resource.stubs.azure.storage(org.apache.airavata.mft.resource.stubs.azure.storage) JSONParser(org.json.simple.parser.JSONParser) org.apache.airavata.mft.resource.stubs.common(org.apache.airavata.mft.resource.stubs.common) org.apache.airavata.mft.resource.stubs.box.storage(org.apache.airavata.mft.resource.stubs.box.storage) org.apache.airavata.mft.resource.stubs.scp.storage(org.apache.airavata.mft.resource.stubs.scp.storage) org.apache.airavata.mft.resource.stubs.ftp.storage(org.apache.airavata.mft.resource.stubs.ftp.storage) LoggerFactory(org.slf4j.LoggerFactory) IOException(java.io.IOException) org.apache.airavata.mft.resource.stubs.gcs.storage(org.apache.airavata.mft.resource.stubs.gcs.storage) JSONArray(org.json.simple.JSONArray) InputStreamReader(java.io.InputStreamReader) Collectors(java.util.stream.Collectors) List(java.util.List) org.apache.airavata.mft.storage.stubs.storagesecret(org.apache.airavata.mft.storage.stubs.storagesecret) JSONObject(org.json.simple.JSONObject) org.apache.airavata.mft.resource.stubs.s3.storage(org.apache.airavata.mft.resource.stubs.s3.storage) org.apache.airavata.mft.resource.stubs.dropbox.storage(org.apache.airavata.mft.resource.stubs.dropbox.storage) org.apache.airavata.mft.resource.stubs.local.storage(org.apache.airavata.mft.resource.stubs.local.storage) Optional(java.util.Optional) InputStream(java.io.InputStream) InputStreamReader(java.io.InputStreamReader) JSONObject(org.json.simple.JSONObject) InputStream(java.io.InputStream) JSONArray(org.json.simple.JSONArray) JSONParser(org.json.simple.parser.JSONParser) JSONObject(org.json.simple.JSONObject) List(java.util.List)

Aggregations

Optional (java.util.Optional)9 ResourceBackend (org.apache.airavata.mft.resource.server.backend.ResourceBackend)9 org.apache.airavata.mft.resource.stubs.azure.storage (org.apache.airavata.mft.resource.stubs.azure.storage)9 org.apache.airavata.mft.resource.stubs.box.storage (org.apache.airavata.mft.resource.stubs.box.storage)9 org.apache.airavata.mft.resource.stubs.common (org.apache.airavata.mft.resource.stubs.common)9 org.apache.airavata.mft.resource.stubs.dropbox.storage (org.apache.airavata.mft.resource.stubs.dropbox.storage)9 org.apache.airavata.mft.resource.stubs.ftp.storage (org.apache.airavata.mft.resource.stubs.ftp.storage)9 org.apache.airavata.mft.resource.stubs.gcs.storage (org.apache.airavata.mft.resource.stubs.gcs.storage)9 org.apache.airavata.mft.resource.stubs.local.storage (org.apache.airavata.mft.resource.stubs.local.storage)9 org.apache.airavata.mft.resource.stubs.s3.storage (org.apache.airavata.mft.resource.stubs.s3.storage)9 org.apache.airavata.mft.resource.stubs.scp.storage (org.apache.airavata.mft.resource.stubs.scp.storage)9 org.apache.airavata.mft.storage.stubs.storagesecret (org.apache.airavata.mft.storage.stubs.storagesecret)9 Logger (org.slf4j.Logger)9 LoggerFactory (org.slf4j.LoggerFactory)9 IOException (java.io.IOException)8 InputStream (java.io.InputStream)8 InputStreamReader (java.io.InputStreamReader)8 List (java.util.List)8 Collectors (java.util.stream.Collectors)8 JSONArray (org.json.simple.JSONArray)8