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

Next challenges

Recent achievements

  • Global
  • Personal

Recognition

  • Give kudos
  • Received
  • Given

Leaderboard

  • Global

Trophy case

Kudos (beta program)

Kudos logo

You've been invited into the Kudos (beta program) private group. Chat with others in the program, or give feedback to Atlassian.

View group

It's not the same without you

Join the community to find out what other Atlassian users are discussing, debating and creating.

Atlassian Community Hero Image Collage

How to use getEntityProperty() method of PropertyServiceResult class

Hi atlassian,

I have jira versions 7.x and 8.x and I want to build jira plugin to get two jar files. For jira version 7.x getEntityProperty() method returned:

com.atlassian.fugue.Option<EntityProperty> class type,

for jira version 8.x:

io.atlassian.fugue.Option<EntityProperty> class type,

I check the versions with statement, here my code:

 if (version.equals("7")) {
com.atlassian.fugue.Option<EntityProperty> jsonValues =
propertyValues.getEntityProperty();
entity = jsonValues.getOrNull();
} else {
io.atlassian.fugue.Option<EntityProperty> jsonValues =
propertyValues.getEntityProperty();
entity = jsonValues.getOrNull();
}

When the jira version is 7.x in my pom.xml I get the following error:

package io.atlassian.fugue does not exist

and the case when version is 8.x:

incompatible types: io.atlassian.fugue.Option<com.atlassian.jira.entity.property.EntityProperty> cannot be converted to com.atlassian.fugue.Option<com.atlassian.jira.entity.property.EntityProperty>

How can I solve this problem for in order to my plugin work for both jira versions?

Thanks in advance,

@Mamikon Papikyan 

1 answer

0 votes
Dario B Atlassian Team Nov 19, 2020

Hello @Mamikon Papikyan ,

This question has been already answered in the below threads, in the developers community and in here:


Specifically:

david2 Marketplace Partner Mar '19

@verenok you mean to build an app that’s compatible with both Jira 7 and Jira 8? There are two approaches:

  • build compatibility (adapter) libraries for Jira 7 and Jira 8 (compiling each against the appropriate Jira version) and call the right library based on the Jira version
  • use Java introspection to call the methods; since the only difference is in the return type it’s actually easy.

And:

david2 Marketplace Partner May '19

This is what we use to access the property value from the return value of issuePropertyService.getProperty:

  public static <T> T getEntityPropertyOrNull(PropertyResult propertyResult) {
    try {
      Object option = propertyResult.getClass().getMethod("getEntityProperty").invoke(propertyResult);
      return option.getClass().getMethod("getOrNull").invoke(option);
    } catch (InvocationTargetException | NoSuchMethodException | IllegalAccessException var2) {
      throw new IllegalStateException(var2);
    }
  }

 

Finally, please notice that this might not be the best place to get help on development related questions. In case further help will be needed on this topic, you might want to refer to the resources listed in https://developer.atlassian.com/resources:

 

 

Cheers,
Dario

Suggest an answer

Log in or Sign up to answer
DEPLOYMENT TYPE
CLOUD
PRODUCT PLAN
FREE
PERMISSIONS LEVEL
Site Admin
TAGS
Community showcase
Posted in Jira Software

Presenting the "Best of 2020" Jira Software roundup!

Catch up with Atlassian Product Managers in our 2020 Demo Den round-up! From Advanced Roadmaps to Code in Jira to Next-Gen Workflows, check out the videos below to help up-level your work in the new ...

7,184 views 8 28
Join discussion

Community Events

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

Find an event

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

Unfortunately there are no Community Events near you at the moment.

Host an event

You're one step closer to meeting fellow Atlassian users at your local event. Learn more about Community Events

Events near you