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

Accepted Answer
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 Sign up to answer
Community showcase
Posted Tuesday in Jira

Looking for anyone who made the switch to Data Center

The Jira Marketing team is putting together an ebook on migrating to Data Center. We're looking for pro tips on how you staffed your project team and organized your Proof of Concept. Share yo...

26 views 0 2
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