How to get the custom project properties in jira plugin? Edited

I am making a jira plugin where the client side executes a jira api:

PUT - ${BASEURL}/rest/api/2/project/SAMPLE/properties/HT

 

On the backend I have a rest module trying to access the project properties data I created. This is the code I have so far...

ApplicationUser user = ComponentAccessor.getJiraAuthenticationContext().getLoggedInUser();
ProjectPropertyService projectPeopertyService = ComponentAccessor.getComponent(ProjectPropertyService.class);
EntityPropertyService.PropertyResult propertyValues = projectPeopertyService.getProperty(user, "SAMPLE", "HT"); //THIS SHOULD CONTAIN MY PROPERTIES
Option<EntityProperty> jsonValues = propertyValues.getEntityProperty();
jsonValues.get();

How do I parse the json data that is returned to me. I am not sure how to access it? I am trying to return jsonValues.get() but it's giving me a no serializer found exception.

Is this the correct way to extract the project properties data through component access?

1 answer

1 accepted

1 vote

Hello,

That is how you can access it:

import com.atlassian.jira.user.ApplicationUser
import com.atlassian.jira.component.ComponentAccessor
import com.atlassian.jira.bc.project.property.ProjectPropertyService
import com.atlassian.jira.entity.property.EntityPropertyService
import com.atlassian.jira.entity.property.EntityProperty
import com.atlassian.fugue.Option

ApplicationUser user = ComponentAccessor.getJiraAuthenticationContext().getLoggedInUser();
ProjectPropertyService projectPeopertyService = ComponentAccessor.getComponent(ProjectPropertyService.class);
EntityPropertyService.PropertyResult propertyValues = projectPeopertyService.getProperty(user, "SAMPLE", "HT"); //THIS SHOULD CONTAIN MY PROPERTIES
Option<EntityProperty> jsonValues = propertyValues.getEntityProperty();
def value1 = jsonValues.getOrNull()
log.error(value1.getValue());

Hi Alexey,

 

This was what I was looking for. Thanks!

Suggest an answer

Log in or Join to answer
Community showcase
Sarah Schuster
Posted Jan 29, 2018 in Jira

What are common themes you've seen across successful & failed Jira Software implementations?

Hey everyone! My name is Sarah Schuster, and I'm a Customer Success Manager in Atlassian specializing in Jira Software Cloud. Over the next few weeks I will be posting discussion topics (8 total) to ...

3,323 views 14 20
Join discussion

Atlassian User Groups

Connect with like-minded Atlassian users at free events near you!

Find a group

Connect with like-minded Atlassian users at free events near you!

Find my local user group

Unfortunately there are no AUG chapters near you at the moment.

Start an AUG

You're one step closer to meeting fellow Atlassian users at your local meet up. Learn more about AUGs

Groups near you
Atlassian Team Tour

Join us on the Team Tour

We're bringing product updates and pro tips on teamwork to ten cities around the world.

Save your spot