i looked way store project-specific configurations plugin. in first step want store simple string "hello".
so, found sal , pluginsettings. https://developer.atlassian.com/docs/atlassian-platform-common-components/shared-access-layer/sal-services
this seems pretty easy use don´t have idea how implement code. used webwork taking place in project administration section:
@override public string dodefault() throws exception { project project = getprojectmanager().getprojectobjbykey(_projectkey); httpservletrequest request = executinghttprequest.get(); request.setattribute((new stringbuilder()).append("com.atlassian.jira.projectconfig.util.servletrequestprojectconfigrequestcache").append(":project").tostring(), project); return input; } @override protected string doexecute() throws exception { project project = getprojectmanager().getprojectobjbykey(_projectkey); httpservletrequest request = executinghttprequest.get(); request.setattribute((new stringbuilder()).append("com.atlassian.jira.projectconfig.util.servletrequestprojectconfigrequestcache").append(":project").tostring(), project); string param = request.getparameter("param"); return success; } public void setprojectkey(string projectkey) { _projectkey = projectkey; } public string getprojectkey() { return _projectkey; } public string getbaseurl() { return componentaccessor.getapplicationproperties().getstring(apkeys.jira_baseurl); }
as sal said implemented settings-class:
public customprojectsettings( final pluginsettingsfactory pluginsettingsfactory, final string projectkey) { this.pluginsettingsfactory = pluginsettingsfactory; this.projectkey = projectkey; } public void setvalue(final string key, final string value) { final pluginsettings settings = pluginsettingsfactory .createsettingsforkey(projectkey); settings.put(key, value); } public object getvalue(final string key) { final pluginsettings settings = pluginsettingsfactory .createsettingsforkey(projectkey); return settings.get(key); }
and added component in xml:
<component-import key="pluginsettingsfactory" interface="com.atlassian.sal.api.pluginsettings.pluginsettingsfactory" />
so how connect , implement webwork
protected string doexecute() throws exception{ [...] pluginsettings.setvalue("key", param); [...] }
it easier thought. had inject settings dependency webwork:
public webworkaction(customprojectsettings settings){ this.settings = settings }
the settings-class gets autowired by
<component-import key="pluginsettingsfactory" interface="com.atlassian.sal.api.pluginsettings.pluginsettingsfactory" />
and adding
<component key="settingscomponent" class="com.xxx.customprojectsettings"> </component>
Comments
Post a Comment