package io.cattle.platform.iaas.api.auth;

import io.cattle.platform.archaius.util.ArchaiusUtil;
import io.cattle.platform.core.model.Setting;
import io.cattle.platform.deferred.util.DeferredUtils;
import io.cattle.platform.object.ObjectManager;

import javax.inject.Inject;

public class SettingsUtils {

    @Inject
    ObjectManager objectManager;

    public void changeSetting(String name, Object value) {
        if (name == null) {
            return;
        }
        Setting setting = objectManager.findOne(Setting.class, "name", name);
        if (setting == null) {
            objectManager.create(Setting.class, "name", name, "value", value);
        } else {
            objectManager.setFields(setting, "value", value);
        }

        DeferredUtils.defer(new Runnable() {

            @Override
            public void run() {
                ArchaiusUtil.refresh();
            }
        });
    }
}

@@ -454,32 +454,97 @@
 turn;%0A        %7D%0A
+%0A        if (value == null) %7B%0A            value = %22%22;%0A        %7D%0A%0A
         Setting 
@@ -601,24 +601,25 @@
 me%22, name);%0A
+%0A
         if (

Check value is not null before creating setting.