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 ( PluginUpgradeTask | Shared Access Layer POM ).

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