Forums

Articles
Create
cancel
Showing results for 
Search instead for 
Did you mean: 

Getting warning in logs while creating permissions by using SharePermissionUtils class

nitsajwa August 25, 2019

Hi Community Members,

We have developed a customized plugin in Jira using Atlassian SDK 6.3.12. This plugin creates projects in Jira instance. Somewhere in the code, we need to create permissions. Below is the code snippet for the same.


public SharedEntity.SharePermissions createSharePermissions(Project project)
{
SharedEntity.SharePermissions sharePermissions = null;
try
{
JSONArray jsonpermissionArray = new JSONArray();
String jsonText= "{\"type\":\"project\",\"param1\":\""+project.getId()+"\"}";
JSONObject jsonObjectProject = new JSONObject(jsonText);
Map<String,Boolean> map=new HashMap<>();
map.put("view", true);
jsonObjectProject.put("rights", map);
System.out.println(jsonObjectProject.get("rights"));
jsonpermissionArray.put(jsonObjectProject);
sharePermissions = SharePermissionUtils.fromJsonArray(jsonpermissionArray);


} catch (JSONException e) {
log.error(e.getMessage());
}catch (Exception e) {
log.error(e.getMessage());
}
return sharePermissions;
}

 

After the above-underlined line, I am getting a warning in logs which says:-

Rights object could not be found in the Share Permission JSON. Right to 'view' will be assigned as the default.

In order to resolve this issue when I am manually trying to add the rights object like below

jsonObjectProject.append("rights","VIEW");

I am again getting an error which states: - 

com.atlassian.jira.util.json.JSONException: JSONObject["rights"] is not a JSONObject.
at com.atlassian.jira.util.json.JSONObject.getJSONObject(JSONObject.java:500)
at com.atlassian.jira.sharing.SharePermissionUtils.fromJsonObject(SharePermissionUtils.java:98)

1 answer

0 votes
Dario B
Atlassian Team
Atlassian Team members are employees working across the company in a wide variety of roles.
August 29, 2019

Hi @nitsajwa ,

Please notice that this may not the best place to get help on development related questions. In case of no luck in getting an answer in here I'd advise to refer to the resources listed in https://developer.atlassian.com/resources/.

Specifically:

 

I hope this helps.

 

Cheers,
Dario

Suggest an answer

Log in or Sign up to answer