package com.bitmovin.bitcodin.api.test;

import java.io.BufferedReader;
import java.io.FileNotFoundException;
import java.io.InputStream;
import java.io.InputStreamReader;

import com.bitmovin.bitcodin.api.output.FTPOutputConfig;
import com.bitmovin.bitcodin.api.output.S3OutputConfig;
import com.google.gson.Gson;
import com.google.gson.annotations.Expose;

public class Settings {
    
    @Expose
    public String apikey;
    @Expose
    public S3OutputConfig s3OutputEUWest;
    @Expose
    public FTPOutputConfig ftpOutput;

    static private Settings settings = null;
    static private String settingsfile  = "settings.json";
    
    static public Settings getInstance() throws FileNotFoundException
    {
        if (settings == null)
        {
            InputStream inputStream = Settings.class.getClassLoader().getResourceAsStream(Settings.settingsfile);
            
            if (inputStream == null)
                throw new FileNotFoundException("Cloud not find config file: " + Settings.settingsfile);

            BufferedReader  reader = new BufferedReader(new InputStreamReader(inputStream));
            Gson            gson   = new Gson();

            settings = gson.fromJson(reader, Settings.class);
        }
        
        return settings;
    }
}

@@ -376,21 +376,16 @@
 tings %7B%0A
-    %0A
     @Exp
@@ -380,32 +380,32 @@
 s %7B%0A    @Expose%0A
+
     public Strin
@@ -623,16 +623,85 @@
 .json%22;%0A
+    static private String localSettingsfile = %22local_settings.json%22;%0A
     %0A   
@@ -969,32 +969,217 @@
 Stream == null)%0A
+            %7B%0A                inputStream = Settings.class.getClassLoader().getResourceAsStream(Settings.localSettingsfile);%0A                %0A                if (inputStream == null)%0A  
                 
@@ -1226,16 +1226,20 @@
 ot find 
+any 
 config f
@@ -1270,16 +1270,30 @@
 gsfile);
+%0A            %7D
 %0A%0A      

Use local_settings.json when ci settings are not available