Plugin admin initial settings

Hi. I’ve developed a confluence plugin that has an admin config page. The plugin settings are blank upon installation but I want to initialize them upon installation. How can I do it?
Thanks

Hi @ShahramAtrian,

Maybe instead of trying to initialize them on install you should consider working with default values? Consider something like this in your settings service:

public String getSetting() {
    String value = someAtlassianStorageService.get("setting");
    
    if (value == null) {
        value = "your default value";
    }
    
    return value;
}

Cheers,
Sven

2 Likes

Thanks @sven.schatter. I’ll try it but I still want to know if it’s possible to save some default settings on confluence DB upon installation.

You can use SAL’s UpgradeTask ( https://docs.atlassian.com/DAC/javadoc/sal/2.6/reference/com/atlassian/sal/api/upgrade/PluginUpgradeTask.html ).

But note that the last time I looked at it - they were broken and you need to persist that you’ve done the upgrade or it will happen whenever your app is done.

Best way to handle it though is to do a lazy persistence (ie. set the default values when the they’re first retrieved and not really used).

2 Likes