use of com.nightscout.core.upload.MongoUploader in project android-uploader by nightscout.
the class Uploader method initializeMongoUploader.
private boolean initializeMongoUploader(Context context, NightscoutPreferences preferences) {
String dbURI = preferences.getMongoClientUri();
String collectionName = preferences.getMongoCollection();
String dsCollectionName = preferences.getMongoDeviceStatusCollection();
checkNotNull(collectionName);
checkNotNull(dsCollectionName);
MongoClientURI uri;
try {
uri = new MongoClientURI(dbURI);
} catch (IllegalArgumentException e) {
Log.e(LOG_TAG, "Error creating mongo client uri for " + dbURI + ".", e);
context.sendBroadcast(ToastReceiver.createIntent(context, R.string.unknown_mongo_host));
return false;
} catch (NullPointerException e) {
Log.e(LOG_TAG, "Error creating mongo client uri for null value.", e);
context.sendBroadcast(ToastReceiver.createIntent(context, R.string.unknown_mongo_host));
return false;
}
uploaders.add(new MongoUploader(preferences, uri, collectionName, dsCollectionName));
return true;
}
Aggregations