How to use getEntityProperty() method of PropertyServiceResult class

Mamikon Papikyan November 17, 2020

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
Atlassian Team members are employees working across the company in a wide variety of roles.
November 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
AUG Leaders

Atlassian Community Events