Search in sources :

Example 1 with OrchidUtils

use of com.eden.orchid.utilities.OrchidUtils in project Orchid by JavaEden.

the class SetupEnvironment method parseConfigFile.

// config file
private void parseConfigFile(JSONObject options) {
    String resPath = "" + options.optString("resourcesDir");
    String env = "" + options.optString("environment");
    JSONObject configFile = Arrays.stream(dataExtensions).map(ext -> Arrays.stream(formats).map(format -> parseFile(new File(resPath + "/" + Clog.format(format, env, ext)))).filter(OrchidUtils::elementIsObject).map(el -> (JSONObject) el.getElement()).findFirst().orElseGet(() -> null)).findFirst().orElseGet(() -> new JSONObject());
    if (configFile.length() > 0) {
        for (String key : configFile.keySet()) {
            options.put(key, configFile.get(key));
        }
    }
    options.put("config", configFile);
}
Also used : On(com.eden.orchid.api.events.On) Arrays(java.util.Arrays) FileUtils(org.apache.commons.io.FileUtils) FileInputStream(java.io.FileInputStream) OrchidContext(com.eden.orchid.api.OrchidContext) File(java.io.File) ArrayList(java.util.ArrayList) Inject(javax.inject.Inject) IOUtils(org.apache.commons.io.IOUtils) EventListener(java.util.EventListener) JSONObject(org.json.JSONObject) Orchid(com.eden.orchid.Orchid) OrchidUtils(com.eden.orchid.utilities.OrchidUtils) Clog(com.caseyjbrooks.clog.Clog) JSONElement(com.eden.common.json.JSONElement) FilenameUtils(org.apache.commons.io.FilenameUtils) OrchidUtils(com.eden.orchid.utilities.OrchidUtils) JSONObject(org.json.JSONObject) File(java.io.File)

Aggregations

Clog (com.caseyjbrooks.clog.Clog)1 JSONElement (com.eden.common.json.JSONElement)1 Orchid (com.eden.orchid.Orchid)1 OrchidContext (com.eden.orchid.api.OrchidContext)1 On (com.eden.orchid.api.events.On)1 OrchidUtils (com.eden.orchid.utilities.OrchidUtils)1 File (java.io.File)1 FileInputStream (java.io.FileInputStream)1 ArrayList (java.util.ArrayList)1 Arrays (java.util.Arrays)1 EventListener (java.util.EventListener)1 Inject (javax.inject.Inject)1 FileUtils (org.apache.commons.io.FileUtils)1 FilenameUtils (org.apache.commons.io.FilenameUtils)1 IOUtils (org.apache.commons.io.IOUtils)1 JSONObject (org.json.JSONObject)1