Create
cancel
Showing results for 
Search instead for 
Did you mean: 
Sign up Log in

What is the best way to store and access plugin data?

imamudin naseem March 29, 2018

I have been exploring Jira plugin development for a while.

I have a scenario where I need to store user-specific data in the backend. Consider it a set of some Input fields(On right panel of view issue page), which asks some info from user and later displays it when user had saved it. I don't want to enclose input fields in <form></form> tag. I want to handle things via calling APIs(REST modules) via AJS. Please suggest best way to do this.

Even after going through various docs and examples I could not find a solid approach to do this, and still there is a bit of confusion.

For storing data, I could find two ways. I can use PluginSettingsFactory or ActiveObjects. Apparently, these two services cannot be used in REST modules(Correct me if I am wrong. It will solve my problem.)

I want to go via ActiveObjects approach. But I not sure whether I can use it in JIRA plugin because it is made for Generic Confluence apps.

Let's say if it is possible to use ActiveObjects in JIRA plugin. I am not sure how to call POST of servlet using AJS. Please suggest a way if there is any?

 

If ActiveObjects can't be used in JIRA plugin, I will anyways have to go with PluginSettingsFactory inside servlets because apparenly I cannot use PluginSettingsFactory in REST ModuleAgain, I will have to go via Servlet approach and I am not sure how to call POST of servlet using AJS.

I know there are too many questions in this post. 

Please suggest a way if there is any?

1 comment

Comment

Log in or Sign up to comment
Maciej Nowakowski
Atlassian Team
Atlassian Team members are employees working across the company in a wide variety of roles.
March 30, 2018

Hey @imamudin naseem

Unfortunately it is hard to find one and the only right solution as each of these will have pros and cons :)

 

As you have found out there are at least two of them - PluginSettingsFactory and ActiveObjects. ActiveObjects is less constrained storage access which essentially gives you semi-direct access to the database. PluginSettingsFactory on the other hand requires none preparation on your end, but gives only simple key-value storage.

To fetch your data in front-end most likely you'll need to implement your own REST endpoint to control the data flow precisely as you want. Also it should be possible to use PluginSettingsFactory from REST endpoint.

minaseem March 30, 2018

Thanks @Maciej Nowakowski

I tried using PluginSettingsFactory inside Rest Module. Getting exception regarding dependency injection. Finding hard to understand dependency using @Scanned. 

I am stuck. It will be great if you could share link of some example that uses PluginSettingsFactory inside Rest Module.

Maciej Nowakowski
Atlassian Team
Atlassian Team members are employees working across the company in a wide variety of roles.
March 30, 2018

@imamudin naseemit looks like you are having troubles with dependencies rather than using PluginSettingsFactory on it's own.

Here you'll find comprehensive manual for atlassian-plugin-scanner: https://bitbucket.org/atlassian/atlassian-spring-scanner/src/1.2.x/README.md?at=1.2.x&fileviewer=file-view-default (which is responsible for @Scanned annotation)

If you find it challenging to start with scanner you can use alternative method of providing dependencies:  https://developer.atlassian.com/server/jira/platform/component-import/

Essentially, all you need to do is add a component-import entry to your atlassian-plugin.xml file

 

Here's comprehensive howto: https://developer.atlassian.com/server/framework/atlassian-sdk/sal-code-samples/

imamudin naseem April 2, 2018

@Maciej Nowakowski

Tried hands on component-import. Didn't work for me. 

Then Tried with atlassian-plugin-scanner. Breaking my head since hours, still no luck.

It will be great if you could fix dependecy injection in MyRestResource.java in below repo

https://github.com/minaseem/jiraPlugin

 

Thanks

imamudin naseem April 2, 2018

Just to add about injecting PluginSettingsFactory via component-import (followed https://developer.atlassian.com/server/framework/atlassian-sdk/sal-code-samples/), I got below exception 

Unsatisfied dependency expressed through constructor argument with index 0 of type [com.atlassian.sal.api.pluginsettings.PluginSettingsFactory]: No qualifying bean of type [com.atlassian.sal.api.pluginsettings.PluginSettingsFactory] found for dependency: expected at least 1 bean which qualifies as autowire candidate for this dependency. Dependency annotations: {}; nested exception is org.springframework.beans.factory.NoSuchBeanDefinitionException: No qualifying bean of type [com.atlassian.sal.api.pluginsettings.PluginSettingsFactory] found for dependency: expected at least 1 bean which qualifies as autowire candidate for this dependency. Dependency annotations: {}

Maciej Nowakowski
Atlassian Team
Atlassian Team members are employees working across the company in a wide variety of roles.
April 3, 2018

@imamudin naseem, I have managed to make your skeleton working: https://github.com/minaseem/jiraPlugin/pull/1

I was trying to keep commits meaningful, separating required changes.

Along the way I have also updated atlassian-spring-scanner to 2.x which also simplifies configuration. Docs: https://bitbucket.org/atlassian/atlassian-spring-scanner/src

imamudin naseem April 3, 2018

@Maciej Nowakowski,
Thanks for doing code changes. 

I applied your changes locally and while resolving dependencies, it says

Dependency '''com.atlassian.plugin:atlassian-spring-scanner-annotation:2.1.3''' not found less... (⌘F1) 
Inspects a Maven model for resolution problems.  
TAGS
AUG Leaders

Atlassian Community Events