Search in sources :

Example 1 with HubCategoryConfiguration

use of com.amplifyframework.hub.HubCategoryConfiguration in project amplify-android by aws-amplify.

the class AmplifyConfiguration method configsFromJson.

private static Map<String, CategoryConfiguration> configsFromJson(JSONObject json) throws AmplifyException {
    final List<CategoryConfiguration> possibleConfigs = Arrays.asList(new AnalyticsCategoryConfiguration(), new ApiCategoryConfiguration(), new AuthCategoryConfiguration(), new DataStoreCategoryConfiguration(), new GeoCategoryConfiguration(), new HubCategoryConfiguration(), new LoggingCategoryConfiguration(), new PredictionsCategoryConfiguration(), new StorageCategoryConfiguration());
    final Map<String, CategoryConfiguration> actualConfigs = new HashMap<>();
    try {
        for (CategoryConfiguration possibleConfig : possibleConfigs) {
            String categoryJsonKey = possibleConfig.getCategoryType().getConfigurationKey();
            if (json.has(categoryJsonKey)) {
                possibleConfig.populateFromJSON(json.getJSONObject(categoryJsonKey));
                actualConfigs.put(categoryJsonKey, possibleConfig);
            }
        }
    } catch (JSONException error) {
        throw new AmplifyException("Could not parse amplifyconfiguration.json ", error, "Check any modifications made to the file.");
    }
    return Immutable.of(actualConfigs);
}
Also used : DataStoreCategoryConfiguration(com.amplifyframework.datastore.DataStoreCategoryConfiguration) StorageCategoryConfiguration(com.amplifyframework.storage.StorageCategoryConfiguration) AmplifyException(com.amplifyframework.AmplifyException) PredictionsCategoryConfiguration(com.amplifyframework.predictions.PredictionsCategoryConfiguration) HashMap(java.util.HashMap) LinkedHashMap(java.util.LinkedHashMap) AuthCategoryConfiguration(com.amplifyframework.auth.AuthCategoryConfiguration) LoggingCategoryConfiguration(com.amplifyframework.logging.LoggingCategoryConfiguration) AnalyticsCategoryConfiguration(com.amplifyframework.analytics.AnalyticsCategoryConfiguration) AuthCategoryConfiguration(com.amplifyframework.auth.AuthCategoryConfiguration) CategoryConfiguration(com.amplifyframework.core.category.CategoryConfiguration) GeoCategoryConfiguration(com.amplifyframework.geo.GeoCategoryConfiguration) DataStoreCategoryConfiguration(com.amplifyframework.datastore.DataStoreCategoryConfiguration) HubCategoryConfiguration(com.amplifyframework.hub.HubCategoryConfiguration) PredictionsCategoryConfiguration(com.amplifyframework.predictions.PredictionsCategoryConfiguration) StorageCategoryConfiguration(com.amplifyframework.storage.StorageCategoryConfiguration) ApiCategoryConfiguration(com.amplifyframework.api.ApiCategoryConfiguration) EmptyCategoryConfiguration(com.amplifyframework.core.category.EmptyCategoryConfiguration) JSONException(org.json.JSONException) GeoCategoryConfiguration(com.amplifyframework.geo.GeoCategoryConfiguration) AnalyticsCategoryConfiguration(com.amplifyframework.analytics.AnalyticsCategoryConfiguration) ApiCategoryConfiguration(com.amplifyframework.api.ApiCategoryConfiguration) HubCategoryConfiguration(com.amplifyframework.hub.HubCategoryConfiguration) LoggingCategoryConfiguration(com.amplifyframework.logging.LoggingCategoryConfiguration)

Aggregations

AmplifyException (com.amplifyframework.AmplifyException)1 AnalyticsCategoryConfiguration (com.amplifyframework.analytics.AnalyticsCategoryConfiguration)1 ApiCategoryConfiguration (com.amplifyframework.api.ApiCategoryConfiguration)1 AuthCategoryConfiguration (com.amplifyframework.auth.AuthCategoryConfiguration)1 CategoryConfiguration (com.amplifyframework.core.category.CategoryConfiguration)1 EmptyCategoryConfiguration (com.amplifyframework.core.category.EmptyCategoryConfiguration)1 DataStoreCategoryConfiguration (com.amplifyframework.datastore.DataStoreCategoryConfiguration)1 GeoCategoryConfiguration (com.amplifyframework.geo.GeoCategoryConfiguration)1 HubCategoryConfiguration (com.amplifyframework.hub.HubCategoryConfiguration)1 LoggingCategoryConfiguration (com.amplifyframework.logging.LoggingCategoryConfiguration)1 PredictionsCategoryConfiguration (com.amplifyframework.predictions.PredictionsCategoryConfiguration)1 StorageCategoryConfiguration (com.amplifyframework.storage.StorageCategoryConfiguration)1 HashMap (java.util.HashMap)1 LinkedHashMap (java.util.LinkedHashMap)1 JSONException (org.json.JSONException)1